blob: 77868dfc9fdb0ab25fe21df37185bf09288651ba [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
bsalomon@google.com669fdc42011-04-05 17:08:27 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * 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.com669fdc42011-04-05 17:08:27 +00007 */
8
epoger@google.comec3ed6a2011-07-28 14:26:00 +00009
bsalomon@google.com669fdc42011-04-05 17:08:27 +000010#include "GrTexture.h"
bsalomon@google.comaa5b6732011-07-29 15:13:20 +000011
bsalomon@google.com669fdc42011-04-05 17:08:27 +000012#include "GrContext.h"
bsalomon@google.com05ef5102011-05-02 21:14:59 +000013#include "GrGpu.h"
bsalomon@google.comaa5b6732011-07-29 15:13:20 +000014#include "GrRenderTarget.h"
bsalomon@google.com8295dc12011-05-02 12:53:34 +000015
bsalomon@google.com669fdc42011-04-05 17:08:27 +000016bool 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.comcee661a2011-07-26 12:32:36 +000026
bsalomon@google.comaa5b6732011-07-29 15:13:20 +000027void GrTexture::releaseRenderTarget() {
28 if (NULL != fRenderTarget) {
29 GrAssert(fRenderTarget->asTexture() == this);
30 fRenderTarget->onTextureReleaseRenderTarget();
31 fRenderTarget->unref();
32 fRenderTarget = NULL;
33 }
34}
35
36void GrTexture::onAbandon() {
37 if (NULL != fRenderTarget) {
38 fRenderTarget->abandon();
39 }
40}
41