Update framework to use M34 version of Skia.
These changes are needed due to changes in the Skia API.
Depends on https://googleplex-android-review.git.corp.google.com/#/c/439626/1
(Ic3cf846b74d6f10ec30c477b50fd774cc30ad52c)
BitmapFactory.cpp:
Use SkColorType instead of SkBitmap::Config, where possible.
Call SkBitmap::info() instead of deprecated SkBitmap::asImageInfo().
Remove calls to deprecated SkBitmap::getSize64().
Canvas.cpp:
ColorFilter.cpp:
Matrix.cpp
Remove the deprecated SK_SCALAR_IS_FIXED path. Leave in an else case for
SK_SCALAR_IS_FLOAT, to allow for eventual SK_SCALAR_IS_DOUBLE path.
Graphics.cpp:
Like in BitmapFactory.cpp, use new methods for determining the size of
pixels.
Paint.cpp:
Use more precise SkScalar_ToInt versions of macros.
TextLayoutCache.cpp:
Fix bug in macro definition for HB_SurrogateToUcs4.
Use the new name for SkCreateTypefaceForScriptNG.
android_view_SurfaceControl.cpp:
Replace ScreenshotPixelRef with a Skia pixel ref.
This is a merge from master-skia branch:
https://googleplex-android-review.git.corp.google.com/#/c/430554/
(Ie11503bcefd3883c466279fde5ce147c8a72b452)
Change-Id: Idf15746f93dabeb7862ac02cc6bd925f0dcc68ba
diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp
index c5ab284..159ffb2 100644
--- a/core/jni/android_view_SurfaceControl.cpp
+++ b/core/jni/android_view_SurfaceControl.cpp
@@ -58,36 +58,11 @@
jfieldID secure;
} gPhysicalDisplayInfoClassInfo;
-
-class ScreenshotPixelRef : public SkPixelRef {
-public:
- ScreenshotPixelRef(const SkImageInfo& info, ScreenshotClient* screenshot) :
- SkPixelRef(info),
- mScreenshot(screenshot) {
- setImmutable();
- }
-
- virtual ~ScreenshotPixelRef() {
- delete mScreenshot;
- }
-
-protected:
- // overrides from SkPixelRef
- virtual void* onLockPixels(SkColorTable** ct) {
- *ct = NULL;
- return (void*)mScreenshot->getPixels();
- }
-
- virtual void onUnlockPixels() {
- }
-
- SK_DECLARE_UNFLATTENABLE_OBJECT()
-private:
- ScreenshotClient* mScreenshot;
-
- typedef SkPixelRef INHERITED;
-};
-
+// Implements SkMallocPixelRef::ReleaseProc, to delete the screenshot on unref.
+void DeleteScreenshot(void* addr, void* context) {
+ SkASSERT(addr == ((ScreenshotClient*) context)->getPixels());
+ delete ((ScreenshotClient*) context);
+}
// ----------------------------------------------------------------------------
@@ -167,20 +142,19 @@
}
}
- // takes ownership of ScreenshotClient
- ScreenshotPixelRef* pixels = new ScreenshotPixelRef(screenshotInfo, screenshot);
const ssize_t rowBytes =
screenshot->getStride() * android::bytesPerPixel(screenshot->getFormat());
SkBitmap* bitmap = new SkBitmap();
bitmap->setConfig(screenshotInfo, (size_t)rowBytes);
if (screenshotInfo.fWidth > 0 && screenshotInfo.fHeight > 0) {
+ // takes ownership of ScreenshotClient
+ SkMallocPixelRef* pixels = SkMallocPixelRef::NewWithProc(screenshotInfo,
+ (size_t) rowBytes, NULL, (void*) screenshot->getPixels(), &DeleteScreenshot,
+ (void*) screenshot);
+ pixels->setImmutable();
bitmap->setPixelRef(pixels)->unref();
bitmap->lockPixels();
- } else {
- // be safe with an empty bitmap.
- delete pixels;
- bitmap->setPixels(NULL);
}
return GraphicsJNI::createBitmap(env, bitmap,