blob: 8df9c9e8f5ce91c664d1082d4721f353814b306c [file] [log] [blame]
bsalomon@google.com669fdc42011-04-05 17:08:27 +00001/*
2 Copyright 2011 Google Inc.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17#include "GrTexture.h"
18#include "GrContext.h"
bsalomon@google.com05ef5102011-05-02 21:14:59 +000019#include "GrGpu.h"
bsalomon@google.com669fdc42011-04-05 17:08:27 +000020
21bool GrRenderTarget::readPixels(int left, int top, int width, int height,
22 GrPixelConfig config, void* buffer) {
23 // go through context so that all necessary flushing occurs
24 GrContext* context = this->getGpu()->getContext();
25 GrAssert(NULL != context);
26 return context->readRenderTargetPixels(this,
27 left, top,
28 width, height,
29 config, buffer);
30}
31
bsalomon@google.com8295dc12011-05-02 12:53:34 +000032void GrRenderTarget::flagAsNeedingResolve(const GrIRect* rect) {
33 if (kCanResolve_ResolveType == getResolveType()) {
34 if (NULL != rect) {
reed@google.com20efde72011-05-09 17:00:02 +000035 fResolveRect.join(*rect);
36 if (!fResolveRect.intersect(0, 0, this->width(), this->height())) {
37 fResolveRect.setEmpty();
38 }
bsalomon@google.com8295dc12011-05-02 12:53:34 +000039 } else {
40 fResolveRect.setLTRB(0, 0, this->width(), this->height());
41 }
42 }
43}
44
45void GrRenderTarget::overrideResolveRect(const GrIRect rect) {
46 fResolveRect = rect;
47 if (fResolveRect.isEmpty()) {
48 fResolveRect.setLargestInverted();
49 } else {
reed@google.com20efde72011-05-09 17:00:02 +000050 if (!fResolveRect.intersect(0, 0, this->width(), this->height())) {
bsalomon@google.com8295dc12011-05-02 12:53:34 +000051 fResolveRect.setLargestInverted();
52 }
53 }
54}
55
bsalomon@google.com669fdc42011-04-05 17:08:27 +000056bool GrTexture::readPixels(int left, int top, int width, int height,
57 GrPixelConfig config, void* buffer) {
58 // go through context so that all necessary flushing occurs
59 GrContext* context = this->getGpu()->getContext();
60 GrAssert(NULL != context);
61 return context->readTexturePixels(this,
62 left, top,
63 width, height,
64 config, buffer);
65}