android-only api to reset the fields of a pixelref

BUG=skia:6494

Change-Id: I97c8a93849a13f0c5fd57c8a150ecc2ce363d8f3
Reviewed-on: https://skia-review.googlesource.com/13250
Reviewed-by: Matt Sarett <msarett@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2017-04-12 12:57:07 -04:00 committed by Skia Commit-Bot
parent 6d2cf4726c
commit 4ccd862d29
2 changed files with 22 additions and 0 deletions

View File

@ -255,6 +255,11 @@ protected:
*/
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(const SkImageInfo&, size_t rowBytes, sk_sp<SkColorTable>);
#endif
/** Return the mutex associated with this pixelref. This value is assigned
in the constructor, and cannot change during the lifetime of the object.
*/

View File

@ -106,6 +106,23 @@ SkPixelRef::~SkPixelRef() {
this->callGenIDChangeListeners();
}
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
// This is undefined if there are clients in-flight trying to use us
void SkPixelRef::android_only_reset(const SkImageInfo& info, size_t rowBytes,
sk_sp<SkColorTable> ctable) {
validate_pixels_ctable(info, ctable.get());
*const_cast<SkImageInfo*>(&fInfo) = info;
fCTable = std::move(ctable);
// note: we do not change fRec.fPixels
fRec.fRowBytes = rowBytes;
fRec.fColorTable = fCTable.get();
// conservative, since its possible the "new" settings are the same as the old.
this->notifyPixelsChanged();
}
#endif
void SkPixelRef::needsNewGenID() {
fTaggedGenID.store(0);
SkASSERT(!this->genIDIsUnique()); // This method isn't threadsafe, so the assert should be fine.