Home | History | Annotate | Download | only in src
      1 /*
      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"
     19 #include "GrGpu.h"
     20 
     21 bool 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 
     32 void GrRenderTarget::flagAsNeedingResolve(const GrIRect* rect) {
     33     if (kCanResolve_ResolveType == getResolveType()) {
     34         if (NULL != rect) {
     35             fResolveRect.join(*rect);
     36             if (!fResolveRect.intersect(0, 0, this->width(), this->height())) {
     37                 fResolveRect.setEmpty();
     38             }
     39         } else {
     40             fResolveRect.setLTRB(0, 0, this->width(), this->height());
     41         }
     42     }
     43 }
     44 
     45 void GrRenderTarget::overrideResolveRect(const GrIRect rect) {
     46     fResolveRect = rect;
     47     if (fResolveRect.isEmpty()) {
     48         fResolveRect.setLargestInverted();
     49     } else {
     50         if (!fResolveRect.intersect(0, 0, this->width(), this->height())) {
     51             fResolveRect.setLargestInverted();
     52         }
     53     }
     54 }
     55 
     56 bool 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 }
     66