| Index: src/image/SkImage_Raster.cpp
|
| diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
|
| index 3282e7b7ed87b4555c8908eb53f2de8cf34b766e..e87e4c95ce5c29caa3a16726ba48934b547d56b3 100644
|
| --- a/src/image/SkImage_Raster.cpp
|
| +++ b/src/image/SkImage_Raster.cpp
|
| @@ -5,7 +5,7 @@
|
| * found in the LICENSE file.
|
| */
|
|
|
| -#include "SkImage_Base.h"
|
| +#include "SkImage_Raster.h"
|
| #include "SkBitmap.h"
|
| #include "SkCanvas.h"
|
| #include "SkColorTable.h"
|
| @@ -20,108 +20,6 @@
|
| #include "SkGrPriv.h"
|
| #endif
|
|
|
| -// fixes https://bug.skia.org/5096
|
| -static bool is_not_subset(const SkBitmap& bm) {
|
| - SkASSERT(bm.pixelRef());
|
| - SkISize dim = bm.pixelRef()->info().dimensions();
|
| - SkASSERT(dim != bm.dimensions() || bm.pixelRefOrigin().isZero());
|
| - return dim == bm.dimensions();
|
| -}
|
| -
|
| -class SkImage_Raster : public SkImage_Base {
|
| -public:
|
| - static bool ValidArgs(const Info& info, size_t rowBytes, bool hasColorTable,
|
| - size_t* minSize) {
|
| - const int maxDimension = SK_MaxS32 >> 2;
|
| -
|
| - if (info.width() <= 0 || info.height() <= 0) {
|
| - return false;
|
| - }
|
| - if (info.width() > maxDimension || info.height() > maxDimension) {
|
| - return false;
|
| - }
|
| - if ((unsigned)info.colorType() > (unsigned)kLastEnum_SkColorType) {
|
| - return false;
|
| - }
|
| - if ((unsigned)info.alphaType() > (unsigned)kLastEnum_SkAlphaType) {
|
| - return false;
|
| - }
|
| -
|
| - if (kUnknown_SkColorType == info.colorType()) {
|
| - return false;
|
| - }
|
| -
|
| - const bool needsCT = kIndex_8_SkColorType == info.colorType();
|
| - if (needsCT != hasColorTable) {
|
| - return false;
|
| - }
|
| -
|
| - if (rowBytes < info.minRowBytes()) {
|
| - return false;
|
| - }
|
| -
|
| - size_t size = info.getSafeSize(rowBytes);
|
| - if (0 == size) {
|
| - return false;
|
| - }
|
| -
|
| - if (minSize) {
|
| - *minSize = size;
|
| - }
|
| - return true;
|
| - }
|
| -
|
| - SkImage_Raster(const SkImageInfo&, sk_sp<SkData>, size_t rb, SkColorTable*);
|
| - virtual ~SkImage_Raster();
|
| -
|
| - SkImageInfo onImageInfo() const override {
|
| - return fBitmap.info();
|
| - }
|
| -
|
| - bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY, CachingHint) const override;
|
| - bool onPeekPixels(SkPixmap*) const override;
|
| - const SkBitmap* onPeekBitmap() const override { return &fBitmap; }
|
| -
|
| - SkData* onRefEncoded(GrContext*) const override;
|
| - bool getROPixels(SkBitmap*, CachingHint) const override;
|
| - GrTexture* asTextureRef(GrContext*, const GrTextureParams&,
|
| - SkSourceGammaTreatment) const override;
|
| - sk_sp<SkImage> onMakeSubset(const SkIRect&) const override;
|
| -
|
| - // exposed for SkSurface_Raster via SkNewImageFromPixelRef
|
| - 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, bool bitmapMayBeMutable = false)
|
| - : INHERITED(bm.width(), bm.height(),
|
| - is_not_subset(bm) ? bm.getGenerationID()
|
| - : (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());
|
| - }
|
| -
|
| - bool onIsLazyGenerated() const override {
|
| - return fBitmap.pixelRef() && fBitmap.pixelRef()->isLazyGenerated();
|
| - }
|
| -
|
| -private:
|
| - SkBitmap fBitmap;
|
| -
|
| - typedef SkImage_Base INHERITED;
|
| -};
|
| -
|
| -///////////////////////////////////////////////////////////////////////////////
|
| -
|
| static void release_data(void* addr, void* context) {
|
| SkData* data = static_cast<SkData*>(context);
|
| data->unref();
|
|
|