add query to pixelref for its encoded data (if it has any)

Review URL: https://codereview.appspot.com/6891047

git-svn-id: http://skia.googlecode.com/svn/trunk@6689 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@google.com 2012-12-06 14:26:02 +00:00
parent 34cd70a581
commit eb776128f5
2 changed files with 20 additions and 0 deletions

View File

@ -16,6 +16,7 @@
#include "SkFlattenable.h" #include "SkFlattenable.h"
class SkColorTable; class SkColorTable;
class SkData;
struct SkIRect; struct SkIRect;
class SkMutex; class SkMutex;
@ -113,6 +114,18 @@ public:
*/ */
void setURI(const SkString& uri) { fURI = uri; } void setURI(const SkString& uri) { fURI = uri; }
/**
* If the pixelRef has an encoded (i.e. compressed) representation,
* return a ref to its data. If the pixelRef
* is uncompressed or otherwise does not have this form, return NULL.
*
* If non-null is returned, the caller is responsible for calling unref()
* on the data when it is finished.
*/
SkData* refEncodedData() {
return this->onRefEncodedData();
}
/** Are we really wrapping a texture instead of a bitmap? /** Are we really wrapping a texture instead of a bitmap?
*/ */
virtual SkGpuTexture* getTexture() { return NULL; } virtual SkGpuTexture* getTexture() { return NULL; }
@ -163,6 +176,9 @@ protected:
*/ */
virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subsetOrNull); virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subsetOrNull);
// default impl returns NULL.
virtual SkData* onRefEncodedData();
/** Return the mutex associated with this pixelref. This value is assigned /** Return the mutex associated with this pixelref. This value is assigned
in the constructor, and cannot change during the lifetime of the object. in the constructor, and cannot change during the lifetime of the object.
*/ */

View File

@ -168,6 +168,10 @@ bool SkPixelRef::onReadPixels(SkBitmap* dst, const SkIRect* subset) {
return false; return false;
} }
SkData* SkPixelRef::onRefEncodedData() {
return NULL;
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#ifdef SK_BUILD_FOR_ANDROID #ifdef SK_BUILD_FOR_ANDROID