diff --git a/include/core/SkImage.h b/include/core/SkImage.h index d6aedbae75..96de89ef87 100644 --- a/include/core/SkImage.h +++ b/include/core/SkImage.h @@ -24,7 +24,6 @@ class SkPicture; class SkPixelSerializer; class SkString; class SkSurface; -class SkSurfaceProps; class GrContext; class GrTexture; diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp index ee76a7ea39..af9c27592c 100644 --- a/src/image/SkImage.cpp +++ b/src/image/SkImage.cpp @@ -198,15 +198,10 @@ static bool raster_canvas_supports(const SkImageInfo& info) { return false; } -static SkSurfaceProps copy_or_safe_defaults(const SkSurfaceProps* props) { - return props ? *props : SkSurfaceProps(0, kUnknown_SkPixelGeometry); -} - -SkImage_Base::SkImage_Base(int width, int height, uint32_t uniqueID, const SkSurfaceProps* props) +SkImage_Base::SkImage_Base(int width, int height, uint32_t uniqueID) : INHERITED(width, height, uniqueID) - , fProps(copy_or_safe_defaults(props)) , fAddedToCache(false) -{ } +{} SkImage_Base::~SkImage_Base() { if (fAddedToCache.load()) { @@ -276,7 +271,7 @@ SkImage* SkImage::NewFromBitmap(const SkBitmap& bm) { #endif // This will check for immutable (share or copy) - return SkNewImageFromRasterBitmap(bm, nullptr); + return SkNewImageFromRasterBitmap(bm); } bool SkImage::asLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) const { diff --git a/src/image/SkImagePriv.h b/src/image/SkImagePriv.h index 4b92e946e3..b8f177905d 100644 --- a/src/image/SkImagePriv.h +++ b/src/image/SkImagePriv.h @@ -14,8 +14,7 @@ // Call this if you explicitly want to use/share this pixelRef in the image extern SkImage* SkNewImageFromPixelRef(const SkImageInfo&, SkPixelRef*, const SkIPoint& pixelRefOrigin, - size_t rowBytes, - const SkSurfaceProps*); + size_t rowBytes); /** * Examines the bitmap to decide if it can share the existing pixelRef, or @@ -39,8 +38,7 @@ enum ForceCopyMode { kNo_ForceCopyMode, kYes_ForceCopyMode, // must copy the pixels even if the bitmap is immutable }; -extern SkImage* SkNewImageFromRasterBitmap(const SkBitmap&, const SkSurfaceProps*, - ForceCopyMode = kNo_ForceCopyMode); +extern SkImage* SkNewImageFromRasterBitmap(const SkBitmap&, ForceCopyMode = kNo_ForceCopyMode); static inline size_t SkImageMinRowBytes(const SkImageInfo& info) { size_t minRB = info.minRowBytes(); diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h index 757262ad3d..20df0bca2e 100644 --- a/src/image/SkImage_Base.h +++ b/src/image/SkImage_Base.h @@ -20,26 +20,10 @@ enum { class SkImage_Base : public SkImage { public: - SkImage_Base(int width, int height, uint32_t uniqueID, const SkSurfaceProps* props); + SkImage_Base(int width, int height, uint32_t uniqueID); virtual ~SkImage_Base(); - /** - * If the props weren't know at constructor time, call this but only before the image is - * ever released into the wild (since the props field must appear to be immutable). - */ - void initWithProps(const SkSurfaceProps& props) { - SkASSERT(this->unique()); // only viewed by one thread - SkSurfaceProps* mutableProps = const_cast(&fProps); - SkASSERT(mutableProps != &props); // check for self-assignment - mutableProps->~SkSurfaceProps(); - new (mutableProps) SkSurfaceProps(props); - } - - const SkSurfaceProps& props() const { return fProps; } - - virtual const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const { - return nullptr; - } + virtual const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const { return nullptr; } // Default impl calls onDraw virtual bool onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes, @@ -69,8 +53,6 @@ public: } private: - const SkSurfaceProps fProps; - // Set true by caches when they cache content that's derived from the current pixels. mutable SkAtomic fAddedToCache; diff --git a/src/image/SkImage_Generator.cpp b/src/image/SkImage_Generator.cpp index 1c1b263371..5ce552cb13 100644 --- a/src/image/SkImage_Generator.cpp +++ b/src/image/SkImage_Generator.cpp @@ -17,7 +17,7 @@ class SkImage_Generator : public SkImage_Base { public: SkImage_Generator(SkImageCacherator* cache) - : INHERITED(cache->info().width(), cache->info().height(), cache->uniqueID(), NULL) + : INHERITED(cache->info().width(), cache->info().height(), cache->uniqueID()) , fCache(cache) // take ownership {} diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index 2cc0241a48..e6af3265b6 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -19,7 +19,7 @@ SkImage_Gpu::SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType at, GrTexture* tex, SkSurface::Budgeted budgeted) - : INHERITED(w, h, uniqueID, nullptr) + : INHERITED(w, h, uniqueID) , fTexture(SkRef(tex)) , fAlphaType(at) , fBudgeted(budgeted) diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp index c88e17689c..b6c62e8423 100644 --- a/src/image/SkImage_Raster.cpp +++ b/src/image/SkImage_Raster.cpp @@ -63,7 +63,7 @@ public: return true; } - SkImage_Raster(const SkImageInfo&, SkData*, size_t rb, SkColorTable*, const SkSurfaceProps*); + SkImage_Raster(const SkImageInfo&, SkData*, size_t rb, SkColorTable*); virtual ~SkImage_Raster(); bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY) const override; @@ -74,16 +74,15 @@ public: SkImage* onNewSubset(const SkIRect&) const override; // exposed for SkSurface_Raster via SkNewImageFromPixelRef - SkImage_Raster(const SkImageInfo&, SkPixelRef*, const SkIPoint& pixelRefOrigin, size_t rowBytes, - const SkSurfaceProps*); + SkImage_Raster(const SkImageInfo&, SkPixelRef*, const SkIPoint& origin, size_t rowBytes); SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } bool isOpaque() const override; bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const override; - SkImage_Raster(const SkBitmap& bm, const SkSurfaceProps* props) - : INHERITED(bm.width(), bm.height(), bm.getGenerationID(), props) + SkImage_Raster(const SkBitmap& bm) + : INHERITED(bm.width(), bm.height(), bm.getGenerationID()) , fBitmap(bm) { if (bm.pixelRef()->isPreLocked()) { @@ -99,11 +98,7 @@ public: } private: - SkImage_Raster() : INHERITED(0, 0, kNeedNewImageUniqueID, nullptr) { - fBitmap.setImmutable(); - } - - SkBitmap fBitmap; + SkBitmap fBitmap; typedef SkImage_Base INHERITED; }; @@ -116,8 +111,8 @@ static void release_data(void* addr, void* context) { } SkImage_Raster::SkImage_Raster(const Info& info, SkData* data, size_t rowBytes, - SkColorTable* ctable, const SkSurfaceProps* props) - : INHERITED(info.width(), info.height(), kNeedNewImageUniqueID, props) + SkColorTable* ctable) + : INHERITED(info.width(), info.height(), kNeedNewImageUniqueID) { data->ref(); void* addr = const_cast(data->data()); @@ -128,8 +123,8 @@ SkImage_Raster::SkImage_Raster(const Info& info, SkData* data, size_t rowBytes, } SkImage_Raster::SkImage_Raster(const Info& info, SkPixelRef* pr, const SkIPoint& pixelRefOrigin, - size_t rowBytes, const SkSurfaceProps* props) - : INHERITED(info.width(), info.height(), pr->getGenerationID(), props) + size_t rowBytes) + : INHERITED(info.width(), info.height(), pr->getGenerationID()) { fBitmap.setInfo(info, rowBytes); fBitmap.setPixelRef(pr, pixelRefOrigin); @@ -223,7 +218,7 @@ SkImage* SkImage::NewRasterCopy(const SkImageInfo& info, const void* pixels, siz // Here we actually make a copy of the caller's pixel data SkAutoDataUnref data(SkData::NewWithCopy(pixels, size)); - return new SkImage_Raster(info, data, rowBytes, ctable, nullptr); + return new SkImage_Raster(info, data, rowBytes, ctable); } @@ -239,7 +234,7 @@ SkImage* SkImage::NewRasterData(const SkImageInfo& info, SkData* data, size_t ro } SkColorTable* ctable = nullptr; - return new SkImage_Raster(info, data, rowBytes, ctable, nullptr); + return new SkImage_Raster(info, data, rowBytes, ctable); } SkImage* SkImage::NewFromRaster(const SkImageInfo& info, const void* pixels, size_t rowBytes, @@ -251,20 +246,18 @@ SkImage* SkImage::NewFromRaster(const SkImageInfo& info, const void* pixels, siz SkColorTable* ctable = nullptr; SkAutoDataUnref data(SkData::NewWithProc(pixels, size, proc, ctx)); - return new SkImage_Raster(info, data, rowBytes, ctable, nullptr); + return new SkImage_Raster(info, data, rowBytes, ctable); } SkImage* SkNewImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr, - const SkIPoint& pixelRefOrigin, size_t rowBytes, - const SkSurfaceProps* props) { + const SkIPoint& pixelRefOrigin, size_t rowBytes) { if (!SkImage_Raster::ValidArgs(info, rowBytes, false, nullptr)) { return nullptr; } - return new SkImage_Raster(info, pr, pixelRefOrigin, rowBytes, props); + return new SkImage_Raster(info, pr, pixelRefOrigin, rowBytes); } -SkImage* SkNewImageFromRasterBitmap(const SkBitmap& bm, const SkSurfaceProps* props, - ForceCopyMode forceCopy) { +SkImage* SkNewImageFromRasterBitmap(const SkBitmap& bm, ForceCopyMode forceCopy) { SkASSERT(nullptr == bm.getTexture()); bool hasColorTable = false; @@ -285,13 +278,8 @@ SkImage* SkNewImageFromRasterBitmap(const SkBitmap& bm, const SkSurfaceProps* pr image = SkImage::NewRasterCopy(tmp.info(), tmp.getPixels(), tmp.rowBytes(), tmp.getColorTable()); } - - // we don't expose props to NewRasterCopy (need a private vers) so post-init it here - if (image && props) { - as_IB(image)->initWithProps(*props); - } } else { - image = new SkImage_Raster(bm, props); + image = new SkImage_Raster(bm); } return image; } diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp index b705f4733a..2d5645b2b0 100644 --- a/src/image/SkSurface_Gpu.cpp +++ b/src/image/SkSurface_Gpu.cpp @@ -85,9 +85,6 @@ SkImage* SkSurface_Gpu::onNewImageSnapshot(Budgeted budgeted) { image = new SkImage_Gpu(info.width(), info.height(), kNeedNewImageUniqueID, info.alphaType(), tex, budgeted); } - if (image) { - as_IB(image)->initWithProps(this->props()); - } return image; } diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp index 7ee09c1eed..d5593eb1d7 100644 --- a/src/image/SkSurface_Raster.cpp +++ b/src/image/SkSurface_Raster.cpp @@ -126,7 +126,7 @@ SkImage* SkSurface_Raster::onNewImageSnapshot(Budgeted) { } // Our pixels are in memory, so read access on the snapshot SkImage could be cheap. // Lock the shared pixel ref to ensure peekPixels() is usable. - return SkNewImageFromRasterBitmap(fBitmap, &this->props(), + return SkNewImageFromRasterBitmap(fBitmap, fWeOwnThePixels ? kNo_ForceCopyMode : kYes_ForceCopyMode); }