Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / skia / src / gpu / SkGrPixelRef.cpp
index feac9b1..1784d55 100644 (file)
@@ -54,7 +54,7 @@ bool SkROLockPixelsPixelRef::onLockPixelsAreWritable() const {
 ///////////////////////////////////////////////////////////////////////////////
 
 static SkGrPixelRef* copy_to_new_texture_pixelref(GrTexture* texture, SkColorType dstCT,
-                                           const SkIRect* subset) {
+                                                  const SkIRect* subset) {
     if (NULL == texture || kUnknown_SkColorType == dstCT) {
         return NULL;
     }
@@ -62,23 +62,22 @@ static SkGrPixelRef* copy_to_new_texture_pixelref(GrTexture* texture, SkColorTyp
     if (NULL == context) {
         return NULL;
     }
-    GrTextureDesc desc;
+    GrSurfaceDesc desc;
 
-    SkIPoint pointStorage;
-    SkIPoint* topLeft;
-    if (subset != NULL) {
+    SkIRect srcRect;
+
+    if (!subset) {
+        desc.fWidth  = texture->width();
+        desc.fHeight = texture->height();
+        srcRect = SkIRect::MakeWH(texture->width(), texture->height());
+    } else {
         SkASSERT(SkIRect::MakeWH(texture->width(), texture->height()).contains(*subset));
         // Create a new texture that is the size of subset.
         desc.fWidth = subset->width();
         desc.fHeight = subset->height();
-        pointStorage.set(subset->x(), subset->y());
-        topLeft = &pointStorage;
-    } else {
-        desc.fWidth  = texture->width();
-        desc.fHeight = texture->height();
-        topLeft = NULL;
+        srcRect = *subset;
     }
-    desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
+    desc.fFlags = kRenderTarget_GrSurfaceFlag | kNoStencil_GrSurfaceFlag;
     desc.fConfig = SkImageInfo2GrPixelConfig(dstCT, kPremul_SkAlphaType);
 
     GrTexture* dst = context->createUncachedTexture(desc, NULL, 0);
@@ -86,13 +85,12 @@ static SkGrPixelRef* copy_to_new_texture_pixelref(GrTexture* texture, SkColorTyp
         return NULL;
     }
 
-    context->copyTexture(texture, dst->asRenderTarget(), topLeft);
-
     // Blink is relying on the above copy being sent to GL immediately in the case when the source
-    // is a WebGL canvas backing store. We could have a TODO to remove this flush, but we have a
-    // larger TODO to remove SkGrPixelRef entirely.
-    context->flush();
-
+    // is a WebGL canvas backing store. We could have a TODO to remove this flush flag, but we have
+    // a larger TODO to remove SkGrPixelRef entirely.
+    context->copySurface(dst->asRenderTarget(), texture, srcRect, SkIPoint::Make(0,0),
+                         GrContext::kFlushWrites_PixelOp);
+  
     SkImageInfo info = SkImageInfo::Make(desc.fWidth, desc.fHeight, dstCT, kPremul_SkAlphaType);
     SkGrPixelRef* pixelRef = SkNEW_ARGS(SkGrPixelRef, (info, dst));
     SkSafeUnref(dst);
@@ -101,8 +99,7 @@ static SkGrPixelRef* copy_to_new_texture_pixelref(GrTexture* texture, SkColorTyp
 
 ///////////////////////////////////////////////////////////////////////////////
 
-SkGrPixelRef::SkGrPixelRef(const SkImageInfo& info, GrSurface* surface,
-                           bool transferCacheLock) : INHERITED(info) {
+SkGrPixelRef::SkGrPixelRef(const SkImageInfo& info, GrSurface* surface) : INHERITED(info) {
     // For surfaces that are both textures and render targets, the texture owns the
     // render target but not vice versa. So we ref the texture to keep both alive for
     // the lifetime of this pixel ref.
@@ -110,7 +107,6 @@ SkGrPixelRef::SkGrPixelRef(const SkImageInfo& info, GrSurface* surface,
     if (NULL == fSurface) {
         fSurface = SkSafeRef(surface);
     }
-    fUnlock = transferCacheLock;
 
     if (fSurface) {
         SkASSERT(info.width() <= fSurface->width());
@@ -119,13 +115,6 @@ SkGrPixelRef::SkGrPixelRef(const SkImageInfo& info, GrSurface* surface,
 }
 
 SkGrPixelRef::~SkGrPixelRef() {
-    if (fUnlock) {
-        GrContext* context = fSurface->getContext();
-        GrTexture* texture = fSurface->asTexture();
-        if (context && texture) {
-            context->unlockScratchTexture(texture);
-        }
-    }
     SkSafeUnref(fSurface);
 }