1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/gpu/gl/GrGLTexture.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,68 @@ 1.4 +/* 1.5 + * Copyright 2011 Google Inc. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license that can be 1.8 + * found in the LICENSE file. 1.9 + */ 1.10 + 1.11 +#include "GrGLTexture.h" 1.12 +#include "GrGpuGL.h" 1.13 + 1.14 +#define GPUGL static_cast<GrGpuGL*>(getGpu()) 1.15 + 1.16 +#define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X) 1.17 + 1.18 +void GrGLTexture::init(GrGpuGL* gpu, 1.19 + const Desc& textureDesc, 1.20 + const GrGLRenderTarget::Desc* rtDesc) { 1.21 + 1.22 + SkASSERT(0 != textureDesc.fTextureID); 1.23 + 1.24 + fTexParams.invalidate(); 1.25 + fTexParamsTimestamp = GrGpu::kExpiredTimestamp; 1.26 + fTexIDObj.reset(SkNEW_ARGS(GrGLTexID, (GPUGL->glInterface(), 1.27 + textureDesc.fTextureID, 1.28 + textureDesc.fIsWrapped))); 1.29 + 1.30 + if (NULL != rtDesc) { 1.31 + GrGLIRect vp; 1.32 + vp.fLeft = 0; 1.33 + vp.fWidth = textureDesc.fWidth; 1.34 + vp.fBottom = 0; 1.35 + vp.fHeight = textureDesc.fHeight; 1.36 + 1.37 + fRenderTarget.reset(SkNEW_ARGS(GrGLRenderTarget, (gpu, *rtDesc, vp, fTexIDObj, this))); 1.38 + } 1.39 +} 1.40 + 1.41 +GrGLTexture::GrGLTexture(GrGpuGL* gpu, 1.42 + const Desc& textureDesc) 1.43 + : INHERITED(gpu, textureDesc.fIsWrapped, textureDesc) { 1.44 + this->init(gpu, textureDesc, NULL); 1.45 +} 1.46 + 1.47 +GrGLTexture::GrGLTexture(GrGpuGL* gpu, 1.48 + const Desc& textureDesc, 1.49 + const GrGLRenderTarget::Desc& rtDesc) 1.50 + : INHERITED(gpu, textureDesc.fIsWrapped, textureDesc) { 1.51 + this->init(gpu, textureDesc, &rtDesc); 1.52 +} 1.53 + 1.54 +void GrGLTexture::onRelease() { 1.55 + GPUGL->notifyTextureDelete(this); 1.56 + fTexIDObj.reset(NULL); 1.57 + INHERITED::onRelease(); 1.58 +} 1.59 + 1.60 +void GrGLTexture::onAbandon() { 1.61 + if (NULL != fTexIDObj.get()) { 1.62 + fTexIDObj->abandon(); 1.63 + fTexIDObj.reset(NULL); 1.64 + } 1.65 + 1.66 + INHERITED::onAbandon(); 1.67 +} 1.68 + 1.69 +GrBackendObject GrGLTexture::getTextureHandle() const { 1.70 + return static_cast<GrBackendObject>(this->textureID()); 1.71 +}