diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-01-13 20:17:58 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-01-13 20:17:58 +0000 |
commit | dd9ea9262cb61b545fcf414fbde677eb2b62fee4 (patch) | |
tree | 8126f1aaf7b1a14e900d6245fbc3aca1d9a0f523 /src/image | |
parent | a8582234080b01f042b16af4f2c7461193c2cc82 (diff) |
add SkBitmap::installPixelRef()
BUG=
R=scroggo@google.com
Review URL: https://codereview.chromium.org/129423002
git-svn-id: http://skia.googlecode.com/svn/trunk@13055 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/image')
-rw-r--r-- | src/image/SkImagePriv.cpp | 2 | ||||
-rw-r--r-- | src/image/SkImagePriv.h | 3 | ||||
-rw-r--r-- | src/image/SkImage_Base.h | 1 | ||||
-rw-r--r-- | src/image/SkImage_Raster.cpp | 17 | ||||
-rw-r--r-- | src/image/SkSurface_Raster.cpp | 9 |
5 files changed, 13 insertions, 19 deletions
diff --git a/src/image/SkImagePriv.cpp b/src/image/SkImagePriv.cpp index 43cc44b2fa..af15a7599b 100644 --- a/src/image/SkImagePriv.cpp +++ b/src/image/SkImagePriv.cpp @@ -74,7 +74,7 @@ SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) { SkImage* image = NULL; if (canSharePixelRef || bm.isImmutable()) { - image = SkNewImageFromPixelRef(info, bm.pixelRef(), bm.rowBytes()); + image = SkNewImageFromPixelRef(bm.pixelRef()); } else { bm.lockPixels(); if (bm.getPixels()) { diff --git a/src/image/SkImagePriv.h b/src/image/SkImagePriv.h index 7c19c734c2..2812a8f72d 100644 --- a/src/image/SkImagePriv.h +++ b/src/image/SkImagePriv.h @@ -18,8 +18,7 @@ extern SkBitmap::Config SkColorTypeToBitmapConfig(SkColorType); extern bool SkBitmapConfigToColorType(SkBitmap::Config, SkColorType* ctOut); // Call this if you explicitly want to use/share this pixelRef in the image -extern SkImage* SkNewImageFromPixelRef(const SkImageInfo&, SkPixelRef*, - size_t rowBytes); +extern SkImage* SkNewImageFromPixelRef(SkPixelRef*); /** * Examines the bitmap to decide if it can share the existing pixelRef, or diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h index 7bd1f7e6c9..5574f451fe 100644 --- a/src/image/SkImage_Base.h +++ b/src/image/SkImage_Base.h @@ -13,6 +13,7 @@ class SkImage_Base : public SkImage { public: SkImage_Base(int width, int height) : INHERITED(width, height) {} + SkImage_Base(const SkImageInfo& info) : INHERITED(info.fWidth, info.fHeight) {} virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) = 0; virtual void onDrawRectToRect(SkCanvas*, const SkRect* src, diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp index 32d53fc52e..b80fbb3a54 100644 --- a/src/image/SkImage_Raster.cpp +++ b/src/image/SkImage_Raster.cpp @@ -58,7 +58,7 @@ public: virtual bool getROPixels(SkBitmap*) const SK_OVERRIDE; // exposed for SkSurface_Raster via SkNewImageFromPixelRef - SkImage_Raster(const SkImageInfo&, SkPixelRef*, size_t rowBytes); + SkImage_Raster(SkPixelRef*); SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } @@ -84,18 +84,16 @@ SkImage* SkImage_Raster::NewEmpty() { SkImage_Raster::SkImage_Raster(const Info& info, SkData* data, size_t rowBytes) : INHERITED(info.fWidth, info.fHeight) { - fBitmap.setConfig(info, rowBytes); SkAutoTUnref<SkPixelRef> ref( SkMallocPixelRef::NewWithData(info, rowBytes, NULL, data, 0)); - fBitmap.setPixelRef(ref); + fBitmap.installPixelRef(ref); fBitmap.setImmutable(); } -SkImage_Raster::SkImage_Raster(const Info& info, SkPixelRef* pr, size_t rowBytes) - : INHERITED(info.fWidth, info.fHeight) +SkImage_Raster::SkImage_Raster(SkPixelRef* pr) + : INHERITED(pr->info()) { - fBitmap.setConfig(info, rowBytes); - fBitmap.setPixelRef(pr); + fBitmap.installPixelRef(pr); } SkImage_Raster::~SkImage_Raster() {} @@ -155,9 +153,8 @@ SkImage* SkImage::NewRasterData(const SkImageInfo& info, SkData* pixelData, size return SkNEW_ARGS(SkImage_Raster, (info, data, rowBytes)); } -SkImage* SkNewImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr, - size_t rowBytes) { - return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes)); +SkImage* SkNewImageFromPixelRef(SkPixelRef* pr) { + return SkNEW_ARGS(SkImage_Raster, (pr)); } SkPixelRef* SkBitmapImageGetPixelRef(SkImage* image) { diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp index 1b218eb446..7010b5fb2a 100644 --- a/src/image/SkSurface_Raster.cpp +++ b/src/image/SkSurface_Raster.cpp @@ -85,15 +85,12 @@ SkSurface_Raster::SkSurface_Raster(const SkImageInfo& info, void* pixels, size_t } SkSurface_Raster::SkSurface_Raster(SkPixelRef* pr) - : INHERITED(pr->info().fWidth, pr->info().fHeight) + : INHERITED(pr->info()) { - const SkImageInfo& info = pr->info(); - - fBitmap.setConfig(info, info.minRowBytes()); - fBitmap.setPixelRef(pr); + fBitmap.installPixelRef(pr); fWeOwnThePixels = true; - if (!info.isOpaque()) { + if (!pr->info().isOpaque()) { fBitmap.eraseColor(SK_ColorTRANSPARENT); } } |