Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / skia / src / gpu / gl / GrGLTexture.cpp
index 202fc42..8777d1b 100644 (file)
@@ -8,58 +8,42 @@
 #include "GrGLTexture.h"
 #include "GrGpuGL.h"
 
-#define GPUGL static_cast<GrGpuGL*>(getGpu())
-
+#define GPUGL static_cast<GrGpuGL*>(this->getGpu())
 #define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X)
 
-void GrGLTexture::init(GrGpuGL* gpu,
-                       const Desc& textureDesc,
-                       const GrGLRenderTarget::Desc* rtDesc) {
-
-    SkASSERT(0 != textureDesc.fTextureID);
-
-    fTexParams.invalidate();
-    fTexParamsTimestamp = GrGpu::kExpiredTimestamp;
-    fTexIDObj.reset(SkNEW_ARGS(GrGLTexID, (GPUGL->glInterface(),
-                                           textureDesc.fTextureID,
-                                           textureDesc.fIsWrapped)));
-
-    if (rtDesc) {
-        GrGLIRect vp;
-        vp.fLeft   = 0;
-        vp.fWidth  = textureDesc.fWidth;
-        vp.fBottom = 0;
-        vp.fHeight = textureDesc.fHeight;
-
-        fRenderTarget.reset(SkNEW_ARGS(GrGLRenderTarget, (gpu, *rtDesc, vp, fTexIDObj, this)));
-    }
+// Because this class is virtually derived from GrSurface we must explicitly call its constructor.
+GrGLTexture::GrGLTexture(GrGpuGL* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc)
+    : GrSurface(gpu, idDesc.fIsWrapped, desc)
+    , INHERITED(gpu, idDesc.fIsWrapped, desc) {
+    this->init(desc, idDesc);
     this->registerWithCache();
 }
 
-GrGLTexture::GrGLTexture(GrGpuGL* gpu,
-                         const Desc& textureDesc)
-    : INHERITED(gpu, textureDesc.fIsWrapped, textureDesc) {
-    this->init(gpu, textureDesc, NULL);
+GrGLTexture::GrGLTexture(GrGpuGL* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc, Derived)
+    : GrSurface(gpu, idDesc.fIsWrapped, desc)
+    , INHERITED(gpu, idDesc.fIsWrapped, desc) {
+    this->init(desc, idDesc);
 }
 
-GrGLTexture::GrGLTexture(GrGpuGL* gpu,
-                         const Desc& textureDesc,
-                         const GrGLRenderTarget::Desc& rtDesc)
-    : INHERITED(gpu, textureDesc.fIsWrapped, textureDesc) {
-    this->init(gpu, textureDesc, &rtDesc);
+void GrGLTexture::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) {
+    SkASSERT(0 != idDesc.fTextureID);
+    fTexParams.invalidate();
+    fTexParamsTimestamp = GrGpu::kExpiredTimestamp;
+    fTextureID = idDesc.fTextureID;
 }
 
 void GrGLTexture::onRelease() {
-    fTexIDObj.reset(NULL);
+    if (fTextureID) {
+        if (!this->isWrapped()) {
+            GL_CALL(DeleteTextures(1, &fTextureID));
+        }
+        fTextureID = 0;
+    }
     INHERITED::onRelease();
 }
 
 void GrGLTexture::onAbandon() {
-    if (fTexIDObj.get()) {
-        fTexIDObj->abandon();
-        fTexIDObj.reset(NULL);
-    }
-
+    fTextureID = 0;
     INHERITED::onAbandon();
 }