hide lockpixels api behind flag
authorMike Reed <reed@google.com>
Mon, 17 Apr 2017 15:02:51 +0000 (11:02 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Mon, 17 Apr 2017 15:33:36 +0000 (15:33 +0000)
guarded by SK_SUPPORT_OBSOLETE_LOCKPIXELS

needs https://codereview.chromium.org/2820873002/# to land first
Bug: skia:6481
Change-Id: I1c39902cbf6fe99f622adfa8192733b95f7fea09

Change-Id: I1c39902cbf6fe99f622adfa8192733b95f7fea09
Reviewed-on: https://skia-review.googlesource.com/13580
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Mike Reed <reed@google.com>

86 files changed:
bench/BitmapBench.cpp
bench/GameBench.cpp
bench/RepeatTileBench.cpp
bench/TileBench.cpp
dm/DM.cpp
dm/DMSrcSink.cpp
fuzz/FuzzCanvas.cpp
gm/all_bitmap_configs.cpp
gm/drawbitmaprect.cpp
gm/encode-platform.cpp
gm/encode-srgb.cpp
gm/image_pict.cpp
gm/showmiplevels.cpp
gm/tinybitmap.cpp
gm/xfermodes3.cpp
gn/android_framework_defines.gni
include/core/SkBitmap.h
include/core/SkImageEncoder.h
include/core/SkPixelRef.h
include/core/SkPixmap.h
samplecode/SampleApp.cpp
samplecode/SampleBlur.cpp
samplecode/SampleDither.cpp
samplecode/SampleDitherBitmap.cpp
samplecode/SampleTextureDomain.cpp
samplecode/SampleTinyBitmap.cpp
samplecode/SampleUnpremul.cpp
samplecode/SampleVertices.cpp
src/core/SkBitmap.cpp
src/core/SkBitmapController.cpp
src/core/SkBitmapDevice.cpp
src/core/SkBitmapScaler.cpp
src/core/SkBlurImageFilter.cpp
src/core/SkCanvas.cpp
src/core/SkDraw.cpp
src/core/SkImageCacherator.cpp
src/core/SkMipMap.cpp
src/core/SkPixelRef.cpp
src/core/SkPixmap.cpp
src/core/SkSpecialImage.cpp
src/core/SkWriteBuffer.cpp
src/effects/SkAlphaThresholdFilter.cpp
src/effects/SkArithmeticImageFilter.cpp
src/effects/SkDisplacementMapEffect.cpp
src/effects/SkLightingImageFilter.cpp
src/effects/SkMagnifierImageFilter.cpp
src/effects/SkMatrixConvolutionImageFilter.cpp
src/effects/SkMorphologyImageFilter.cpp
src/effects/SkTableColorFilter.cpp
src/effects/gradients/SkGradientShader.cpp
src/gpu/SkGpuDevice.cpp
src/gpu/SkGr.cpp
src/gpu/effects/GrTextureStripAtlas.cpp
src/image/SkImage.cpp
src/image/SkImage_Raster.cpp
src/image/SkSurface_Raster.cpp
src/pdf/SkPDFBitmap.cpp
src/pdf/SkPDFDevice.cpp
src/pdf/SkPDFShader.cpp
src/utils/mac/SkCreateCGImageRef.cpp
src/views/win/SkOSWindow_win.cpp
src/xps/SkXPSDevice.cpp
tests/BitmapCopyTest.cpp
tests/BitmapTest.cpp
tests/BlendTest.cpp
tests/BlurTest.cpp
tests/CodecPartialTest.cpp
tests/CodecTest.cpp
tests/DrawBitmapRectTest.cpp
tests/DrawTextTest.cpp
tests/FontHostStreamTest.cpp
tests/GradientTest.cpp
tests/HighContrastFilterTest.cpp
tests/ImageFilterTest.cpp
tests/ImageFrom565Bitmap.cpp
tests/ImageNewShaderTest.cpp
tests/ImageTest.cpp
tests/ReadPixelsTest.cpp
tests/SerializationTest.cpp
tests/SurfaceTest.cpp
tests/WritePixelsTest.cpp
tools/debugger/SkDrawCommand.cpp
tools/picture_utils.cpp
tools/sk_tool_utils.cpp
tools/skdiff/skdiff.cpp
tools/skdiff/skdiff_utils.cpp

index fdf17e9..2fd480b 100644 (file)
@@ -47,9 +47,6 @@ static void convertToIndex666(const SkBitmap& src, SkBitmap* dst, SkAlphaType aT
     dst->allocPixels(SkImageInfo::Make(src.width(), src.height(), kIndex_8_SkColorType, aType),
                      SkColorTable::Make(storage, 216));
 
-    SkAutoLockPixels alps(src);
-    SkAutoLockPixels alpd(*dst);
-
     for (int y = 0; y < src.height(); y++) {
         const SkPMColor* srcP = src.getAddr32(0, y);
         uint8_t* dstP = dst->getAddr8(0, y);
index bd7d114..dfd0aa1 100644 (file)
@@ -250,7 +250,6 @@ private:
         static int kCheckSize = 16;
 
         fCheckerboard.allocN32Pixels(kCheckerboardWidth, kCheckerboardHeight);
-        SkAutoLockPixels lock(fCheckerboard);
         for (int y = 0; y < kCheckerboardHeight; ++y) {
             int even = (y / kCheckSize) % 2;
 
@@ -283,7 +282,6 @@ private:
         }
 
         fAtlas.allocN32Pixels(kTotAtlasWidth, kTotAtlasHeight);
-        SkAutoLockPixels lock(fAtlas);
 
         for (int y = 0; y < kTotAtlasHeight; ++y) {
             int colorY = y / (kAtlasCellHeight + kAtlasSpacer);
index df58a14..5506031 100644 (file)
@@ -66,9 +66,6 @@ static void convert_to_index666(const SkBitmap& src, SkBitmap* dst) {
                                        kIndex_8_SkColorType, kOpaque_SkAlphaType),
                      SkColorTable::Make(storage, 216));
 
-    SkAutoLockPixels alps(src);
-    SkAutoLockPixels alpd(*dst);
-
     for (int y = 0; y < src.height(); y++) {
         const SkPMColor* srcP = src.getAddr32(0, y);
         uint8_t* dstP = dst->getAddr8(0, y);
index 3093016..cd26546 100644 (file)
@@ -18,7 +18,6 @@ static void create_gradient(SkBitmap* bm) {
     float deltaB = 255.0f / height;
     float blue = 255.0f;
 
-    SkAutoLockPixels lock(*bm);
     for (int y = 0; y < height; y++) {
         *bm->getAddr32(0, y) = SkColorSetRGB(0, 0, (U8CPU) blue);
         blue -= deltaB;
index 340c338..707c4c9 100644 (file)
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -1110,9 +1110,6 @@ struct Task {
             gDefinitelyThreadSafeWork.add([task,name,bitmap,data]{
                 std::unique_ptr<SkStreamAsset> ownedData(data);
 
-                // Why doesn't the copy constructor do this when we have pre-locked pixels?
-                bitmap.lockPixels();
-
                 SkString md5;
                 if (!FLAGS_writePath.isEmpty() || !FLAGS_readPath.isEmpty()) {
                     SkMD5 hash;
index 3a19751..b223c97 100644 (file)
@@ -1567,7 +1567,6 @@ Error ViaUpright::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkSt
     canvas.drawBitmap(*bitmap, 0, 0, &paint);
 
     *bitmap = uprighted;
-    bitmap->lockPixels();
     return "";
 }
 
index ba9f3ed..3796812 100644 (file)
@@ -982,7 +982,6 @@ static SkBitmap make_fuzz_bitmap(Fuzz* fuzz) {
     fuzz->nextRange(&w, 1, 1024);
     fuzz->nextRange(&h, 1, 1024);
     bitmap.allocN32Pixels(w, h);
-    SkAutoLockPixels autoLockPixels(bitmap);
     for (int y = 0; y < h; ++y) {
         for (int x = 0; x < w; ++x) {
             SkColor c;
index 60aec88..7e9dfab 100644 (file)
@@ -37,7 +37,6 @@ static SkBitmap make_bitmap(SkColorType ct) {
             SkASSERT(false);
             return bm;
     }
-    SkAutoLockPixels autoLockPixels(bm);
     uint8_t spectrum[256];
     for (int y = 0; y < 256; ++y) {
         spectrum[y] = y;
@@ -127,8 +126,6 @@ static SkBitmap indexed_bitmap() {
     SkImageInfo info = SkImageInfo::Make(SCALE, SCALE, kIndex_8_SkColorType,
                                          kPremul_SkAlphaType);
     bm.allocPixels(info, SkColorTable::Make(pmColors, SK_ARRAY_COUNT(pmColors)));
-    SkAutoLockPixels autoLockPixels1(n32bitmap);
-    SkAutoLockPixels autoLockPixels2(bm);
     for (int y = 0; y < SCALE; ++y) {
         for (int x = 0; x < SCALE; ++x) {
             SkPMColor c = *n32bitmap.getAddr32(x, y);
index bad5e2a..0becf45 100644 (file)
@@ -28,7 +28,6 @@ static SkBitmap make_chessbm(int w, int h) {
             p[x] = ((x + y) & 1) ? SK_ColorWHITE : SK_ColorBLACK;
         }
     }
-    bm.unlockPixels();
     return bm;
 }
 
index ca3cda1..f08da73 100644 (file)
@@ -23,7 +23,6 @@ static void make_premul_256(SkBitmap* bitmap) {
     SkBitmap tmp;
     GetResourceAsBitmap("yellow_rose.png", &tmp);
     tmp.extractSubset(bitmap, SkIRect::MakeWH(256, 256));
-    bitmap->lockPixels();
 }
 
 static void make_unpremul_256(SkBitmap* bitmap) {
@@ -57,7 +56,6 @@ static SkEncodedImageFormat kTypes[] {
 #endif
 
 static sk_sp<SkData> encode_data(SkEncodedImageFormat type, const SkBitmap& bitmap) {
-    SkAutoLockPixels autoLockPixels(bitmap);
     SkPixmap src;
     if (!bitmap.peekPixels(&src)) {
         return nullptr;
index 894b0ef..3015baa 100644 (file)
@@ -109,7 +109,6 @@ static void make(SkBitmap* bitmap, SkColorType colorType, SkAlphaType alphaType,
 }
 
 static sk_sp<SkData> encode_data(const SkBitmap& bitmap, SkEncodedImageFormat format) {
-    SkAutoLockPixels autoLockPixels(bitmap);
     SkPixmap src;
     if (!bitmap.peekPixels(&src)) {
         return nullptr;
index f23b89e..904daae 100644 (file)
@@ -118,9 +118,9 @@ static std::unique_ptr<SkImageGenerator> make_pic_generator(GrContext*, sk_sp<Sk
 
 class RasterGenerator : public SkImageGenerator {
 public:
-    RasterGenerator(const SkBitmap& bm) : SkImageGenerator(bm.info()), fBM(bm) {
-        fBM.lockPixels();
-    }
+    RasterGenerator(const SkBitmap& bm) : SkImageGenerator(bm.info()), fBM(bm)
+    {}
+
 protected:
     bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
                      SkPMColor* ctable, int* ctableCount) override {
index 0dd19d5..e5374e4 100644 (file)
@@ -93,7 +93,6 @@ public:
 
     static void apply_gamma(const SkBitmap& bm) {
         return; // below is our experiment for sRGB correction
-        bm.lockPixels();
         for (int y = 0; y < bm.height(); ++y) {
             for (int x = 0; x < bm.width(); ++x) {
                 SkPMColor c = *bm.getAddr32(x, y);
@@ -136,7 +135,6 @@ protected:
         SkScalar y = 4;
 
         SkPixmap prevPM;
-        baseBM.lockPixels();
         baseBM.peekPixels(&prevPM);
 
         SkDestinationSurfaceColorMode colorMode = SkDestinationSurfaceColorMode::kLegacy;
@@ -181,7 +179,6 @@ protected:
         };
 
         SkPixmap basePM;
-        orig.lockPixels();
         orig.peekPixels(&basePM);
         for (auto method : methods) {
             canvas->translate(orig.width()/2 + 8.0f, 0);
index 1640cb2..f8103cf 100644 (file)
@@ -21,9 +21,7 @@ static SkBitmap make_bitmap() {
                                      kPremul_SkAlphaType),
                    SkColorTable::Make(c, SK_ARRAY_COUNT(c)));
 
-    bm.lockPixels();
     *bm.getAddr8(0, 0) = 0;
-    bm.unlockPixels();
     return bm;
 }
 
index f977b66..6e4d8b8 100644 (file)
@@ -182,7 +182,6 @@ private:
         };
         SkBitmap bg;
         bg.allocN32Pixels(2, 2, true);
-        SkAutoLockPixels bgAlp(bg);
         memcpy(bg.getPixels(), kCheckData, sizeof(kCheckData));
 
         SkMatrix lm;
index 67c6a2d..bf5a051 100644 (file)
@@ -12,4 +12,5 @@ android_framework_defines = [
   "SK_IGNORE_GPU_DITHER",
   "SK_SUPPORT_LEGACY_SHADER_ISABITMAP",
   "SK_SUPPORT_LEGACY_EMBOSSMASKFILTER",
+  "SK_SUPPORT_OBSOLETE_LOCKPIXELS",
 ]
index 9520210..e19f452 100644 (file)
@@ -217,8 +217,8 @@ public:
      *  "unknown" pixels.
      */
     static bool ComputeIsOpaque(const SkBitmap& bm) {
-        SkAutoPixmapUnlock result;
-        return bm.requestLock(&result) && result.pixmap().computeIsOpaque();
+        SkPixmap pmap;
+        return bm.peekPixels(&pmap) && pmap.computeIsOpaque();
     }
 
     /**
@@ -419,10 +419,11 @@ public:
      */
     void setPixelRef(sk_sp<SkPixelRef>, int dx, int dy);
 
+#ifdef SK_SUPPORT_OBSOLETE_LOCKPIXELS
     void lockPixels() const {}
     void unlockPixels() const {}
-
     bool requestLock(SkAutoPixmapUnlock* result) const;
+#endif
 
     /** Call this to be sure that the bitmap is valid enough to be drawn (i.e.
         it has non-null pixels, and if required by its colortype, it has a
@@ -755,26 +756,12 @@ private:
     friend class SkBinaryWriteBuffer; // rawpixels
 };
 
+#ifdef SK_SUPPORT_OBSOLETE_LOCKPIXELS
 class SkAutoLockPixels : SkNoncopyable {
 public:
-    SkAutoLockPixels(const SkBitmap& bm, bool doLock = true) : fBitmap(bm) {
-        fDidLock = doLock;
-        if (doLock) {
-            bm.lockPixels();
-        }
-    }
-    ~SkAutoLockPixels() {
-        if (fDidLock) {
-            fBitmap.unlockPixels();
-        }
-    }
-
-private:
-    const SkBitmap& fBitmap;
-    bool            fDidLock;
+    SkAutoLockPixels(const SkBitmap&, bool = true) {}
 };
-//TODO(mtklein): uncomment when 71713004 lands and Chromium's fixed.
-//#define SkAutoLockPixels(...) SK_REQUIRE_LOCAL_VAR(SkAutoLockPixels)
+#endif
 
 ///////////////////////////////////////////////////////////////////////////////
 
index e4f746a..5cd5f4a 100644 (file)
@@ -34,7 +34,6 @@ SK_API bool SkEncodeImage(SkWStream* dst, const SkPixmap& src,
  * The following helper function wraps SkEncodeImage().
  */
 inline bool SkEncodeImage(SkWStream* dst, const SkBitmap& src, SkEncodedImageFormat f, int q) {
-    SkAutoLockPixels autoLockPixels(src);
     SkPixmap pixmap;
     return src.peekPixels(&pixmap) && SkEncodeImage(dst, pixmap, f, q);
 }
index 0e66f25..56e0caf 100644 (file)
@@ -32,22 +32,18 @@ class SkDiscardableMemory;
 */
 class SK_API SkPixelRef : public SkRefCnt {
 public:
-    explicit SkPixelRef(const SkImageInfo&, void* addr, size_t rowBytes,
-                        sk_sp<SkColorTable> = nullptr);
-    virtual ~SkPixelRef();
+    SkPixelRef(const SkImageInfo&, void* addr, size_t rowBytes, sk_sp<SkColorTable> = nullptr);
+    ~SkPixelRef() override;
 
     const SkImageInfo& info() const {
         return fInfo;
     }
 
-    void* pixels() const { return fRec.fPixels; }
-    SkColorTable* colorTable() const { return fRec.fColorTable; }
-    size_t rowBytes() const { return fRec.fRowBytes; }
+    void* pixels() const { return fPixels; }
+    SkColorTable* colorTable() const { return fCTable.get(); }
+    size_t rowBytes() const { return fRowBytes; }
 
-    /**
-     *  To access the actual pixels of a pixelref, it must be "locked".
-     *  Calling lockPixels returns a LockRec struct (on success).
-     */
+#ifdef SK_SUPPORT_OBSOLETE_LOCKPIXELS
     struct LockRec {
         LockRec() : fPixels(NULL), fColorTable(NULL) {}
 
@@ -72,6 +68,33 @@ public:
      */
     bool lockPixels(LockRec* rec);
 
+    struct LockRequest {
+        SkISize         fSize;
+        SkFilterQuality fQuality;
+    };
+
+    struct LockResult {
+        LockResult() : fPixels(NULL), fCTable(NULL) {}
+
+        void        (*fUnlockProc)(void* ctx);
+        void*       fUnlockContext;
+
+        const void* fPixels;
+        SkColorTable* fCTable;  // should be NULL unless colortype is kIndex8
+        size_t      fRowBytes;
+        SkISize     fSize;
+
+        void unlock() {
+            if (fUnlockProc) {
+                fUnlockProc(fUnlockContext);
+                fUnlockProc = NULL; // can't unlock twice!
+            }
+        }
+    };
+
+    bool requestLock(const LockRequest&, LockResult*);
+#endif
+
 
     /** Returns a non-zero, unique value corresponding to the pixels in this
         pixelref. Each time the pixels are changed (and notifyPixelsChanged is
@@ -116,32 +139,6 @@ public:
     */
     void setImmutable();
 
-    struct LockRequest {
-        SkISize         fSize;
-        SkFilterQuality fQuality;
-    };
-
-    struct LockResult {
-        LockResult() : fPixels(NULL), fCTable(NULL) {}
-
-        void        (*fUnlockProc)(void* ctx);
-        void*       fUnlockContext;
-
-        const void* fPixels;
-        SkColorTable* fCTable;  // should be NULL unless colortype is kIndex8
-        size_t      fRowBytes;
-        SkISize     fSize;
-
-        void unlock() {
-            if (fUnlockProc) {
-                fUnlockProc(fUnlockContext);
-                fUnlockProc = NULL; // can't unlock twice!
-            }
-        }
-    };
-
-    bool requestLock(const LockRequest&, LockResult*);
-
     // Register a listener that may be called the next time our generation ID changes.
     //
     // We'll only call the listener if we're confident that we are the only SkPixelRef with this
@@ -188,10 +185,9 @@ protected:
 private:
     // mostly const. fInfo.fAlpahType can be changed at runtime.
     const SkImageInfo fInfo;
-    sk_sp<SkColorTable> fCTable;    // duplicated in LockRec, will unify later
-
-    // LockRec is only valid if we're in a locked state (isLocked())
-    LockRec         fRec;
+    sk_sp<SkColorTable> fCTable;
+    void*             fPixels;
+    size_t            fRowBytes;
 
     // Bottom bit indicates the Gen ID is unique.
     bool genIDIsUnique() const { return SkToBool(fTaggedGenID.load() & 1); }
@@ -212,9 +208,6 @@ private:
         kImmutable,             // Once set to this state, it never leaves.
     } fMutability : 8;          // easily fits inside a byte
 
-    // only ever set in constructor, const after that
-    bool fPreLocked;
-
     void needsNewGenID();
     void callGenIDChangeListeners();
 
@@ -222,7 +215,6 @@ private:
     void restoreMutability();
     friend class SkSurface_Raster;   // For the two methods above.
 
-    bool isPreLocked() const { return fPreLocked; }
     friend class SkImage_Raster;
     friend class SkSpecialImage_Raster;
 
index 6cf948e..d028124 100644 (file)
@@ -221,8 +221,7 @@ private:
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 
-/////////////////////////////////////////////////////////////////////////////////////////////
-
+#ifdef SK_SUPPORT_OBSOLETE_LOCKPIXELS
 class SK_API SkAutoPixmapUnlock : ::SkNoncopyable {
 public:
     SkAutoPixmapUnlock() : fUnlockProc(NULL), fIsLocked(false) {}
@@ -268,5 +267,6 @@ private:
 
     friend class SkBitmap;
 };
+#endif
 
 #endif
index feace00..bdd1ef1 100644 (file)
@@ -1282,7 +1282,6 @@ void SampleWindow::showZoomer(SkCanvas* canvas) {
     else if (fMouseY < 0) fMouseY = 0;
 
     SkBitmap bitmap = capture_bitmap(canvas);
-    bitmap.lockPixels();
 
     // Find the size of the zoomed in view, forced to be odd, so the examined pixel is in the middle.
     int zoomedWidth = (width >> 1) | 1;
index c43dc9b..4c4082c 100644 (file)
@@ -25,7 +25,6 @@ static SkBitmap make_bitmap() {
                                      kPremul_SkAlphaType),
                    SkColorTable::Make(c, 256));
 
-    bm.lockPixels();
     const float cx = bm.width() * 0.5f;
     const float cy = bm.height() * 0.5f;
     for (int y = 0; y < bm.height(); y++) {
@@ -43,7 +42,6 @@ static SkBitmap make_bitmap() {
             p[x] = id;
         }
     }
-    bm.unlockPixels();
     return bm;
 }
 
index a1b751b..76ebecc 100644 (file)
@@ -73,8 +73,6 @@ static void make_bm(SkBitmap* bm) {
 }
 
 static void pre_dither(const SkBitmap& bm) {
-    SkAutoLockPixels alp(bm);
-
     for (int y = 0; y < bm.height(); y++) {
         DITHER_4444_SCAN(y);
 
index bdd3071..e5f7369 100644 (file)
@@ -60,14 +60,12 @@ static SkBitmap make_bitmap() {
     bm.allocPixels(SkImageInfo::Make(256, 32, kIndex_8_SkColorType, kPremul_SkAlphaType),
                    SkColorTable::Make(c, 256));
 
-    bm.lockPixels();
     for (int y = 0; y < bm.height(); y++) {
         uint8_t* p = bm.getAddr8(0, y);
         for (int x = 0; x < 256; x++) {
             p[x] = x;
         }
     }
-    bm.unlockPixels();
     return bm;
 }
 
@@ -95,7 +93,6 @@ protected:
     }
 
     static void setBitmapOpaque(SkBitmap* bm, bool isOpaque) {
-        SkAutoLockPixels alp(*bm);  // needed for ctable
         bm->setAlphaType(isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
     }
 
index e615235..9c7f3de 100644 (file)
@@ -21,7 +21,6 @@ static SkBitmap make_bitmap() {
             p[x] = ((x + y) & 1) ? SK_ColorWHITE : SK_ColorBLACK;
         }
     }
-    bm.unlockPixels();
     return bm;
 }
 
index 6b01d11..2212cbe 100644 (file)
@@ -25,14 +25,12 @@ static SkBitmap make_bitmap() {
                                      kPremul_SkAlphaType),
                    SkColorTable::Make(c, N));
 
-    bm.lockPixels();
     for (int y = 0; y < bm.height(); y++) {
         uint8_t* p = bm.getAddr8(0, y);
         for (int x = 0; x < bm.width(); x++) {
             p[x] = 0;
         }
     }
-    bm.unlockPixels();
     return bm;
 }
 
@@ -54,7 +52,6 @@ protected:
     }
 
     static void setBitmapOpaque(SkBitmap* bm, bool isOpaque) {
-        SkAutoLockPixels alp(*bm);  // needed for ctable
         bm->setAlphaType(isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
     }
 
index 558bf93..be42d23 100644 (file)
@@ -116,7 +116,6 @@ protected:
         canvas->translate(height * 2, height * 2);
         if (!fPremul) {
             // A premultiplied bitmap cannot currently be drawn.
-            SkAutoLockPixels alp(fBitmap);
             // Copy it to a bitmap which can be drawn, converting
             // to premultiplied:
             SkBitmap bm;
index 9d3e601..9c6eeb8 100644 (file)
@@ -30,11 +30,9 @@ static sk_sp<SkShader> make_shader0(SkIPoint* size) {
     SkPMColor color1 = SkPreMultiplyARGB(0x40, 0xff, 0x00, 0xff);
     bm.allocN32Pixels(size->fX, size->fY);
     bm.eraseColor(color0);
-    bm.lockPixels();
     uint32_t* pixels = (uint32_t*) bm.getPixels();
     pixels[0] = pixels[2] = color0;
     pixels[1] = pixels[3] = color1;
-    bm.unlockPixels();
 
     return SkShader::MakeBitmapShader(bm, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);
 }
index 5c6efd4..7e3b2c9 100644 (file)
@@ -478,12 +478,12 @@ void SkBitmap::erase(SkColor c, const SkIRect& area) const {
             break;
     }
 
-    SkAutoPixmapUnlock result;
-    if (!this->requestLock(&result)) {
+    SkPixmap result;
+    if (!this->peekPixels(&result)) {
         return;
     }
 
-    if (result.pixmap().erase(c, area)) {
+    if (result.erase(c, area)) {
         this->notifyPixelsChanged();
     }
 }
@@ -566,11 +566,11 @@ bool SkBitmap::canCopyTo(SkColorType dstCT) const {
 
 bool SkBitmap::readPixels(const SkImageInfo& requestedDstInfo, void* dstPixels, size_t dstRB,
                           int x, int y) const {
-    SkAutoPixmapUnlock src;
-    if (!this->requestLock(&src)) {
+    SkPixmap src;
+    if (!this->peekPixels(&src)) {
         return false;
     }
-    return src.pixmap().readPixels(requestedDstInfo, dstPixels, dstRB, x, y);
+    return src.readPixels(requestedDstInfo, dstPixels, dstRB, x, y);
 }
 
 bool SkBitmap::readPixels(const SkPixmap& dst, int srcX, int srcY) const {
@@ -579,11 +579,6 @@ bool SkBitmap::readPixels(const SkPixmap& dst, int srcX, int srcY) const {
 
 bool SkBitmap::writePixels(const SkPixmap& src, int dstX, int dstY,
                            SkTransferFunctionBehavior behavior) {
-    SkAutoPixmapUnlock dst;
-    if (!this->requestLock(&dst)) {
-        return false;
-    }
-
     if (!SkImageInfoValidConversion(fInfo, src.info())) {
         return false;
     }
@@ -605,11 +600,10 @@ bool SkBitmap::internalCopyTo(SkBitmap* dst, SkColorType dstColorType, Allocator
         return false;
     }
 
-    SkAutoPixmapUnlock srcUnlocker;
-    if (!this->requestLock(&srcUnlocker)) {
+    SkPixmap srcPM;
+    if (!this->peekPixels(&srcPM)) {
         return false;
     }
-    SkPixmap srcPM = srcUnlocker.pixmap();
 
     // Various Android specific compatibility modes.
     // TODO:
@@ -654,13 +648,11 @@ bool SkBitmap::internalCopyTo(SkBitmap* dst, SkColorType dstColorType, Allocator
         return false;
     }
 
-    SkAutoPixmapUnlock dstUnlocker;
-    if (!tmpDst.requestLock(&dstUnlocker)) {
+    SkPixmap dstPM;
+    if (!tmpDst.peekPixels(&dstPM)) {
         return false;
     }
 
-    SkPixmap dstPM = dstUnlocker.pixmap();
-
     // We can't do a sane conversion from F16 without a src color space.  Guess sRGB in this case.
     if (kRGBA_F16_SkColorType == srcPM.colorType() && !dstPM.colorSpace()) {
         dstPM.setColorSpace(SkColorSpace::MakeSRGB());
@@ -721,15 +713,14 @@ static bool GetBitmapAlpha(const SkBitmap& src, uint8_t* SK_RESTRICT alpha, int
     SkASSERT(alpha != nullptr);
     SkASSERT(alphaRowBytes >= src.width());
 
-    SkAutoPixmapUnlock apl;
-    if (!src.requestLock(&apl)) {
+    SkPixmap pmap;
+    if (!src.peekPixels(&pmap)) {
         for (int y = 0; y < src.height(); ++y) {
             memset(alpha, 0, src.width());
             alpha += alphaRowBytes;
         }
         return false;
     }
-    const SkPixmap& pmap = apl.pixmap();
     SkConvertPixels(SkImageInfo::MakeA8(pmap.width(), pmap.height()), alpha, alphaRowBytes,
                     pmap.info(), pmap.addr(), pmap.rowBytes(), pmap.ctable(),
                     SkTransferFunctionBehavior::kRespect);
@@ -841,13 +832,13 @@ void SkBitmap::WriteRawPixels(SkWriteBuffer* buffer, const SkBitmap& bitmap) {
         return;
     }
 
-    SkAutoPixmapUnlock result;
-    if (!bitmap.requestLock(&result)) {
+    SkPixmap result;
+    if (!bitmap.peekPixels(&result)) {
         buffer->writeUInt(0); // instead of snugRB, signaling no pixels
         return;
     }
 
-    write_raw_pixels(buffer, result.pixmap());
+    write_raw_pixels(buffer, result);
 }
 
 bool SkBitmap::ReadRawPixels(SkReadBuffer* buffer, SkBitmap* bitmap) {
@@ -1003,6 +994,7 @@ void SkBitmap::toString(SkString* str) const {
 
 ///////////////////////////////////////////////////////////////////////////////
 
+#ifdef SK_SUPPORT_OBSOLETE_LOCKPIXELS
 bool SkBitmap::requestLock(SkAutoPixmapUnlock* result) const {
     SkASSERT(result);
 
@@ -1031,6 +1023,7 @@ bool SkBitmap::requestLock(SkAutoPixmapUnlock* result) const {
     }
     return false;
 }
+#endif
 
 bool SkBitmap::peekPixels(SkPixmap* pmap) const {
     if (fPixels) {
index c72693f..ba287b5 100644 (file)
@@ -116,7 +116,6 @@ bool SkDefaultBitmapControllerState::processHQRequest(const SkBitmapProvider& pr
     if (fCanShadeHQ) {
         fQuality = kHigh_SkFilterQuality;
         SkAssertResult(provider.asBitmap(&fResultBitmap));
-        fResultBitmap.lockPixels();
         return true;
     }
 
@@ -129,15 +128,15 @@ bool SkDefaultBitmapControllerState::processHQRequest(const SkBitmapProvider& pr
         if (!provider.asBitmap(&orig)) {
             return false;
         }
-        SkAutoPixmapUnlock src;
-        if (!orig.requestLock(&src)) {
+        SkPixmap src;
+        if (!orig.peekPixels(&src)) {
             return false;
         }
 
         SkPixmap dst;
         SkBitmapCache::RecPtr rec;
         const SkImageInfo info = SkImageInfo::MakeN32(desc.fScaledWidth, desc.fScaledHeight,
-                                                      src.pixmap().alphaType());
+                                                      src.alphaType());
         if (provider.isVolatile()) {
             if (!fResultBitmap.tryAllocPixels(info)) {
                 return false;
@@ -151,7 +150,7 @@ bool SkDefaultBitmapControllerState::processHQRequest(const SkBitmapProvider& pr
                 return false;
             }
         }
-        if (!SkBitmapScaler::Resize(dst, src.pixmap(), kHQ_RESIZE_METHOD)) {
+        if (!SkBitmapScaler::Resize(dst, src, kHQ_RESIZE_METHOD)) {
             return false; // we failed to create fScaledBitmap
         }
         if (rec) {
@@ -241,8 +240,6 @@ SkDefaultBitmapControllerState::SkDefaultBitmapControllerState(const SkBitmapPro
         SkASSERT(fResultBitmap.getPixels());
     } else {
         (void)provider.asBitmap(&fResultBitmap);
-        fResultBitmap.lockPixels();
-        // lock may fail to give us pixels
     }
     SkASSERT(fCanShadeHQ || fQuality <= kLow_SkFilterQuality);
 
index fd387ac..09f25fb 100644 (file)
@@ -74,7 +74,6 @@ SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap)
     , fRCStack(bitmap.width(), bitmap.height())
 {
     SkASSERT(valid_for_bitmap_device(bitmap.info(), nullptr));
-    fBitmap.lockPixels();
 }
 
 SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& info) {
@@ -89,7 +88,6 @@ SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkSurfaceProps& sur
     , fRCStack(bitmap.width(), bitmap.height())
 {
     SkASSERT(valid_for_bitmap_device(bitmap.info(), nullptr));
-    fBitmap.lockPixels();
 }
 
 SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo,
@@ -134,7 +132,6 @@ void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) {
     SkASSERT(bm.width() == fBitmap.width());
     SkASSERT(bm.height() == fBitmap.height());
     fBitmap = bm;   // intent is to use bm's pixelRef (and rowbytes/config)
-    fBitmap.lockPixels();
     this->privateResize(fBitmap.info().width(), fBitmap.info().height());
 }
 
index b4ade85..c803da7 100644 (file)
@@ -249,7 +249,6 @@ bool SkBitmapScaler::Resize(SkBitmap* resultPtr, const SkPixmap& source, ResizeM
     }
 
     *resultPtr = result;
-    resultPtr->lockPixels();
     SkASSERT(resultPtr->getPixels());
     return true;
 }
index 5e7f2a5..320097b 100644 (file)
@@ -214,8 +214,6 @@ sk_sp<SkSpecialImage> SkBlurImageFilterImpl::onFilterImage(SkSpecialImage* sourc
         return nullptr;
     }
 
-    SkAutoLockPixels inputLock(inputBM), tmpLock(tmp), dstLock(dst);
-
     offset->fX = dstBounds.fLeft;
     offset->fY = dstBounds.fTop;
     SkPMColor* t = tmp.getAddr32(0, 0);
index 1b96f49..844de43 100644 (file)
@@ -841,9 +841,8 @@ bool SkCanvas::readPixels(SkBitmap* bitmap, int x, int y) {
         weAllocated = true;
     }
 
-    SkAutoPixmapUnlock unlocker;
-    if (bitmap->requestLock(&unlocker)) {
-        const SkPixmap& pm = unlocker.pixmap();
+    SkPixmap pm;
+    if (bitmap->peekPixels(&pm)) {
         if (this->readPixels(pm.info(), pm.writable_addr(), pm.rowBytes(), x, y)) {
             return true;
         }
@@ -894,9 +893,8 @@ bool SkCanvas::readPixels(const SkBitmap& bm, int x, int y) {
 }
 
 bool SkCanvas::writePixels(const SkBitmap& bitmap, int x, int y) {
-    SkAutoPixmapUnlock unlocker;
-    if (bitmap.requestLock(&unlocker)) {
-        const SkPixmap& pm = unlocker.pixmap();
+    SkPixmap pm;
+    if (bitmap.peekPixels(&pm)) {
         return this->writePixels(pm.info(), pm.addr(), pm.rowBytes(), x, y);
     }
     return false;
index 07129f6..1e6c900 100644 (file)
@@ -1170,11 +1170,10 @@ void SkDraw::drawBitmapAsMask(const SkBitmap& bitmap, const SkPaint& paint) cons
         int ix = SkScalarRoundToInt(fMatrix->getTranslateX());
         int iy = SkScalarRoundToInt(fMatrix->getTranslateY());
 
-        SkAutoPixmapUnlock result;
-        if (!bitmap.requestLock(&result)) {
+        SkPixmap pmap;
+        if (!bitmap.peekPixels(&pmap)) {
             return;
         }
-        const SkPixmap& pmap = result.pixmap();
         SkMask  mask;
         mask.fBounds.set(ix, iy, ix + pmap.width(), iy + pmap.height());
         mask.fFormat = SkMask::kA8_Format;
@@ -1290,11 +1289,10 @@ void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix,
         // It is safe to call lock pixels now, since we know the matrix is
         // (more or less) identity.
         //
-        SkAutoPixmapUnlock unlocker;
-        if (!bitmap.requestLock(&unlocker)) {
+        SkPixmap pmap;
+        if (!bitmap.peekPixels(&pmap)) {
             return;
         }
-        const SkPixmap& pmap = unlocker.pixmap();
         int ix = SkScalarRoundToInt(matrix.getTranslateX());
         int iy = SkScalarRoundToInt(matrix.getTranslateY());
         if (clipHandlesSprite(*fRC, ix, iy, pmap)) {
@@ -1348,11 +1346,10 @@ void SkDraw::drawSprite(const SkBitmap& bitmap, int x, int y, const SkPaint& ori
     SkPaint paint(origPaint);
     paint.setStyle(SkPaint::kFill_Style);
 
-    SkAutoPixmapUnlock unlocker;
-    if (!bitmap.requestLock(&unlocker)) {
+    SkPixmap pmap;
+    if (!bitmap.peekPixels(&pmap)) {
         return;
     }
-    const SkPixmap& pmap = unlocker.pixmap();
 
     if (nullptr == paint.getColorFilter() && clipHandlesSprite(*fRC, x, y, pmap)) {
         // blitter will be owned by the allocator.
index a31d31f..c755f5d 100644 (file)
@@ -241,7 +241,6 @@ bool SkImageCacherator::tryLockAsBitmap(SkBitmap* bitmap, const SkImage* client,
         }
     } else {
         *bitmap = tmpBitmap;
-        bitmap->lockPixels();
         bitmap->pixelRef()->setImmutableWithID(uniqueID);
     }
     return true;
index d15d2c9..b3766e5 100644 (file)
@@ -779,15 +779,10 @@ bool SkMipMap::extractLevel(const SkSize& scaleSize, Level* levelPtr) const {
 //
 SkMipMap* SkMipMap::Build(const SkBitmap& src, SkDestinationSurfaceColorMode colorMode,
                           SkDiscardableFactoryProc fact) {
-    SkAutoPixmapUnlock srcUnlocker;
-    if (!src.requestLock(&srcUnlocker)) {
+    SkPixmap srcPixmap;
+    if (!src.peekPixels(&srcPixmap)) {
         return nullptr;
     }
-    const SkPixmap& srcPixmap = srcUnlocker.pixmap();
-    // Try to catch where we might have returned nullptr for src crbug.com/492818
-    if (nullptr == srcPixmap.addr()) {
-        sk_throw();
-    }
     return Build(srcPixmap, colorMode, fact);
 }
 
index 37a450d..3bf20fa 100644 (file)
@@ -26,9 +26,6 @@ uint32_t SkNextID::ImageID() {
 
 ///////////////////////////////////////////////////////////////////////////////
 
-// just need a > 0 value, so pick a funny one to aid in debugging
-#define SKPIXELREF_PRELOCKED_LOCKCOUNT     123456789
-
 static SkImageInfo validate_info(const SkImageInfo& info) {
     SkAlphaType newAlphaType = info.alphaType();
     SkAssertResult(SkColorTypeValidateAlphaType(info.colorType(), info.alphaType(), &newAlphaType));
@@ -54,6 +51,8 @@ SkPixelRef::SkPixelRef(const SkImageInfo& info, void* pixels, size_t rowBytes,
                        sk_sp<SkColorTable> ctable)
     : fInfo(validate_info(info))
     , fCTable(std::move(ctable))
+    , fPixels(pixels)
+    , fRowBytes(rowBytes)
 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
     , fStableID(SkNextID::ImageID())
 #endif
@@ -63,13 +62,9 @@ SkPixelRef::SkPixelRef(const SkImageInfo& info, void* pixels, size_t rowBytes,
 #ifdef SK_TRACE_PIXELREF_LIFETIME
     SkDebugf(" pixelref %d\n", sk_atomic_inc(&gInstCounter));
 #endif
-    fRec.fPixels = pixels;
-    fRec.fRowBytes = rowBytes;
-    fRec.fColorTable = fCTable.get();
 
     this->needsNewGenID();
     fMutability = kMutable;
-    fPreLocked = true;
     fAddedToCache.store(false);
 }
 
@@ -116,9 +111,15 @@ void SkPixelRef::cloneGenID(const SkPixelRef& that) {
     SkASSERT(!that. genIDIsUnique());
 }
 
+#ifdef SK_SUPPORT_OBSOLETE_LOCKPIXELS
 bool SkPixelRef::lockPixels(LockRec* rec) {
-    *rec = fRec;
-    return true;
+    if (fPixels) {
+        rec->fPixels = fPixels;
+        rec->fRowBytes = fRowBytes;
+        rec->fColorTable = fCTable.get();
+        return true;
+    }
+    return false;
 }
 
 bool SkPixelRef::requestLock(const LockRequest& request, LockResult* result) {
@@ -133,12 +134,13 @@ bool SkPixelRef::requestLock(const LockRequest& request, LockResult* result) {
 
     result->fUnlockProc = nullptr;
     result->fUnlockContext = nullptr;
-    result->fCTable = fRec.fColorTable;
-    result->fPixels = fRec.fPixels;
-    result->fRowBytes = fRec.fRowBytes;
+    result->fCTable = fCTable.get();
+    result->fPixels = fPixels;
+    result->fRowBytes = fRowBytes;
     result->fSize.set(fInfo.width(), fInfo.height());
     return true;
 }
+#endif
 
 uint32_t SkPixelRef::getGenerationID() const {
     uint32_t id = fTaggedGenID.load();
index 7eac6c4..4d48218 100644 (file)
@@ -20,6 +20,7 @@
 #include "SkSurface.h"
 #include "SkUtils.h"
 
+#ifdef SK_SUPPORT_OBSOLETE_LOCKPIXELS
 void SkAutoPixmapUnlock::reset(const SkPixmap& pm, void (*unlock)(void*), void* ctx) {
     SkASSERT(pm.addr() != nullptr);
 
@@ -29,6 +30,7 @@ void SkAutoPixmapUnlock::reset(const SkPixmap& pm, void (*unlock)(void*), void*
     fUnlockContext = ctx;
     fIsLocked = true;
 }
+#endif
 
 /////////////////////////////////////////////////////////////////////////////////////////////////
 
index 0853432..a142576 100644 (file)
@@ -218,11 +218,6 @@ public:
         , fBitmap(bm)
     {
         SkASSERT(bm.pixelRef());
-
-        // We have to lock now, while bm is still in scope, since it may have come from our
-        // cache, which means we need to keep it locked until we (the special) are done, since
-        // we cannot re-generate the cache entry (if bm came from a generator).
-        fBitmap.lockPixels();
         SkASSERT(fBitmap.getPixels());
     }
 
index 79422ab..3322e8a 100644 (file)
@@ -154,9 +154,9 @@ void SkBinaryWriteBuffer::writeBitmap(const SkBitmap& bitmap) {
     this->writeBool(false);
 
     // see if the caller wants to manually encode
-    SkAutoPixmapUnlock result;
-    if (fPixelSerializer && bitmap.requestLock(&result)) {
-        sk_sp<SkData> data(fPixelSerializer->encode(result.pixmap()));
+    SkPixmap result;
+    if (fPixelSerializer && bitmap.peekPixels(&result)) {
+        sk_sp<SkData> data(fPixelSerializer->encode(result));
         if (data) {
             // if we have to "encode" the bitmap, then we assume there is no
             // offset to share, since we are effectively creating a new pixelref
index 35328d5..b725257 100644 (file)
@@ -198,8 +198,6 @@ sk_sp<SkSpecialImage> SkAlphaThresholdFilterImpl::onFilterImage(SkSpecialImage*
         return nullptr;
     }
 
-    SkAutoLockPixels inputLock(inputBM);
-
     if (!inputBM.getPixels() || inputBM.width() <= 0 || inputBM.height() <= 0) {
         return nullptr;
     }
@@ -218,8 +216,6 @@ sk_sp<SkSpecialImage> SkAlphaThresholdFilterImpl::onFilterImage(SkSpecialImage*
         return nullptr;
     }
 
-    SkAutoLockPixels dstLock(dst);
-
     U8CPU innerThreshold = (U8CPU)(fInnerThreshold * 0xFF);
     U8CPU outerThreshold = (U8CPU)(fOuterThreshold * 0xFF);
     SkColor* dptr = dst.getAddr32(0, 0);
index cf85cfa..a80ce19 100644 (file)
@@ -431,7 +431,6 @@ void ArithmeticImageFilterImpl::drawForeground(SkCanvas* canvas, SkSpecialImage*
         if (!img->getROPixels(&srcBM)) {
             return;
         }
-        srcBM.lockPixels();
         if (!srcBM.peekPixels(&src)) {
             return;
         }
index 06f16f0..2c0d5f0 100644 (file)
@@ -388,7 +388,6 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffect::onFilterImage(SkSpecialImage* sou
         return nullptr;
     }
 
-    SkAutoLockPixels colorLock(colorBM), displLock(displBM);
     if (!colorBM.getPixels() || !displBM.getPixels()) {
         return nullptr;
     }
@@ -401,8 +400,6 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffect::onFilterImage(SkSpecialImage* sou
         return nullptr;
     }
 
-    SkAutoLockPixels dstLock(dst);
-
     computeDisplacement(fXChannelSelector, fYChannelSelector, scale, &dst,
                         displBM, colorOffset - displOffset, colorBM, colorBounds);
 
index 58c45ff..5933cff 100644 (file)
@@ -1278,7 +1278,6 @@ sk_sp<SkSpecialImage> SkDiffuseLightingImageFilter::onFilterImage(SkSpecialImage
         return nullptr;
     }
 
-    SkAutoLockPixels alp(inputBM);
     if (!inputBM.getPixels()) {
         return nullptr;
     }
@@ -1290,8 +1289,6 @@ sk_sp<SkSpecialImage> SkDiffuseLightingImageFilter::onFilterImage(SkSpecialImage
         return nullptr;
     }
 
-    SkAutoLockPixels dstLock(dst);
-
     SkMatrix matrix(ctx.ctm());
     matrix.postTranslate(SkIntToScalar(-inputOffset.x()), SkIntToScalar(-inputOffset.y()));
 
@@ -1445,7 +1442,6 @@ sk_sp<SkSpecialImage> SkSpecularLightingImageFilter::onFilterImage(SkSpecialImag
         return nullptr;
     }
 
-    SkAutoLockPixels alp(inputBM);
     if (!inputBM.getPixels()) {
         return nullptr;
     }
@@ -1457,8 +1453,6 @@ sk_sp<SkSpecialImage> SkSpecularLightingImageFilter::onFilterImage(SkSpecialImag
         return nullptr;
     }
 
-    SkAutoLockPixels dstLock(dst);
-
     SpecularLightingType lightingType(fKS, fShininess);
 
     SkMatrix matrix(ctx.ctm());
index 9be3438..8552c81 100644 (file)
@@ -389,7 +389,6 @@ sk_sp<SkSpecialImage> SkMagnifierImageFilter::onFilterImage(SkSpecialImage* sour
         return nullptr;
     }
 
-    SkAutoLockPixels alp(inputBM);
     SkASSERT(inputBM.getPixels());
     if (!inputBM.getPixels() || inputBM.width() <= 0 || inputBM.height() <= 0) {
         return nullptr;
@@ -402,8 +401,6 @@ sk_sp<SkSpecialImage> SkMagnifierImageFilter::onFilterImage(SkSpecialImage* sour
         return nullptr;
     }
 
-    SkAutoLockPixels dstLock(dst);
-
     SkColor* dptr = dst.getAddr32(0, 0);
     int dstWidth = dst.width(), dstHeight = dst.height();
     for (int y = 0; y < dstHeight; ++y) {
index 092cb66..6644ef8 100644 (file)
@@ -244,9 +244,7 @@ void SkMatrixConvolutionImageFilter::filterBorderPixels(const SkBitmap& src,
 // FIXME:  This should be refactored to SkImageFilterUtils for
 // use by other filters.  For now, we assume the input is always
 // premultiplied and unpremultiply it
-static SkBitmap unpremultiply_bitmap(const SkBitmap& src)
-{
-    SkAutoLockPixels alp(src);
+static SkBitmap unpremultiply_bitmap(const SkBitmap& src) {
     if (!src.getPixels()) {
         return SkBitmap();
     }
@@ -256,7 +254,6 @@ static SkBitmap unpremultiply_bitmap(const SkBitmap& src)
     if (!result.tryAllocPixels(info)) {
         return SkBitmap();
     }
-    SkAutoLockPixels resultLock(result);
     for (int y = 0; y < src.height(); ++y) {
         const uint32_t* srcRow = src.getAddr32(0, y);
         uint32_t* dstRow = result.getAddr32(0, y);
@@ -350,7 +347,6 @@ sk_sp<SkSpecialImage> SkMatrixConvolutionImageFilter::onFilterImage(SkSpecialIma
         inputBM = unpremultiply_bitmap(inputBM);
     }
 
-    SkAutoLockPixels alp(inputBM);
     if (!inputBM.getPixels()) {
         return nullptr;
     }
@@ -363,8 +359,6 @@ sk_sp<SkSpecialImage> SkMatrixConvolutionImageFilter::onFilterImage(SkSpecialIma
         return nullptr;
     }
 
-    SkAutoLockPixels dstLock(dst);
-
     offset->fX = bounds.fLeft;
     offset->fY = bounds.fTop;
     bounds.offset(-inputOffset);
index d7454a4..d11b4da 100644 (file)
@@ -621,8 +621,6 @@ sk_sp<SkSpecialImage> SkMorphologyImageFilter::onFilterImage(SkSpecialImage* sou
         return nullptr;
     }
 
-    SkAutoLockPixels inputLock(inputBM), dstLock(dst);
-
     SkMorphologyImageFilter::Proc procX, procY;
 
     if (kDilate_Op == this->op()) {
@@ -639,8 +637,6 @@ sk_sp<SkSpecialImage> SkMorphologyImageFilter::onFilterImage(SkSpecialImage* sou
             return nullptr;
         }
 
-        SkAutoLockPixels tmpLock(tmp);
-
         call_proc_X(procX, inputBM, &tmp, width, srcBounds);
         SkIRect tmpBounds = SkIRect::MakeWH(srcBounds.width(), srcBounds.height());
         call_proc_Y(procY,
index 0667f51..0253e60 100644 (file)
@@ -321,7 +321,6 @@ sk_sp<SkColorFilter> SkTable_ColorFilter::makeComposed(sk_sp<SkColorFilter> inne
         return nullptr;
     }
 
-    innerBM.lockPixels();
     if (nullptr == innerBM.getPixels()) {
         return nullptr;
     }
index 730cfbf..276eaac 100644 (file)
@@ -607,7 +607,6 @@ void SkGradientShaderBase::GradientShaderCache::initCache32(GradientShaderCache*
 void SkGradientShaderBase::initLinearBitmap(SkBitmap* bitmap) const {
     const bool interpInPremul = SkToBool(fGradFlags &
                                          SkGradientShader::kInterpolateColorsInPremul_Flag);
-    bitmap->lockPixels();
     SkHalf* pixelsF16 = reinterpret_cast<SkHalf*>(bitmap->getPixels());
     uint32_t* pixelsS32 = reinterpret_cast<uint32_t*>(bitmap->getPixels());
 
@@ -657,7 +656,6 @@ void SkGradientShaderBase::initLinearBitmap(SkBitmap* bitmap) const {
         prevIndex = nextIndex;
     }
     SkASSERT(prevIndex == kCache32Count - 1);
-    bitmap->unlockPixels();
 }
 
 /*
index 11ed637..7046f1c 100644 (file)
@@ -957,12 +957,6 @@ void SkGpuDevice::drawTiledBitmap(const SkBitmap& bitmap,
     SK_HISTOGRAM_BOOLEAN("DrawTiled", true);
     LogDrawScaleFactor(viewMatrix, origPaint.getFilterQuality());
 
-    // The following pixel lock is technically redundant, but it is desirable
-    // to lock outside of the tile loop to prevent redecoding the whole image
-    // at each tile in cases where 'bitmap' holds an SkDiscardablePixelRef that
-    // is larger than the limit of the discardable memory pool.
-    SkAutoLockPixels alp(bitmap);
-
     const SkPaint* paint = &origPaint;
     SkPaint tempPaint;
     if (origPaint.isAntiAlias() && !fRenderTargetContext->isUnifiedMultisampled()) {
index 84be09e..e4b3155 100644 (file)
@@ -93,7 +93,6 @@ GrPixelConfig GrIsCompressedTextureDataSupported(GrContext* ctx, SkData* data,
 //////////////////////////////////////////////////////////////////////////////
 sk_sp<GrTextureProxy> GrUploadBitmapToTextureProxy(GrResourceProvider* resourceProvider,
                                                    const SkBitmap& bitmap) {
-    SkAutoLockPixels alp(bitmap);
     if (!bitmap.readyToDraw()) {
         return nullptr;
     }
@@ -212,15 +211,10 @@ sk_sp<GrTextureProxy> GrGenerateMipMapsAndUploadToTextureProxy(GrContext* ctx,
 
     GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap.info(), *ctx->caps());
 
-    SkAutoPixmapUnlock srcUnlocker;
-    if (!bitmap.requestLock(&srcUnlocker)) {
+    SkPixmap pixmap;
+    if (!bitmap.peekPixels(&pixmap)) {
         return nullptr;
     }
-    const SkPixmap& pixmap = srcUnlocker.pixmap();
-    // Try to catch where we might have returned nullptr for src crbug.com/492818
-    if (nullptr == pixmap.addr()) {
-        sk_throw();
-    }
 
     std::unique_ptr<SkMipMap> mipmaps(SkMipMap::Build(pixmap, colorMode, nullptr));
     if (!mipmaps) {
index 26ef596..72817b2 100644 (file)
@@ -153,8 +153,6 @@ int GrTextureStripAtlas::lockRow(const SkBitmap& bitmap) {
         fKeyTable.insert(index, 1, &row);
         rowNumber = static_cast<int>(row - fRows);
 
-        SkAutoLockPixels lock(bitmap);
-
         SkASSERT(bitmap.width() == fDesc.fWidth);
         SkASSERT(bitmap.height() == fDesc.fRowHeight);
 
index 0847eb1..bbe1754 100644 (file)
@@ -67,7 +67,6 @@ bool SkImage::scalePixels(const SkPixmap& dst, SkFilterQuality quality, CachingH
     //
     SkBitmap bm;
     if (as_IB(this)->getROPixels(&bm, dst.info().colorSpace(), chint)) {
-        bm.lockPixels();
         SkPixmap pmap;
         // Note: By calling the pixmap scaler, we never cache the final result, so the chint
         //       is (currently) only being applied to the getROPixels. If we get a request to
@@ -115,15 +114,14 @@ SkData* SkImage::encode(SkPixelSerializer* serializer) const {
     }
 
     SkBitmap bm;
-    SkAutoPixmapUnlock apu;
+    SkPixmap pmap;
     SkColorSpace* legacyColorSpace = nullptr;
-    if (as_IB(this)->getROPixels(&bm, legacyColorSpace) &&
-        bm.requestLock(&apu)) {
+    if (as_IB(this)->getROPixels(&bm, legacyColorSpace) && bm.peekPixels(&pmap)) {
         if (serializer) {
-            return serializer->encode(apu.pixmap());
+            return serializer->encode(pmap);
         } else {
             SkDynamicMemoryWStream buf;
-            return SkEncodeImage(&buf, apu.pixmap(), SkEncodedImageFormat::kPNG, 100)
+            return SkEncodeImage(&buf, pmap, SkEncodedImageFormat::kPNG, 100)
                    ? buf.detachAsData().release() : nullptr;
         }
     }
index 1aca5a9..91de4c5 100644 (file)
@@ -109,11 +109,6 @@ public:
                                       : (uint32_t)kNeedNewImageUniqueID)
         , fBitmap(bm)
     {
-        if (bm.pixelRef()->isPreLocked()) {
-            // we only preemptively lock if there is no chance of triggering something expensive
-            // like a lazy decode or imagegenerator. PreLocked means it is flat pixels already.
-            fBitmap.lockPixels();
-        }
         SkASSERT(bitmapMayBeMutable || fBitmap.isImmutable());
     }
 
@@ -152,7 +147,6 @@ SkImage_Raster::SkImage_Raster(const Info& info, sk_sp<SkData> data, size_t rowB
 
     fBitmap.installPixels(info, addr, rowBytes, ctable, release_data, data.release());
     fBitmap.setImmutable();
-    fBitmap.lockPixels();
 }
 
 SkImage_Raster::~SkImage_Raster() {
@@ -307,7 +301,6 @@ sk_sp<SkImage> SkImage::MakeFromRaster(const SkPixmap& pmap, RasterReleaseProc p
 sk_sp<SkImage> SkMakeImageFromRasterBitmap(const SkBitmap& bm, SkCopyPixelsMode cpm) {
     bool hasColorTable = false;
     if (kIndex_8_SkColorType == bm.colorType()) {
-        SkAutoLockPixels autoLockPixels(bm);
         hasColorTable = bm.getColorTable() != nullptr;
     }
 
@@ -316,10 +309,8 @@ sk_sp<SkImage> SkMakeImageFromRasterBitmap(const SkBitmap& bm, SkCopyPixelsMode
     }
 
     if (kAlways_SkCopyPixelsMode == cpm || (!bm.isImmutable() && kNever_SkCopyPixelsMode != cpm)) {
-        SkBitmap tmp(bm);
-        tmp.lockPixels();
         SkPixmap pmap;
-        if (tmp.getPixels() && tmp.peekPixels(&pmap)) {
+        if (bm.getPixels() && bm.peekPixels(&pmap)) {
             return SkImage::MakeRasterCopy(pmap);
         }
     } else {
@@ -405,7 +396,6 @@ sk_sp<SkImage> SkImage_Raster::onMakeColorSpace(sk_sp<SkColorSpace> target) cons
     SkTLazy<SkBitmap> tmp;
     if (!fBitmap.peekPixels(&src)) {
         tmp.init(fBitmap);
-        tmp.get()->lockPixels();
         SkAssertResult(tmp.get()->peekPixels(&src));
     }
 
index 92f5301..2de1ed7 100644 (file)
@@ -165,7 +165,6 @@ void SkSurface_Raster::onCopyOnWrite(ContentChangeMode mode) {
         } else {
             SkBitmap prev(fBitmap);
             fBitmap.allocPixels();
-            prev.lockPixels();
             SkASSERT(prev.info() == fBitmap.info());
             SkASSERT(prev.rowBytes() == fBitmap.rowBytes());
             memcpy(fBitmap.getPixels(), prev.getPixels(), fBitmap.getSafeSize());
index 511fca8..19460a4 100644 (file)
@@ -23,8 +23,6 @@ void image_get_ro_pixels(const SkImage* image, SkBitmap* dst) {
         if (dst->colorType() != kIndex_8_SkColorType) {
             return;
         }
-        // We must check to see if the bitmap has a color table.
-        SkAutoLockPixels autoLockPixels(*dst);
         if (!dst->getColorTable()) {
             // We can't use an indexed bitmap with no colortable.
             dst->reset();
@@ -181,7 +179,6 @@ static void bitmap_to_pdf_pixels(const SkBitmap& bitmap, SkWStream* out) {
     }
     SkBitmap copy;
     const SkBitmap& bm = not4444(bitmap, &copy);
-    SkAutoLockPixels autoLockPixels(bm);
     SkColorType colorType = bm.colorType();
     SkAlphaType alphaType = bm.alphaType();
     switch (colorType) {
@@ -257,7 +254,6 @@ static void bitmap_alpha_to_a8(const SkBitmap& bitmap, SkWStream* out) {
     }
     SkBitmap copy;
     const SkBitmap& bm = not4444(bitmap, &copy);
-    SkAutoLockPixels autoLockPixels(bm);
     SkColorType colorType = bm.colorType();
     switch (colorType) {
         case kRGBA_8888_SkColorType:
@@ -350,7 +346,6 @@ static void emit_image_xobject(SkWStream* stream,
                                const SkPDFObjNumMap& objNumMap) {
     SkBitmap bitmap;
     image_get_ro_pixels(image, &bitmap);      // TODO(halcanary): test
-    SkAutoLockPixels autoLockPixels(bitmap);  // with malformed images.
 
     // Write to a temporary buffer to get the compressed length.
     SkDynamicMemoryWStream buffer;
@@ -502,11 +497,10 @@ sk_sp<SkPDFObject> SkPDFCreateBitmapObject(sk_sp<SkImage> image,
 
     if (pixelSerializer) {
         SkBitmap bm;
-        SkAutoPixmapUnlock apu;
+        SkPixmap pmap;
         SkColorSpace* legacyColorSpace = nullptr;
-        if (as_IB(image.get())->getROPixels(&bm, legacyColorSpace) &&
-            bm.requestLock(&apu)) {
-            data.reset(pixelSerializer->encode(apu.pixmap()));
+        if (as_IB(image.get())->getROPixels(&bm, legacyColorSpace) && bm.peekPixels(&pmap)) {
+            data.reset(pixelSerializer->encode(pmap));
             if (data && SkIsJFIF(data.get(), &info)) {
                 bool yuv = info.fType == SkJFIFInfo::kYCbCr;
                 if (info.fSize == image->dimensions()) {  // Sanity check.
index 992508d..358ba16 100644 (file)
@@ -104,12 +104,10 @@ static SkPaint calculate_text_paint(const SkPaint& paint) {
 static SkImageSubset make_image_subset(const SkBitmap& bitmap) {
     SkASSERT(!bitmap.drawsNothing());
     SkIRect subset = bitmap.getSubset();
-    SkAutoLockPixels autoLockPixels(bitmap);
     SkASSERT(bitmap.pixelRef());
     SkBitmap tmp;
     tmp.setInfo(bitmap.pixelRef()->info(), bitmap.rowBytes());
     tmp.setPixelRef(sk_ref_sp(bitmap.pixelRef()), 0, 0);
-    tmp.lockPixels();
     auto img = SkImage::MakeFromBitmap(tmp);
     if (img) {
         SkASSERT(!bitmap.isImmutable() || img->uniqueID() == bitmap.getGenerationID());
index 6a51185..13a9ecd 100644 (file)
@@ -962,7 +962,6 @@ static sk_sp<SkPDFStream> make_image_shader(SkPDFDocument* doc,
                                             SkBitmap image) {
     SkASSERT(state.fBitmapKey ==
              (SkBitmapKey{image.getSubset(), image.getGenerationID()}));
-    SkAutoLockPixels SkAutoLockPixels(image);
 
     // The image shader pattern cell will be drawn into a separate device
     // in pattern cell space (no scaling on the bitmap, though there may be
index e373592..880c566 100644 (file)
@@ -134,9 +134,6 @@ CGImageRef SkCreateCGImageRefWithColorspace(const SkBitmap& bm,
     const size_t s = bitmap->getSize();
 
     // our provider "owns" the bitmap*, and will take care of deleting it
-    // we initially lock it, so we can access the pixels. The bitmap will be deleted in the release
-    // proc, which will in turn unlock the pixels
-    bitmap->lockPixels();
     CGDataProviderRef dataRef = CGDataProviderCreateWithData(bitmap, bitmap->getPixels(), s,
                                                              SkBitmap_ReleaseInfo);
 
index 983b253..8be15d1 100644 (file)
@@ -207,7 +207,6 @@ void SkOSWindow::doPaint(void* ctx) {
         //       seems to be to copy the bitmap to a temporary (contiguous)
         //       buffer before passing to SetDIBitsToDevice().
         SkASSERT(bitmap.width() * bitmap.bytesPerPixel() == bitmap.rowBytes());
-        bitmap.lockPixels();
         int ret = SetDIBitsToDevice(hdc,
             0, 0,
             bitmap.width(), bitmap.height(),
@@ -217,7 +216,6 @@ void SkOSWindow::doPaint(void* ctx) {
             &bmi,
             DIB_RGB_COLORS);
         (void)ret; // we're ignoring potential failures for now.
-        bitmap.unlockPixels();
     }
 }
 
index 4a018a9..2022590 100644 (file)
@@ -749,8 +749,6 @@ HRESULT SkXPSDevice::createXpsImageBrush(
         if (SkShader::kClamp_TileMode == xy[0] &&
             SkShader::kClamp_TileMode == xy[1]) {
 
-            SkAutoLockPixels alp(bitmap);
-
             const SkColor tlColor = bitmap.getColor(0,0);
             const SkRect tlArea = SkRect::MakeLTRB(-BIG, -BIG, 0, 0);
             HR(this->cornerOfClamp(tlArea, tlColor, brushVisuals.get()));
index d2fda9e..aadf192 100644 (file)
@@ -11,7 +11,6 @@
 #include "Test.h"
 
 static void init_src(const SkBitmap& bitmap) {
-    SkAutoLockPixels lock(bitmap);
     if (bitmap.getPixels()) {
         if (bitmap.getColorTable()) {
             sk_bzero(bitmap.getPixels(), bitmap.getSize());
@@ -130,8 +129,6 @@ DEF_TEST(BitmapCopy_extractSubset, reporter) {
                 REPORTER_ASSERT(reporter, copy.height() == 2);
 
                 if (gPairs[i].fColorType == gPairs[j].fColorType) {
-                    SkAutoLockPixels alp0(subset);
-                    SkAutoLockPixels alp1(copy);
                     // they should both have, or both not-have, a colortable
                     bool hasCT = subset.getColorTable() != nullptr;
                     REPORTER_ASSERT(reporter, (copy.getColorTable() != nullptr) == hasCT);
index 76621e6..0d4b785 100644 (file)
@@ -141,8 +141,6 @@ DEF_TEST(Bitmap_getColor_Swizzle, r) {
             ERRORF(r, "SkBitmap::copy failed %d", (int)ct);
             continue;
         }
-        SkAutoLockPixels autoLockPixels1(copy);
-        SkAutoLockPixels autoLockPixels2(source);
         REPORTER_ASSERT(r, source.getColor(0, 0) == copy.getColor(0, 0));
     }
 }
index 8f688e2..0acbd07 100644 (file)
@@ -187,7 +187,6 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ES2BlendWithNoTexture, reporter, ctxInfo)
         SkBitmap bitmap;
         REPORTER_ASSERT(reporter, bitmap.tryAllocPixels(SkImageInfo::Make(
                                           kWidth, kHeight, kColorType, kPremul_SkAlphaType)));
-        bitmap.lockPixels();
         REPORTER_ASSERT(
                 reporter,
                 surface->readPixels(bitmap.info(), bitmap.getPixels(), bitmap.rowBytes(), 0, 0));
@@ -199,7 +198,6 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ES2BlendWithNoTexture, reporter, ctxInfo)
                                           SkColorSetRGB(0x80, 0xFF, 0x80));
 
         // Clean up - surface depends on backingSurface and must be released first.
-        bitmap.unlockPixels();
         surface.reset();
         backingSurface.reset();
     }
index 985917f..5d95718 100644 (file)
@@ -76,9 +76,6 @@ static bool compare(const SkBitmap& ref, const SkIRect& iref,
     const int xOff = itest.fLeft - iref.fLeft;
     const int yOff = itest.fTop - iref.fTop;
 
-    SkAutoLockPixels alpRef(ref);
-    SkAutoLockPixels alpTest(test);
-
     for (int y = 0; y < test.height(); ++y) {
         for (int x = 0; x < test.width(); ++x) {
             SkColor testColor = test.getColor(x, y);
@@ -244,7 +241,6 @@ static void readback(SkCanvas* canvas, int* result, int resultCount) {
     readback.allocN32Pixels(resultCount, 30);
     canvas->readPixels(readback, 0, 0);
 
-    readback.lockPixels();
     SkPMColor* pixels = (SkPMColor*) readback.getAddr32(0, 15);
 
     for (int i = 0; i < resultCount; ++i) {
index f5eea37..20cd1d1 100644 (file)
@@ -277,10 +277,6 @@ DEF_TEST(Codec_partialAnim, r) {
         frameInfo = partialCodec->getFrameInfo();
         REPORTER_ASSERT(r, frameInfo.size() == i + 1);
         REPORTER_ASSERT(r, frameInfo[i].fFullyReceived);
-
-        // allocPixels locked the pixels for frame, but frames[i] was copied
-        // from another bitmap, and did not retain the locked status.
-        SkAutoLockPixels alp(frames[i]);
         compare_bitmaps(r, frames[i], frame);
     }
 }
index 2c601fa..ceafa15 100644 (file)
@@ -38,7 +38,6 @@
 #endif
 
 static void md5(const SkBitmap& bm, SkMD5::Digest* digest) {
-    SkAutoLockPixels autoLockPixels(bm);
     SkASSERT(bm.getPixels());
     SkMD5 md5;
     size_t rowLen = bm.info().bytesPerPixel() * bm.width();
@@ -72,7 +71,6 @@ static void test_info(skiatest::Reporter* r, Codec* codec, const SkImageInfo& in
                       SkCodec::Result expectedResult, const SkMD5::Digest* goodDigest) {
     SkBitmap bm;
     bm.allocPixels(info);
-    SkAutoLockPixels autoLockPixels(bm);
 
     SkCodec::Result result = codec->getPixels(info, bm.getPixels(), bm.rowBytes());
     REPORTER_ASSERT(r, result == expectedResult);
@@ -98,7 +96,6 @@ static void test_incremental_decode(skiatest::Reporter* r, SkCodec* codec, const
         const SkMD5::Digest& goodDigest) {
     SkBitmap bm;
     bm.allocPixels(info);
-    SkAutoLockPixels autoLockPixels(bm);
 
     REPORTER_ASSERT(r, SkCodec::kSuccess == codec->startIncrementalDecode(info, bm.getPixels(),
                                                                           bm.rowBytes()));
@@ -157,7 +154,6 @@ static void test_codec(skiatest::Reporter* r, Codec* codec, SkBitmap& bm, const
 
     REPORTER_ASSERT(r, info.dimensions() == size);
     bm.allocPixels(info);
-    SkAutoLockPixels autoLockPixels(bm);
 
     SkCodec::Result result = codec->getPixels(info, bm.getPixels(), bm.rowBytes());
     REPORTER_ASSERT(r, result == expectedResult);
@@ -174,7 +170,6 @@ static void test_codec(skiatest::Reporter* r, Codec* codec, SkBitmap& bm, const
             // Decoding to 565 should succeed.
             SkBitmap bm565;
             bm565.allocPixels(info565);
-            SkAutoLockPixels alp(bm565);
 
             // This will allow comparison even if the image is incomplete.
             bm565.eraseColor(SK_ColorBLACK);
@@ -199,7 +194,6 @@ static void test_codec(skiatest::Reporter* r, Codec* codec, SkBitmap& bm, const
         SkImageInfo grayInfo = codec->getInfo();
         SkBitmap grayBm;
         grayBm.allocPixels(grayInfo);
-        SkAutoLockPixels alp(grayBm);
 
         grayBm.eraseColor(SK_ColorBLACK);
 
@@ -442,7 +436,6 @@ static void check(skiatest::Reporter* r,
                 SkCodecImageGenerator::MakeFromEncodedCodec(fullData));
         SkBitmap bm;
         bm.allocPixels(info);
-        SkAutoLockPixels autoLockPixels(bm);
         REPORTER_ASSERT(r, gen->getPixels(info, bm.getPixels(), bm.rowBytes()));
         compare_to_good_digest(r, codecDigest, bm);
 
index df410b2..9912901 100644 (file)
@@ -226,8 +226,6 @@ static void test_nan_antihair() {
 }
 
 static bool check_for_all_zeros(const SkBitmap& bm) {
-    SkAutoLockPixels alp(bm);
-
     size_t count = bm.width() * bm.bytesPerPixel();
     for (int y = 0; y < bm.height(); y++) {
         const uint8_t* ptr = reinterpret_cast<const uint8_t*>(bm.getAddr(0, y));
index bf9bd39..a98b36f 100644 (file)
@@ -37,9 +37,6 @@ static bool compare(const SkBitmap& ref, const SkIRect& iref,
     const int xOff = itest.fLeft - iref.fLeft;
     const int yOff = itest.fTop - iref.fTop;
 
-    SkAutoLockPixels alpRef(ref);
-    SkAutoLockPixels alpTest(test);
-
     for (int y = 0; y < test.height(); ++y) {
         for (int x = 0; x < test.width(); ++x) {
             SkColor testColor = test.getColor(x, y);
index 7c4cb67..2bb439b 100644 (file)
@@ -39,9 +39,6 @@ static bool compare(const SkBitmap& ref, const SkIRect& iref,
     const int xOff = itest.fLeft - iref.fLeft;
     const int yOff = itest.fTop - iref.fTop;
 
-    SkAutoLockPixels alpRef(ref);
-    SkAutoLockPixels alpTest(test);
-
     for (int y = 0; y < test.height(); ++y) {
         for (int x = 0; x < test.width(); ++x) {
             SkColor testColor = test.getColor(x, y);
index e46bfb4..ec2753d 100644 (file)
@@ -149,7 +149,6 @@ static void TestConstantGradient(skiatest::Reporter*) {
     outBitmap.allocN32Pixels(10, 1);
     SkCanvas canvas(outBitmap);
     canvas.drawPaint(paint);
-    SkAutoLockPixels alp(outBitmap);
     for (int i = 0; i < 10; i++) {
         // The following is commented out because it currently fails
         // Related bug: https://code.google.com/p/skia/issues/detail?id=1098
index 35b0c9f..26f1a7c 100644 (file)
@@ -33,8 +33,6 @@ DEF_TEST(HighContrastFilter_FilterImage, reporter) {
     paint.setColorFilter(SkHighContrastFilter::Make(config));
     canvasFilter.drawRect(r, paint);
 
-    paintResult.lockPixels();
-    filterResult.lockPixels();
     for (int y = r.top(); y < r.bottom(); ++y) {
         for (int x = r.left(); x < r.right(); ++x) {
             SkColor paintColor = paintResult.getColor(x, y);
@@ -44,8 +42,6 @@ DEF_TEST(HighContrastFilter_FilterImage, reporter) {
                 paint.getColorFilter()->filterColor(paintColor));
         }
     }
-    paintResult.unlockPixels();
-    filterResult.unlockPixels();
 }
 
 DEF_TEST(HighContrastFilter_SanityCheck, reporter) {
index 79f34f7..5d959d1 100644 (file)
@@ -594,10 +594,6 @@ static void test_negative_blur_sigma(skiatest::Reporter* reporter,
     REPORTER_ASSERT(reporter, negativeResult1->getROPixels(&negativeResultBM1));
     REPORTER_ASSERT(reporter, negativeResult2->getROPixels(&negativeResultBM2));
 
-    SkAutoLockPixels lockP1(positiveResultBM1);
-    SkAutoLockPixels lockP2(positiveResultBM2);
-    SkAutoLockPixels lockN1(negativeResultBM1);
-    SkAutoLockPixels lockN2(negativeResultBM2);
     for (int y = 0; y < height; y++) {
         int diffs = memcmp(positiveResultBM1.getAddr32(0, y),
                            negativeResultBM1.getAddr32(0, y),
@@ -656,7 +652,6 @@ static void test_zero_blur_sigma(skiatest::Reporter* reporter, GrContext* contex
 
     REPORTER_ASSERT(reporter, result->getROPixels(&resultBM));
 
-    SkAutoLockPixels lock(resultBM);
     for (int y = 0; y < resultBM.height(); y++) {
         for (int x = 0; x < resultBM.width(); x++) {
             bool diff = *resultBM.getAddr32(x, y) != SK_ColorGREEN;
@@ -696,7 +691,6 @@ static void test_fail_affects_transparent_black(skiatest::Reporter* reporter, Gr
     if (result.get()) {
         SkBitmap resultBM;
         REPORTER_ASSERT(reporter, result->getROPixels(&resultBM));
-        SkAutoLockPixels lock(resultBM);
         REPORTER_ASSERT(reporter, *resultBM.getAddr32(0, 0) == SK_ColorGREEN);
     }
 }
@@ -1573,7 +1567,6 @@ static void test_composed_imagefilter_bounds(skiatest::Reporter* reporter, GrCon
 
     SkBitmap resultBM;
     REPORTER_ASSERT(reporter, result->getROPixels(&resultBM));
-    SkAutoLockPixels lock(resultBM);
     REPORTER_ASSERT(reporter, resultBM.getColor(50, 50) == SK_ColorGREEN);
 }
 
index fada9f0..53f65df 100644 (file)
@@ -14,7 +14,6 @@ DEF_TEST(ImageFrom565Bitmap, r) {
     SkBitmap bm;
     bm.allocPixels(SkImageInfo::Make(
         5, 7, kRGB_565_SkColorType, kOpaque_SkAlphaType));
-    SkAutoLockPixels autoLockPixels(bm);
     bm.eraseColor(SK_ColorBLACK);
     REPORTER_ASSERT(r, SkImage::MakeFromBitmap(bm) != nullptr);
 }
index 37e1e30..fe01f04 100644 (file)
@@ -17,9 +17,6 @@
 #endif
 
 static void test_bitmap_equality(skiatest::Reporter* reporter, SkBitmap& bm1, SkBitmap& bm2) {
-    SkAutoLockPixels lockBm1(bm1);
-    SkAutoLockPixels lockBm2(bm2);
-
     REPORTER_ASSERT(reporter, bm1.getSize() == bm2.getSize());
     REPORTER_ASSERT(reporter, 0 == memcmp(bm1.getPixels(), bm2.getPixels(), bm1.getSize()));
 }
@@ -90,7 +87,6 @@ static void run_shader_test(skiatest::Reporter* reporter, SkSurface* sourceSurfa
 
     //  Test correctness
     {
-        SkAutoLockPixels lockBm(bmt);
         for (int y = 0; y < info.height(); y++) {
             REPORTER_ASSERT(reporter, 0xFFFF0000 == bmt.getColor(0, y));
 
index 22004a0..77017f3 100644 (file)
@@ -691,7 +691,6 @@ static void check_legacy_bitmap(skiatest::Reporter* reporter, const SkImage* ima
         REPORTER_ASSERT(reporter, bitmap.isImmutable());
     }
 
-    SkAutoLockPixels alp(bitmap);
     REPORTER_ASSERT(reporter, bitmap.getPixels());
 
     const SkImageInfo info = SkImageInfo::MakeN32(1, 1, bitmap.alphaType());
@@ -1065,7 +1064,6 @@ DEF_TEST(Image_makeColorSpace, r) {
     SkBitmap p3Bitmap;
     bool success = p3Image->asLegacyBitmap(&p3Bitmap, SkImage::kRO_LegacyBitmapMode);
     REPORTER_ASSERT(r, success);
-    p3Bitmap.lockPixels();
     REPORTER_ASSERT(r, almost_equal(0x28, SkGetPackedR32(*p3Bitmap.getAddr32(0, 0))));
     REPORTER_ASSERT(r, almost_equal(0x40, SkGetPackedG32(*p3Bitmap.getAddr32(0, 0))));
     REPORTER_ASSERT(r, almost_equal(0x5E, SkGetPackedB32(*p3Bitmap.getAddr32(0, 0))));
@@ -1075,7 +1073,6 @@ DEF_TEST(Image_makeColorSpace, r) {
     SkBitmap adobeBitmap;
     success = adobeImage->asLegacyBitmap(&adobeBitmap, SkImage::kRO_LegacyBitmapMode);
     REPORTER_ASSERT(r, success);
-    adobeBitmap.lockPixels();
     REPORTER_ASSERT(r, almost_equal(0x21, SkGetPackedR32(*adobeBitmap.getAddr32(0, 0))));
     REPORTER_ASSERT(r, almost_equal(0x31, SkGetPackedG32(*adobeBitmap.getAddr32(0, 0))));
     REPORTER_ASSERT(r, almost_equal(0x4C, SkGetPackedB32(*adobeBitmap.getAddr32(0, 0))));
@@ -1084,7 +1081,6 @@ DEF_TEST(Image_makeColorSpace, r) {
     p3Image = srgbImage->makeColorSpace(p3, SkTransferFunctionBehavior::kIgnore);
     success = p3Image->asLegacyBitmap(&p3Bitmap, SkImage::kRO_LegacyBitmapMode);
     REPORTER_ASSERT(r, success);
-    p3Bitmap.lockPixels();
     REPORTER_ASSERT(r, almost_equal(0x8B, SkGetPackedR32(*p3Bitmap.getAddr32(0, 0))));
     REPORTER_ASSERT(r, almost_equal(0x82, SkGetPackedG32(*p3Bitmap.getAddr32(0, 0))));
     REPORTER_ASSERT(r, almost_equal(0x77, SkGetPackedB32(*p3Bitmap.getAddr32(0, 0))));
index 697d3ee..89706ac 100644 (file)
@@ -124,7 +124,6 @@ static void fill_src_canvas(SkCanvas* canvas) {
 }
 
 static void fill_dst_bmp_with_init_data(SkBitmap* bitmap) {
-    SkAutoLockPixels alp(*bitmap);
     int w = bitmap->width();
     int h = bitmap->height();
     intptr_t pixels = reinterpret_cast<intptr_t>(bitmap->getPixels());
@@ -184,7 +183,6 @@ static bool check_read(skiatest::Reporter* reporter,
     if (!clippedSrcRect.intersect(srcRect)) {
         clippedSrcRect.setEmpty();
     }
-    SkAutoLockPixels alp(bitmap);
     if (kAlpha_8_SkColorType == ct) {
         for (int by = 0; by < bh; ++by) {
             for (int bx = 0; bx < bw; ++bx) {
@@ -440,11 +438,9 @@ static void test_readpixels_texture(skiatest::Reporter* reporter,
                     if (gReadPixelsConfigs[c].fAlphaType == kUnpremul_SkAlphaType) {
                         flags = GrContextPriv::kUnpremul_PixelOpsFlag;
                     }
-                    bmp.lockPixels();
                     bool success = sContext->readPixels(bmp.info(), bmp.getPixels(),
                                                         bmp.rowBytes(),
                                                         srcRect.fLeft, srcRect.fTop, flags);
-                    bmp.unlockPixels();
                     check_read(reporter, bmp, srcRect.fLeft, srcRect.fTop,
                                success, true,
                                gReadPixelsConfigs[c].fColorType, gReadPixelsConfigs[c].fAlphaType);
@@ -458,7 +454,6 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Texture, reporter, ctxInfo) {
     GrContext* context = ctxInfo.grContext();
 
     SkBitmap bmp = make_src_bitmap();
-    bmp.lockPixels();
 
     // On the GPU we will also try reading back from a non-renderable texture.
     for (auto origin : {kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin}) {
@@ -481,8 +476,6 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Texture, reporter, ctxInfo) {
             test_readpixels_texture(reporter, std::move(sContext));
         }
     }
-
-    bmp.unlockPixels();
 }
 #endif
 
index 3de422b..10aec53 100644 (file)
@@ -318,8 +318,6 @@ static void compare_bitmaps(skiatest::Reporter* reporter,
                             const SkBitmap& b1, const SkBitmap& b2) {
     REPORTER_ASSERT(reporter, b1.width() == b2.width());
     REPORTER_ASSERT(reporter, b1.height() == b2.height());
-    SkAutoLockPixels autoLockPixels1(b1);
-    SkAutoLockPixels autoLockPixels2(b2);
 
     if ((b1.width() != b2.width()) ||
         (b1.height() != b2.height())) {
index f620cff..e236928 100644 (file)
@@ -912,7 +912,6 @@ static void test_overdraw_surface(skiatest::Reporter* r, SkSurface* surface) {
 
     SkBitmap bitmap;
     image->asLegacyBitmap(&bitmap, SkImage::kRO_LegacyBitmapMode);
-    bitmap.lockPixels();
     for (int y = 0; y < 10; y++) {
         for (int x = 0; x < 10; x++) {
             REPORTER_ASSERT(r, 1 == SkGetPackedA32(*bitmap.getAddr32(x, y)));
index bf2e64e..f5cdddc 100644 (file)
@@ -196,7 +196,6 @@ static bool check_write(skiatest::Reporter* reporter, SkCanvas* canvas, const Sk
         return false;
     }
 
-    SkAutoLockPixels alp(secretDevBitmap);
     canvasRowBytes = secretDevBitmap.rowBytes();
     canvasPixels = static_cast<const uint32_t*>(secretDevBitmap.getPixels());
 
@@ -279,7 +278,6 @@ static bool setup_bitmap(SkBitmap* bm, SkColorType ct, SkAlphaType at, int w, in
     if (!alloc_row_bytes(bm, info, rowBytes)) {
         return false;
     }
-    SkAutoLockPixels alp(*bm);
     for (int y = 0; y < h; ++y) {
         for (int x = 0; x < w; ++x) {
             *bm->getAddr32(x, y) = get_bitmap_color(x, y, w, ct, at);
index 691a4f8..e386f46 100644 (file)
@@ -889,9 +889,7 @@ static sk_sp<SkImage> load_image(const Json::Value& jsonImage, UrlDataManager& u
 
 bool SkDrawCommand::flatten(const SkBitmap& bitmap, Json::Value* target,
                             UrlDataManager& urlDataManager) {
-    bitmap.lockPixels();
     sk_sp<SkImage> image(SkImage::MakeFromBitmap(bitmap));
-    bitmap.unlockPixels();
     (*target)[SKDEBUGCANVAS_ATTRIBUTE_COLOR] = Json::Value(color_type_name(bitmap.colorType()));
     (*target)[SKDEBUGCANVAS_ATTRIBUTE_ALPHA] = Json::Value(alpha_type_name(bitmap.alphaType()));
     bool success = flatten(*image, target, urlDataManager);
index b0fd224..27e91cc 100644 (file)
@@ -26,7 +26,6 @@ namespace sk_tools {
             return;
         }
 
-        SkAutoLockPixels lock(bitmap);
         for (int y = 0; y < bitmap.height(); y++) {
             for (int x = 0; x < bitmap.width(); x++) {
                 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT);
@@ -87,7 +86,6 @@ namespace sk_tools {
             bitmap.colorSpace() == srgbColorSpace.get()) {
             // These are premul sRGB 8-bit pixels in SkPMColor order.
             // We want unpremul sRGB 8-bit pixels in RGBA order.  We'll get there via floats.
-            bitmap.lockPixels();
             auto px = (const uint32_t*)bitmap.getPixels();
             if (!px) {
                 return nullptr;
@@ -105,7 +103,6 @@ namespace sk_tools {
         } else if (bitmap.colorType() == kRGBA_F16_SkColorType) {
             // These are premul linear half-float pixels in RGBA order.
             // We want unpremul sRGB 8-bit pixels in RGBA order.  We'll get there via floats.
-            bitmap.lockPixels();
             auto px = (const uint64_t*)bitmap.getPixels();
             if (!px) {
                 return nullptr;
index f8236bf..9a4bb2b 100644 (file)
@@ -225,8 +225,6 @@ void set_portable_typeface(SkPaint* paint, const char* name, SkFontStyle style)
 void write_pixels(SkCanvas* canvas, const SkBitmap& bitmap, int x, int y,
                   SkColorType colorType, SkAlphaType alphaType) {
     SkBitmap tmp(bitmap);
-    tmp.lockPixels();
-
     const SkImageInfo info = SkImageInfo::Make(tmp.width(), tmp.height(), colorType, alphaType);
 
     canvas->writePixels(info, tmp.getPixels(), tmp.rowBytes(), x, y);
index ae6d72c..c7ddf7d 100644 (file)
@@ -163,8 +163,6 @@ void compute_diff(DiffRecord* dr, DiffMetricProc diffFunction, const int colorTh
         return;
     }
 
-    SkAutoLockPixels alpDiff(dr->fDifference.fBitmap);
-    SkAutoLockPixels alpWhite(dr->fWhite.fBitmap);
     int mismatchedPixels = 0;
     int totalMismatchA = 0;
     int totalMismatchR = 0;
index f8eed90..05e1c50 100644 (file)
@@ -71,7 +71,6 @@ bool get_bitmap(sk_sp<SkData> fileBits, DiffResource& resource, bool sizeOnly) {
 
 /** Thanks to PNG, we need to force all pixels 100% opaque. */
 static void force_all_opaque(const SkBitmap& bitmap) {
-   SkAutoLockPixels lock(bitmap);
    for (int y = 0; y < bitmap.height(); y++) {
        for (int x = 0; x < bitmap.width(); x++) {
            *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT);