aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Ben Wagner <benjaminwagner@google.com>2017-04-28 13:06:02 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-28 17:06:23 +0000
commit2fcd4a480deecb23e9fdde07e63d18d2735c9287 (patch)
treea38637d39c6d26e725caad83e033958c0174703a /include
parent68b8e3d50d0954eb5eeb7f625f06026c7fbd38c1 (diff)
Revert "Only store width and height on SkPixelRef"
This reverts commit 2cbb6662e329981840f90ef4edd62f70f69e6030. Reason for revert: Likely cause of Chromium DEPS roll failure; speculative revert. Original change's description: > Only store width and height on SkPixelRef > > Bug: skia:6535 > Change-Id: Id91e8d1e82f593be7d4b23ca5abde752f2666a77 > Reviewed-on: https://skia-review.googlesource.com/14105 > Commit-Queue: Matt Sarett <msarett@google.com> > Reviewed-by: Mike Reed <reed@google.com> > TBR=djsollen@google.com,msarett@google.com,reed@google.com,stani@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I12a024a71833f33432d5ea8cffdfc642b8b4240a Bug: skia: Reviewed-on: https://skia-review.googlesource.com/14644 Reviewed-by: Ben Wagner <benjaminwagner@google.com> Commit-Queue: Ben Wagner <benjaminwagner@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/core/SkMallocPixelRef.h2
-rw-r--r--include/core/SkPixelRef.h59
2 files changed, 25 insertions, 36 deletions
diff --git a/include/core/SkMallocPixelRef.h b/include/core/SkMallocPixelRef.h
index e6d9727952..45ab6547f4 100644
--- a/include/core/SkMallocPixelRef.h
+++ b/include/core/SkMallocPixelRef.h
@@ -78,6 +78,8 @@ public:
protected:
~SkMallocPixelRef() override;
+ size_t getAllocatedSizeInBytes() const override;
+
private:
// Uses alloc to implement NewAllocate or NewZeroed.
static sk_sp<SkPixelRef> MakeUsing(void*(*alloc)(size_t),
diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h
index 535c6e10e0..6a86e59a86 100644
--- a/include/core/SkPixelRef.h
+++ b/include/core/SkPixelRef.h
@@ -32,42 +32,13 @@ class SkDiscardableMemory;
*/
class SK_API SkPixelRef : public SkRefCnt {
public:
-#ifdef SK_SUPPORT_LEGACY_PIXELREF_API
SkPixelRef(const SkImageInfo&, void* addr, size_t rowBytes, sk_sp<SkColorTable> = nullptr);
+ ~SkPixelRef() override;
const SkImageInfo& info() const {
return fInfo;
}
-#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
- // This is undefined if there are clients in-flight trying to use us
- void android_only_reset(const SkImageInfo&, size_t rowBytes, sk_sp<SkColorTable>);
-#endif
-
- /**
- * Change the info's AlphaType. Note that this does not automatically
- * invalidate the generation ID. If the pixel values themselves have
- * changed, then you must explicitly call notifyPixelsChanged() as well.
- */
- void changeAlphaType(SkAlphaType at);
-
- /**
- * Returns the size (in bytes) of the internally allocated memory.
- * This should be implemented in all serializable SkPixelRef derived classes.
- * SkBitmap::fPixelRefOffset + SkBitmap::getSafeSize() should never overflow this value,
- * otherwise the rendering code may attempt to read memory out of bounds.
- *
- * @return default impl returns 0.
- */
- virtual size_t getAllocatedSizeInBytes() const { return 0; }
-
-#endif
- SkPixelRef(int width, int height, void* addr, size_t rowBytes, sk_sp<SkColorTable> = nullptr);
-
- ~SkPixelRef() override;
-
- int width() const { return fInfo.width(); }
- int height() const { return fInfo.height(); }
void* pixels() const { return fPixels; }
SkColorTable* colorTable() const { return fCTable.get(); }
size_t rowBytes() const { return fRowBytes; }
@@ -97,6 +68,13 @@ public:
*/
void notifyPixelsChanged();
+ /**
+ * Change the info's AlphaType. Note that this does not automatically
+ * invalidate the generation ID. If the pixel values themselves have
+ * changed, then you must explicitly call notifyPixelsChanged() as well.
+ */
+ void changeAlphaType(SkAlphaType at);
+
/** Returns true if this pixelref is marked as immutable, meaning that the
contents of its pixels will not change for the lifetime of the pixelref.
*/
@@ -136,18 +114,27 @@ protected:
// default impl does nothing.
virtual void onNotifyPixelsChanged();
+ /**
+ * Returns the size (in bytes) of the internally allocated memory.
+ * This should be implemented in all serializable SkPixelRef derived classes.
+ * SkBitmap::fPixelRefOffset + SkBitmap::getSafeSize() should never overflow this value,
+ * otherwise the rendering code may attempt to read memory out of bounds.
+ *
+ * @return default impl returns 0.
+ */
+ virtual size_t getAllocatedSizeInBytes() const;
+
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
// This is undefined if there are clients in-flight trying to use us
- void android_only_reset(int width, int height, size_t rowBytes, sk_sp<SkColorTable>);
+ void android_only_reset(const SkImageInfo&, size_t rowBytes, sk_sp<SkColorTable>);
#endif
private:
- // TODO (msarett): After we remove legacy APIs, we should replace |fInfo| with just a width
- // and height.
- const SkImageInfo fInfo;
+ // mostly const. fInfo.fAlpahType can be changed at runtime.
+ const SkImageInfo fInfo;
sk_sp<SkColorTable> fCTable;
- void* fPixels;
- size_t fRowBytes;
+ void* fPixels;
+ size_t fRowBytes;
// Bottom bit indicates the Gen ID is unique.
bool genIDIsUnique() const { return SkToBool(fTaggedGenID.load() & 1); }