Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / skia / src / gpu / GrRenderTarget.cpp
1
2 /*
3  * Copyright 2011 Google Inc.
4  *
5  * Use of this source code is governed by a BSD-style license that can be
6  * found in the LICENSE file.
7  */
8
9
10 #include "GrRenderTarget.h"
11
12 #include "GrContext.h"
13 #include "GrGpu.h"
14 #include "GrStencilBuffer.h"
15
16 void GrRenderTarget::discard() {
17     // go through context so that all necessary flushing occurs
18     GrContext* context = this->getContext();
19     if (NULL == context) {
20         return;
21     }
22     context->discardRenderTarget(this);
23 }
24
25 void GrRenderTarget::flagAsNeedingResolve(const SkIRect* rect) {
26     if (kCanResolve_ResolveType == getResolveType()) {
27         if (rect) {
28             fResolveRect.join(*rect);
29             if (!fResolveRect.intersect(0, 0, this->width(), this->height())) {
30                 fResolveRect.setEmpty();
31             }
32         } else {
33             fResolveRect.setLTRB(0, 0, this->width(), this->height());
34         }
35     }
36 }
37
38 void GrRenderTarget::overrideResolveRect(const SkIRect rect) {
39     fResolveRect = rect;
40     if (fResolveRect.isEmpty()) {
41         fResolveRect.setLargestInverted();
42     } else {
43         if (!fResolveRect.intersect(0, 0, this->width(), this->height())) {
44             fResolveRect.setLargestInverted();
45         }
46     }
47 }
48
49 void GrRenderTarget::setStencilBuffer(GrStencilBuffer* stencilBuffer) {
50     SkRefCnt_SafeAssign(fStencilBuffer, stencilBuffer);
51 }
52
53 void GrRenderTarget::onRelease() {
54     this->setStencilBuffer(NULL);
55
56     INHERITED::onRelease();
57 }
58
59 void GrRenderTarget::onAbandon() {
60     this->setStencilBuffer(NULL);
61
62     INHERITED::onAbandon();
63 }