epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 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. |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 9 | |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 10 | #include "GrTexture.h" |
bsalomon@google.com | aa5b673 | 2011-07-29 15:13:20 +0000 | [diff] [blame^] | 11 | |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 12 | #include "GrContext.h" |
bsalomon@google.com | 05ef510 | 2011-05-02 21:14:59 +0000 | [diff] [blame] | 13 | #include "GrGpu.h" |
bsalomon@google.com | aa5b673 | 2011-07-29 15:13:20 +0000 | [diff] [blame^] | 14 | #include "GrRenderTarget.h" |
bsalomon@google.com | 8295dc1 | 2011-05-02 12:53:34 +0000 | [diff] [blame] | 15 | |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 16 | bool GrTexture::readPixels(int left, int top, int width, int height, |
| 17 | GrPixelConfig config, void* buffer) { |
| 18 | // go through context so that all necessary flushing occurs |
| 19 | GrContext* context = this->getGpu()->getContext(); |
| 20 | GrAssert(NULL != context); |
| 21 | return context->readTexturePixels(this, |
| 22 | left, top, |
| 23 | width, height, |
| 24 | config, buffer); |
| 25 | } |
bsalomon@google.com | cee661a | 2011-07-26 12:32:36 +0000 | [diff] [blame] | 26 | |
bsalomon@google.com | aa5b673 | 2011-07-29 15:13:20 +0000 | [diff] [blame^] | 27 | void GrTexture::releaseRenderTarget() { |
| 28 | if (NULL != fRenderTarget) { |
| 29 | GrAssert(fRenderTarget->asTexture() == this); |
| 30 | fRenderTarget->onTextureReleaseRenderTarget(); |
| 31 | fRenderTarget->unref(); |
| 32 | fRenderTarget = NULL; |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | void GrTexture::onAbandon() { |
| 37 | if (NULL != fRenderTarget) { |
| 38 | fRenderTarget->abandon(); |
| 39 | } |
| 40 | } |
| 41 | |