blob: 386bd2e779926e888f1edb87f33682827cc9691d [file] [log] [blame]
bsalomon@google.comaa5b6732011-07-29 15:13:20 +00001
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"
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000014#include "GrStencilBuffer.h"
bsalomon@google.comaa5b6732011-07-29 15:13:20 +000015
commit-bot@chromium.org28361fa2014-03-28 16:08:05 +000016void 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
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000025void GrRenderTarget::flagAsNeedingResolve(const SkIRect* rect) {
bsalomon@google.comaa5b6732011-07-29 15:13:20 +000026 if (kCanResolve_ResolveType == getResolveType()) {
bsalomon49f085d2014-09-05 13:34:00 -070027 if (rect) {
bsalomon@google.comaa5b6732011-07-29 15:13:20 +000028 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
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000038void GrRenderTarget::overrideResolveRect(const SkIRect rect) {
bsalomon@google.comaa5b6732011-07-29 15:13:20 +000039 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 }
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000047}
48
49void GrRenderTarget::setStencilBuffer(GrStencilBuffer* stencilBuffer) {
bsalomon@google.com76202b82013-05-10 19:08:22 +000050 SkRefCnt_SafeAssign(fStencilBuffer, stencilBuffer);
bsalomon@google.comf6ff4952011-08-09 13:32:14 +000051}
robertphillips@google.comd6bbbf82012-09-05 15:46:34 +000052
53void GrRenderTarget::onRelease() {
54 this->setStencilBuffer(NULL);
robertphillips@google.comd3645542012-09-05 18:37:39 +000055
56 INHERITED::onRelease();
robertphillips@google.comd6bbbf82012-09-05 15:46:34 +000057}
58
59void GrRenderTarget::onAbandon() {
60 this->setStencilBuffer(NULL);
robertphillips@google.comd3645542012-09-05 18:37:39 +000061
62 INHERITED::onAbandon();
robertphillips@google.comd6bbbf82012-09-05 15:46:34 +000063}