Only store width and height on SkPixelRef (last part)
authorMatt Sarett <msarett@google.com>
Mon, 1 May 2017 15:12:47 +0000 (11:12 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Mon, 1 May 2017 17:01:29 +0000 (17:01 +0000)
Relanding https://skia-review.googlesource.com/c/14105/
in pieces to try to diagnose problems with the Chrome
roll.

Bug: skia:6535
Change-Id: Iefe4825b9ce9be999baeec8ab7ae6651f1caf451
Reviewed-on: https://skia-review.googlesource.com/14860
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Matt Sarett <msarett@google.com>

gn/android_framework_defines.gni
include/core/SkPixelRef.h
public.bzl
src/core/SkBitmap.cpp
src/core/SkMallocPixelRef.cpp
src/core/SkPixelRef.cpp

index 67c6a2d..bc49f4b 100644 (file)
@@ -9,6 +9,7 @@ android_framework_defines = [
   "SK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS",
   "SK_SUPPORT_LEGACY_GRADIENT_DITHERING",
   "SK_SUPPORT_LEGACY_DRAWFILTER",
+  "SK_SUPPORT_LEGACY_PIXELREF_API",
   "SK_IGNORE_GPU_DITHER",
   "SK_SUPPORT_LEGACY_SHADER_ISABITMAP",
   "SK_SUPPORT_LEGACY_EMBOSSMASKFILTER",
index 3c002dc..bf46098 100644 (file)
@@ -32,6 +32,7 @@ class SkDiscardableMemory;
 */
 class SK_API SkPixelRef : public SkRefCnt {
 public:
+#ifdef SK_SUPPORT_LEGACY_PIXELREF_API
     SkPixelRef(const SkImageInfo&, void* addr, size_t rowBytes, sk_sp<SkColorTable> = nullptr);
 
     const SkImageInfo& info() const {
@@ -60,6 +61,8 @@ public:
      */
     virtual size_t getAllocatedSizeInBytes() const { return 0; }
 
+#endif
+
     SkPixelRef(int width, int height, void* addr, size_t rowBytes, sk_sp<SkColorTable> = nullptr);
 
     ~SkPixelRef() override;
index 9c41cdb..6e1908f 100644 (file)
@@ -655,6 +655,7 @@ DEFINES_ALL = [
     # Turn on a few Google3-specific build fixes.
     "GOOGLE3",
     # Staging flags for API changes
+    "SK_SUPPORT_LEGACY_PIXELREF_API",
     # Temporarily Disable analytic AA for Google3
     "SK_NO_ANALYTIC_AA",
 ]
index 5969a73..c23b5e2 100644 (file)
@@ -171,9 +171,6 @@ bool SkBitmap::setAlphaType(SkAlphaType newAlphaType) {
     }
     if (fInfo.alphaType() != newAlphaType) {
         fInfo = fInfo.makeAlphaType(newAlphaType);
-        if (fPixelRef) {
-            fPixelRef->changeAlphaType(newAlphaType);
-        }
     }
     SkDEBUGCODE(this->validate();)
     return true;
index 36b790f..cf4fac7 100644 (file)
@@ -156,7 +156,7 @@ SkMallocPixelRef::SkMallocPixelRef(const SkImageInfo& info, void* storage,
                                    size_t rowBytes, sk_sp<SkColorTable> ctable,
                                    SkMallocPixelRef::ReleaseProc proc,
                                    void* context)
-    : INHERITED(info, storage, rowBytes, sanitize(info, std::move(ctable)))
+    : INHERITED(info.width(), info.height(), storage, rowBytes, sanitize(info, std::move(ctable)))
     , fReleaseProc(proc)
     , fReleaseProcContext(context)
 {}
index 143abbc..7d8b12d 100644 (file)
@@ -30,6 +30,8 @@ uint32_t SkNextID::ImageID() {
     static int32_t gInstCounter;
 #endif
 
+#ifdef SK_SUPPORT_LEGACY_PIXELREF_API
+
 static SkImageInfo validate_info(const SkImageInfo& info) {
     SkAlphaType newAlphaType = info.alphaType();
     SkAssertResult(SkColorTypeValidateAlphaType(info.colorType(), info.alphaType(), &newAlphaType));
@@ -68,6 +70,8 @@ SkPixelRef::SkPixelRef(const SkImageInfo& info, void* pixels, size_t rowBytes,
     fAddedToCache.store(false);
 }
 
+#endif
+
 SkPixelRef::SkPixelRef(int width, int height, void* pixels, size_t rowBytes,
                        sk_sp<SkColorTable> ctable)
     : fInfo(SkImageInfo::MakeUnknown(width, height))
@@ -96,6 +100,7 @@ SkPixelRef::~SkPixelRef() {
 
 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
 
+#ifdef SK_SUPPORT_LEGACY_PIXELREF_API
 // This is undefined if there are clients in-flight trying to use us
 void SkPixelRef::android_only_reset(const SkImageInfo& info, size_t rowBytes,
                                     sk_sp<SkColorTable> ctable) {
@@ -108,6 +113,8 @@ void SkPixelRef::android_only_reset(const SkImageInfo& info, size_t rowBytes,
     this->notifyPixelsChanged();
 }
 
+#endif
+
 // This is undefined if there are clients in-flight trying to use us
 void SkPixelRef::android_only_reset(int width, int height, size_t rowBytes,
                                     sk_sp<SkColorTable> ctable) {
@@ -180,9 +187,11 @@ void SkPixelRef::notifyPixelsChanged() {
     this->onNotifyPixelsChanged();
 }
 
+#ifdef SK_SUPPORT_LEGACY_PIXELREF_API
 void SkPixelRef::changeAlphaType(SkAlphaType at) {
     *const_cast<SkImageInfo*>(&fInfo) = fInfo.makeAlphaType(at);
 }
+#endif
 
 void SkPixelRef::setImmutable() {
     fMutability = kImmutable;