• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "GrTexture.h"
11 
12 #include "GrContext.h"
13 #include "GrGpu.h"
14 #include "GrRenderTarget.h"
15 
readPixels(int left,int top,int width,int height,GrPixelConfig config,void * buffer,size_t rowBytes)16 bool GrTexture::readPixels(int left, int top, int width, int height,
17                            GrPixelConfig config, void* buffer,
18                            size_t rowBytes) {
19     // go through context so that all necessary flushing occurs
20     GrContext* context = this->getContext();
21     if (NULL == context) {
22         return false;
23     }
24     return context->readTexturePixels(this,
25                                       left, top,
26                                       width, height,
27                                       config, buffer, rowBytes);
28 }
29 
writePixels(int left,int top,int width,int height,GrPixelConfig config,const void * buffer,size_t rowBytes)30 void GrTexture::writePixels(int left, int top, int width, int height,
31                             GrPixelConfig config, const void* buffer,
32                             size_t rowBytes) {
33     // go through context so that all necessary flushing occurs
34     GrContext* context = this->getContext();
35     if (NULL == context) {
36         return;
37     }
38     context->writeTexturePixels(this,
39                                 left, top,
40                                 width, height,
41                                 config, buffer, rowBytes);
42 }
43 
releaseRenderTarget()44 void GrTexture::releaseRenderTarget() {
45     if (NULL != fRenderTarget) {
46         GrAssert(fRenderTarget->asTexture() == this);
47         fRenderTarget->onTextureReleaseRenderTarget();
48         fRenderTarget->unref();
49         fRenderTarget = NULL;
50     }
51 }
52 
onAbandon()53 void GrTexture::onAbandon() {
54     if (NULL != fRenderTarget) {
55         fRenderTarget->abandon();
56     }
57 }
58 
59