3 * Copyright 2011 Google Inc.
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
10 #include "GrRenderTarget.h"
12 #include "GrContext.h"
14 #include "GrStencilBuffer.h"
16 void GrRenderTarget::discard() {
17 // go through context so that all necessary flushing occurs
18 GrContext* context = this->getContext();
19 if (NULL == context) {
22 context->discardRenderTarget(this);
25 void GrRenderTarget::flagAsNeedingResolve(const SkIRect* rect) {
26 if (kCanResolve_ResolveType == getResolveType()) {
28 fResolveRect.join(*rect);
29 if (!fResolveRect.intersect(0, 0, this->width(), this->height())) {
30 fResolveRect.setEmpty();
33 fResolveRect.setLTRB(0, 0, this->width(), this->height());
38 void GrRenderTarget::overrideResolveRect(const SkIRect rect) {
40 if (fResolveRect.isEmpty()) {
41 fResolveRect.setLargestInverted();
43 if (!fResolveRect.intersect(0, 0, this->width(), this->height())) {
44 fResolveRect.setLargestInverted();
49 void GrRenderTarget::setStencilBuffer(GrStencilBuffer* stencilBuffer) {
50 SkRefCnt_SafeAssign(fStencilBuffer, stencilBuffer);
53 void GrRenderTarget::onRelease() {
54 this->setStencilBuffer(NULL);
56 INHERITED::onRelease();
59 void GrRenderTarget::onAbandon() {
60 this->setStencilBuffer(NULL);
62 INHERITED::onAbandon();