Loading core/jni/android/graphics/Bitmap.cpp +5 −11 Original line number Diff line number Diff line Loading @@ -224,37 +224,34 @@ static void ToColor_SI8_Alpha(SkColor dst[], const void* src, int width, SkColorTable* ctable) { SkASSERT(width > 0); const uint8_t* s = (const uint8_t*)src; const SkPMColor* colors = ctable->lockColors(); const SkPMColor* colors = ctable->readColors(); do { *dst++ = SkUnPreMultiply::PMColorToColor(colors[*s++]); } while (--width != 0); ctable->unlockColors(); } static void ToColor_SI8_Raw(SkColor dst[], const void* src, int width, SkColorTable* ctable) { SkASSERT(width > 0); const uint8_t* s = (const uint8_t*)src; const SkPMColor* colors = ctable->lockColors(); const SkPMColor* colors = ctable->readColors(); do { SkPMColor c = colors[*s++]; *dst++ = SkColorSetARGB(SkGetPackedA32(c), SkGetPackedR32(c), SkGetPackedG32(c), SkGetPackedB32(c)); } while (--width != 0); ctable->unlockColors(); } static void ToColor_SI8_Opaque(SkColor dst[], const void* src, int width, SkColorTable* ctable) { SkASSERT(width > 0); const uint8_t* s = (const uint8_t*)src; const SkPMColor* colors = ctable->lockColors(); const SkPMColor* colors = ctable->readColors(); do { SkPMColor c = colors[*s++]; *dst++ = SkColorSetRGB(SkGetPackedR32(c), SkGetPackedG32(c), SkGetPackedB32(c)); } while (--width != 0); ctable->unlockColors(); } // can return NULL Loading Loading @@ -639,8 +636,7 @@ static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject, int count = ctable->count(); p->writeInt32(count); memcpy(p->writeInplace(count * sizeof(SkPMColor)), ctable->lockColors(), count * sizeof(SkPMColor)); ctable->unlockColors(); ctable->readColors(), count * sizeof(SkPMColor)); } else { p->writeInt32(0); // indicate no ctable } Loading Loading @@ -827,10 +823,8 @@ static jboolean Bitmap_sameAs(JNIEnv* env, jobject, jlong bm0Handle, return JNI_FALSE; } SkAutoLockColors alc0(ct0); SkAutoLockColors alc1(ct1); const size_t size = ct0->count() * sizeof(SkPMColor); if (memcmp(alc0.colors(), alc1.colors(), size) != 0) { if (memcmp(ct0->readColors(), ct1->readColors(), size) != 0) { return JNI_FALSE; } } Loading core/jni/android/graphics/Graphics.cpp +0 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,6 @@ #include "SkCanvas.h" #include "SkDevice.h" #include "SkMath.h" #include "SkPicture.h" #include "SkRegion.h" #include <android_runtime/AndroidRuntime.h> Loading core/jni/android/graphics/Picture.cpp +24 −15 Original line number Diff line number Diff line Loading @@ -27,9 +27,10 @@ Picture::Picture(const Picture* src) { mHeight = src->height(); if (NULL != src->mPicture.get()) { mPicture.reset(SkRef(src->mPicture.get())); } if (NULL != src->mRecorder.get()) { } else if (NULL != src->mRecorder.get()) { mPicture.reset(src->makePartialCopy()); } validate(); } else { mWidth = 0; mHeight = 0; Loading @@ -48,35 +49,31 @@ Canvas* Picture::beginRecording(int width, int height) { void Picture::endRecording() { if (NULL != mRecorder.get()) { mPicture.reset(mRecorder->endRecording()); validate(); mRecorder.reset(NULL); } } int Picture::width() const { if (NULL != mPicture.get()) { SkASSERT(mPicture->width() == mWidth); SkASSERT(mPicture->height() == mHeight); } validate(); return mWidth; } int Picture::height() const { if (NULL != mPicture.get()) { SkASSERT(mPicture->width() == mWidth); SkASSERT(mPicture->height() == mHeight); } validate(); return mHeight; } Picture* Picture::CreateFromStream(SkStream* stream) { Picture* newPict = new Picture; newPict->mPicture.reset(SkPicture::CreateFromStream(stream)); if (NULL != newPict->mPicture.get()) { newPict->mWidth = newPict->mPicture->width(); newPict->mHeight = newPict->mPicture->height(); SkPicture* skPicture = SkPicture::CreateFromStream(stream); if (NULL != skPicture) { newPict->mPicture.reset(skPicture); const SkIRect cullRect = skPicture->cullRect().roundOut(); newPict->mWidth = cullRect.width(); newPict->mHeight = cullRect.height(); } return newPict; Loading @@ -87,6 +84,7 @@ void Picture::serialize(SkWStream* stream) const { SkAutoTDelete<SkPicture> tempPict(this->makePartialCopy()); tempPict->serialize(stream); } else if (NULL != mPicture.get()) { validate(); mPicture->serialize(stream); } else { SkPictureRecorder recorder; Loading @@ -101,6 +99,7 @@ void Picture::draw(Canvas* canvas) { this->endRecording(); SkASSERT(NULL != mPicture.get()); } validate(); if (NULL != mPicture.get()) { mPicture.get()->playback(canvas->getSkCanvas()); } Loading @@ -116,4 +115,14 @@ SkPicture* Picture::makePartialCopy() const { return reRecorder.endRecording(); } void Picture::validate() const { #ifdef SK_DEBUG if (NULL != mPicture.get()) { SkRect cullRect = mPicture->cullRect(); SkRect myRect = SkRect::MakeWH(SkIntToScalar(mWidth), SkIntToScalar(mHeight)); SkASSERT(cullRect == myRect); } #endif } }; // namespace android core/jni/android/graphics/Picture.h +2 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,8 @@ private: // Make a copy of a picture that is in the midst of being recorded. The // resulting picture will have balanced saves and restores. SkPicture* makePartialCopy() const; void validate() const; }; }; // namespace android Loading core/jni/android/graphics/pdf/PdfDocument.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ public: mCurrentPage = page; SkCanvas* canvas = page->mPictureRecorder->beginRecording( contentRect.width(), contentRect.height(), NULL, 0); SkRect::MakeWH(contentRect.width(), contentRect.height())); return canvas; } Loading Loading
core/jni/android/graphics/Bitmap.cpp +5 −11 Original line number Diff line number Diff line Loading @@ -224,37 +224,34 @@ static void ToColor_SI8_Alpha(SkColor dst[], const void* src, int width, SkColorTable* ctable) { SkASSERT(width > 0); const uint8_t* s = (const uint8_t*)src; const SkPMColor* colors = ctable->lockColors(); const SkPMColor* colors = ctable->readColors(); do { *dst++ = SkUnPreMultiply::PMColorToColor(colors[*s++]); } while (--width != 0); ctable->unlockColors(); } static void ToColor_SI8_Raw(SkColor dst[], const void* src, int width, SkColorTable* ctable) { SkASSERT(width > 0); const uint8_t* s = (const uint8_t*)src; const SkPMColor* colors = ctable->lockColors(); const SkPMColor* colors = ctable->readColors(); do { SkPMColor c = colors[*s++]; *dst++ = SkColorSetARGB(SkGetPackedA32(c), SkGetPackedR32(c), SkGetPackedG32(c), SkGetPackedB32(c)); } while (--width != 0); ctable->unlockColors(); } static void ToColor_SI8_Opaque(SkColor dst[], const void* src, int width, SkColorTable* ctable) { SkASSERT(width > 0); const uint8_t* s = (const uint8_t*)src; const SkPMColor* colors = ctable->lockColors(); const SkPMColor* colors = ctable->readColors(); do { SkPMColor c = colors[*s++]; *dst++ = SkColorSetRGB(SkGetPackedR32(c), SkGetPackedG32(c), SkGetPackedB32(c)); } while (--width != 0); ctable->unlockColors(); } // can return NULL Loading Loading @@ -639,8 +636,7 @@ static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject, int count = ctable->count(); p->writeInt32(count); memcpy(p->writeInplace(count * sizeof(SkPMColor)), ctable->lockColors(), count * sizeof(SkPMColor)); ctable->unlockColors(); ctable->readColors(), count * sizeof(SkPMColor)); } else { p->writeInt32(0); // indicate no ctable } Loading Loading @@ -827,10 +823,8 @@ static jboolean Bitmap_sameAs(JNIEnv* env, jobject, jlong bm0Handle, return JNI_FALSE; } SkAutoLockColors alc0(ct0); SkAutoLockColors alc1(ct1); const size_t size = ct0->count() * sizeof(SkPMColor); if (memcmp(alc0.colors(), alc1.colors(), size) != 0) { if (memcmp(ct0->readColors(), ct1->readColors(), size) != 0) { return JNI_FALSE; } } Loading
core/jni/android/graphics/Graphics.cpp +0 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,6 @@ #include "SkCanvas.h" #include "SkDevice.h" #include "SkMath.h" #include "SkPicture.h" #include "SkRegion.h" #include <android_runtime/AndroidRuntime.h> Loading
core/jni/android/graphics/Picture.cpp +24 −15 Original line number Diff line number Diff line Loading @@ -27,9 +27,10 @@ Picture::Picture(const Picture* src) { mHeight = src->height(); if (NULL != src->mPicture.get()) { mPicture.reset(SkRef(src->mPicture.get())); } if (NULL != src->mRecorder.get()) { } else if (NULL != src->mRecorder.get()) { mPicture.reset(src->makePartialCopy()); } validate(); } else { mWidth = 0; mHeight = 0; Loading @@ -48,35 +49,31 @@ Canvas* Picture::beginRecording(int width, int height) { void Picture::endRecording() { if (NULL != mRecorder.get()) { mPicture.reset(mRecorder->endRecording()); validate(); mRecorder.reset(NULL); } } int Picture::width() const { if (NULL != mPicture.get()) { SkASSERT(mPicture->width() == mWidth); SkASSERT(mPicture->height() == mHeight); } validate(); return mWidth; } int Picture::height() const { if (NULL != mPicture.get()) { SkASSERT(mPicture->width() == mWidth); SkASSERT(mPicture->height() == mHeight); } validate(); return mHeight; } Picture* Picture::CreateFromStream(SkStream* stream) { Picture* newPict = new Picture; newPict->mPicture.reset(SkPicture::CreateFromStream(stream)); if (NULL != newPict->mPicture.get()) { newPict->mWidth = newPict->mPicture->width(); newPict->mHeight = newPict->mPicture->height(); SkPicture* skPicture = SkPicture::CreateFromStream(stream); if (NULL != skPicture) { newPict->mPicture.reset(skPicture); const SkIRect cullRect = skPicture->cullRect().roundOut(); newPict->mWidth = cullRect.width(); newPict->mHeight = cullRect.height(); } return newPict; Loading @@ -87,6 +84,7 @@ void Picture::serialize(SkWStream* stream) const { SkAutoTDelete<SkPicture> tempPict(this->makePartialCopy()); tempPict->serialize(stream); } else if (NULL != mPicture.get()) { validate(); mPicture->serialize(stream); } else { SkPictureRecorder recorder; Loading @@ -101,6 +99,7 @@ void Picture::draw(Canvas* canvas) { this->endRecording(); SkASSERT(NULL != mPicture.get()); } validate(); if (NULL != mPicture.get()) { mPicture.get()->playback(canvas->getSkCanvas()); } Loading @@ -116,4 +115,14 @@ SkPicture* Picture::makePartialCopy() const { return reRecorder.endRecording(); } void Picture::validate() const { #ifdef SK_DEBUG if (NULL != mPicture.get()) { SkRect cullRect = mPicture->cullRect(); SkRect myRect = SkRect::MakeWH(SkIntToScalar(mWidth), SkIntToScalar(mHeight)); SkASSERT(cullRect == myRect); } #endif } }; // namespace android
core/jni/android/graphics/Picture.h +2 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,8 @@ private: // Make a copy of a picture that is in the midst of being recorded. The // resulting picture will have balanced saves and restores. SkPicture* makePartialCopy() const; void validate() const; }; }; // namespace android Loading
core/jni/android/graphics/pdf/PdfDocument.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ public: mCurrentPage = page; SkCanvas* canvas = page->mPictureRecorder->beginRecording( contentRect.width(), contentRect.height(), NULL, 0); SkRect::MakeWH(contentRect.width(), contentRect.height())); return canvas; } Loading