getDeferredTextureImageData(): use legacy scaling in legacy mode
authorMatt Sarett <msarett@google.com>
Fri, 14 Apr 2017 16:41:55 +0000 (12:41 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Fri, 14 Apr 2017 20:29:12 +0000 (20:29 +0000)
Bug:709341

Change-Id: I0dc1dcc3874f9741e0303e376a0ad4a68cd8b03e
Reviewed-on: https://skia-review.googlesource.com/13500
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Matt Sarett <msarett@google.com>

src/image/SkImage_Gpu.cpp

index f81708f..97a657a 100644 (file)
@@ -621,6 +621,10 @@ size_t SkImage::getDeferredTextureImageData(const GrContextThreadSafeProxy& prox
     if (!isScaled && this->peekPixels(&pixmap) && !pixmap.ctable()) {
         info = pixmap.info();
         pixelSize = SkAlign8(pixmap.getSafeSize());
+        if (!dstColorSpace) {
+            pixmap.setColorSpace(nullptr);
+            info = info.makeColorSpace(nullptr);
+        }
     } else {
         // Here we're just using presence of data to know whether there is a codec behind the image.
         // In the future we will access the cacherator and get the exact data that we want to (e.g.
@@ -637,6 +641,9 @@ size_t SkImage::getDeferredTextureImageData(const GrContextThreadSafeProxy& prox
                                                               scaledSize.height());
         } else {
             info = as_IB(this)->onImageInfo().makeWH(scaledSize.width(), scaledSize.height());
+            if (!dstColorSpace) {
+                info = info.makeColorSpace(nullptr);
+            }
         }
         if (kIndex_8_SkColorType == info.colorType()) {
             // Force Index8 to be N32 instead. Index8 is unsupported in Ganesh.
@@ -692,6 +699,7 @@ size_t SkImage::getDeferredTextureImageData(const GrContextThreadSafeProxy& prox
     size_t colorSpaceSize = 0;
     SkColorSpaceTransferFn fn;
     if (info.colorSpace()) {
+        SkASSERT(dstColorSpace);
         colorSpaceOffset = size;
         colorSpaceSize = info.colorSpace()->writeToMemory(nullptr);
         size += colorSpaceSize;