Loading cmds/screencap/screencap.cpp +38 −1 Original line number Diff line number Diff line Loading @@ -33,17 +33,24 @@ #include <ui/DisplayInfo.h> #include <ui/PixelFormat.h> #include <system/graphics.h> // TODO: Fix Skia. #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" #include <SkImageEncoder.h> #include <SkData.h> #include <SkColorSpace.h> #pragma GCC diagnostic pop using namespace android; static uint32_t DEFAULT_DISPLAY_ID = ISurfaceComposer::eDisplayIdMain; #define COLORSPACE_UNKNOWN 0 #define COLORSPACE_SRGB 1 #define COLORSPACE_DISPLAY_P3 2 static void usage(const char* pname) { fprintf(stderr, Loading @@ -67,6 +74,31 @@ static SkColorType flinger2skia(PixelFormat f) } } static sk_sp<SkColorSpace> dataSpaceToColorSpace(android_dataspace d) { switch (d) { case HAL_DATASPACE_V0_SRGB: return SkColorSpace::MakeSRGB(); case HAL_DATASPACE_DISPLAY_P3: return SkColorSpace::MakeRGB( SkColorSpace::kSRGB_RenderTargetGamma, SkColorSpace::kDCIP3_D65_Gamut); default: return nullptr; } } static uint32_t dataSpaceToInt(android_dataspace d) { switch (d) { case HAL_DATASPACE_V0_SRGB: return COLORSPACE_SRGB; case HAL_DATASPACE_DISPLAY_P3: return COLORSPACE_DISPLAY_P3; default: return COLORSPACE_UNKNOWN; } } static status_t notifyMediaScanner(const char* fileName) { String8 cmd("am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file://"); String8 fileUrl("\""); Loading Loading @@ -139,6 +171,7 @@ int main(int argc, char** argv) void const* base = NULL; uint32_t w, s, h, f; android_dataspace d; size_t size = 0; // Maps orientations from DisplayInfo to ISurfaceComposer Loading Loading @@ -177,13 +210,15 @@ int main(int argc, char** argv) h = screenshot.getHeight(); s = screenshot.getStride(); f = screenshot.getFormat(); d = screenshot.getDataSpace(); size = screenshot.getSize(); } if (base != NULL) { if (png) { const SkImageInfo info = SkImageInfo::Make(w, h, flinger2skia(f), kPremul_SkAlphaType); SkImageInfo::Make(w, h, flinger2skia(f), kPremul_SkAlphaType, dataSpaceToColorSpace(d)); SkPixmap pixmap(info, base, s * bytesPerPixel(f)); struct FDWStream final : public SkWStream { size_t fBytesWritten = 0; Loading @@ -200,9 +235,11 @@ int main(int argc, char** argv) notifyMediaScanner(fn); } } else { uint32_t c = dataSpaceToInt(d); write(fd, &w, 4); write(fd, &h, 4); write(fd, &f, 4); write(fd, &c, 4); size_t Bpp = bytesPerPixel(f); for (size_t y=0 ; y<h ; y++) { write(fd, base, w*Bpp); Loading core/java/android/view/ThreadedRenderer.java +10 −5 Original line number Diff line number Diff line Loading @@ -358,7 +358,6 @@ public final class ThreadedRenderer { private long mNativeProxy; private boolean mInitialized = false; private RenderNode mRootNode; private Choreographer mChoreographer; private boolean mRootNodeNeedsUpdate; private boolean mEnabled; Loading Loading @@ -425,8 +424,6 @@ public final class ThreadedRenderer { /** * Indicates whether threaded rendering is currently requested but not * necessarily enabled yet. * * @return True to request threaded rendering, false otherwise. */ void setRequested(boolean requested) { mRequested = requested; Loading Loading @@ -596,6 +593,13 @@ public final class ThreadedRenderer { nSetOpaque(mNativeProxy, opaque && !mHasInsets); } /** * Enable/disable wide gamut rendering on this renderer. */ void setWideGamut(boolean wideGamut) { nSetWideGamut(mNativeProxy, wideGamut); } /** * Gets the current width of the surface. This is the width that the surface * was last set to in a call to {@link #setup(int, int, View.AttachInfo, Rect)}. Loading Loading @@ -933,11 +937,11 @@ public final class ThreadedRenderer { if (mInitialized) return; mInitialized = true; mAppContext = context.getApplicationContext(); initSched(context, renderProxy); initSched(renderProxy); initGraphicsStats(); } private void initSched(Context context, long renderProxy) { private void initSched(long renderProxy) { try { int tid = nGetRenderThreadTid(renderProxy); ActivityManager.getService().setRenderThread(tid); Loading Loading @@ -1007,6 +1011,7 @@ public final class ThreadedRenderer { private static native void nSetLightCenter(long nativeProxy, float lightX, float lightY, float lightZ); private static native void nSetOpaque(long nativeProxy, boolean opaque); private static native void nSetWideGamut(long nativeProxy, boolean wideGamut); private static native int nSyncAndDrawFrame(long nativeProxy, long[] frameInfo, int size); private static native void nDestroy(long nativeProxy, long rootRenderNode); private static native void nRegisterAnimatingRenderNode(long rootRenderNode, long animatingNode); Loading core/java/android/view/ViewRootImpl.java +5 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import android.app.ResourcesManager; import android.content.ClipData; import android.content.ClipDescription; import android.content.Context; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; Loading Loading @@ -960,8 +961,12 @@ public final class ViewRootImpl implements ViewParent, final boolean hasSurfaceInsets = insets.left != 0 || insets.right != 0 || insets.top != 0 || insets.bottom != 0; final boolean translucent = attrs.format != PixelFormat.OPAQUE || hasSurfaceInsets; final boolean wideGamut = attrs.getColorMode() == ActivityInfo.COLOR_MODE_WIDE_COLOR_GAMUT; mAttachInfo.mThreadedRenderer = ThreadedRenderer.create(mContext, translucent, attrs.getTitle().toString()); mAttachInfo.mThreadedRenderer.setWideGamut(wideGamut); if (mAttachInfo.mThreadedRenderer != null) { mAttachInfo.mHardwareAccelerated = mAttachInfo.mHardwareAccelerationRequested = true; Loading core/java/android/view/WindowManager.java +9 −0 Original line number Diff line number Diff line Loading @@ -2090,6 +2090,7 @@ public interface WindowManager extends ViewManager { out.writeInt(needsMenuKey); out.writeInt(accessibilityIdOfAnchor); TextUtils.writeToParcel(accessibilityTitle, out, parcelableFlags); out.writeInt(mColorMode); out.writeLong(hideTimeoutMilliseconds); } Loading Loading @@ -2144,6 +2145,7 @@ public interface WindowManager extends ViewManager { needsMenuKey = in.readInt(); accessibilityIdOfAnchor = in.readInt(); accessibilityTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); mColorMode = in.readInt(); hideTimeoutMilliseconds = in.readLong(); } Loading Loading @@ -2189,6 +2191,8 @@ public interface WindowManager extends ViewManager { @TestApi public static final int ACCESSIBILITY_TITLE_CHANGED = 1 << 25; /** {@hide} */ public static final int COLOR_MODE_CHANGED = 1 << 26; /** {@hide} */ public static final int EVERYTHING_CHANGED = 0xffffffff; // internal buffer to backup/restore parameters under compatibility mode. Loading Loading @@ -2366,6 +2370,11 @@ public interface WindowManager extends ViewManager { changes |= ACCESSIBILITY_TITLE_CHANGED; } if (mColorMode != o.mColorMode) { mColorMode = o.mColorMode; changes |= COLOR_MODE_CHANGED; } // This can't change, it's only set at window creation time. hideTimeoutMilliseconds = o.hideTimeoutMilliseconds; Loading core/jni/android_view_SurfaceControl.cpp +10 −1 Original line number Diff line number Diff line Loading @@ -221,11 +221,20 @@ static jobject nativeScreenshotBitmap(JNIEnv* env, jclass clazz, return NULL; } } sk_sp<SkColorSpace> colorSpace; if (screenshot->getDataSpace() == HAL_DATASPACE_DISPLAY_P3) { colorSpace = SkColorSpace::MakeRGB( SkColorSpace::kSRGB_RenderTargetGamma, SkColorSpace::kDCIP3_D65_Gamut); } else { colorSpace = SkColorSpace::MakeSRGB(); } SkImageInfo screenshotInfo = SkImageInfo::Make(screenshot->getWidth(), screenshot->getHeight(), colorType, alphaType, GraphicsJNI::defaultColorSpace()); colorSpace); const size_t rowBytes = screenshot->getStride() * android::bytesPerPixel(screenshot->getFormat()); Loading Loading
cmds/screencap/screencap.cpp +38 −1 Original line number Diff line number Diff line Loading @@ -33,17 +33,24 @@ #include <ui/DisplayInfo.h> #include <ui/PixelFormat.h> #include <system/graphics.h> // TODO: Fix Skia. #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" #include <SkImageEncoder.h> #include <SkData.h> #include <SkColorSpace.h> #pragma GCC diagnostic pop using namespace android; static uint32_t DEFAULT_DISPLAY_ID = ISurfaceComposer::eDisplayIdMain; #define COLORSPACE_UNKNOWN 0 #define COLORSPACE_SRGB 1 #define COLORSPACE_DISPLAY_P3 2 static void usage(const char* pname) { fprintf(stderr, Loading @@ -67,6 +74,31 @@ static SkColorType flinger2skia(PixelFormat f) } } static sk_sp<SkColorSpace> dataSpaceToColorSpace(android_dataspace d) { switch (d) { case HAL_DATASPACE_V0_SRGB: return SkColorSpace::MakeSRGB(); case HAL_DATASPACE_DISPLAY_P3: return SkColorSpace::MakeRGB( SkColorSpace::kSRGB_RenderTargetGamma, SkColorSpace::kDCIP3_D65_Gamut); default: return nullptr; } } static uint32_t dataSpaceToInt(android_dataspace d) { switch (d) { case HAL_DATASPACE_V0_SRGB: return COLORSPACE_SRGB; case HAL_DATASPACE_DISPLAY_P3: return COLORSPACE_DISPLAY_P3; default: return COLORSPACE_UNKNOWN; } } static status_t notifyMediaScanner(const char* fileName) { String8 cmd("am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file://"); String8 fileUrl("\""); Loading Loading @@ -139,6 +171,7 @@ int main(int argc, char** argv) void const* base = NULL; uint32_t w, s, h, f; android_dataspace d; size_t size = 0; // Maps orientations from DisplayInfo to ISurfaceComposer Loading Loading @@ -177,13 +210,15 @@ int main(int argc, char** argv) h = screenshot.getHeight(); s = screenshot.getStride(); f = screenshot.getFormat(); d = screenshot.getDataSpace(); size = screenshot.getSize(); } if (base != NULL) { if (png) { const SkImageInfo info = SkImageInfo::Make(w, h, flinger2skia(f), kPremul_SkAlphaType); SkImageInfo::Make(w, h, flinger2skia(f), kPremul_SkAlphaType, dataSpaceToColorSpace(d)); SkPixmap pixmap(info, base, s * bytesPerPixel(f)); struct FDWStream final : public SkWStream { size_t fBytesWritten = 0; Loading @@ -200,9 +235,11 @@ int main(int argc, char** argv) notifyMediaScanner(fn); } } else { uint32_t c = dataSpaceToInt(d); write(fd, &w, 4); write(fd, &h, 4); write(fd, &f, 4); write(fd, &c, 4); size_t Bpp = bytesPerPixel(f); for (size_t y=0 ; y<h ; y++) { write(fd, base, w*Bpp); Loading
core/java/android/view/ThreadedRenderer.java +10 −5 Original line number Diff line number Diff line Loading @@ -358,7 +358,6 @@ public final class ThreadedRenderer { private long mNativeProxy; private boolean mInitialized = false; private RenderNode mRootNode; private Choreographer mChoreographer; private boolean mRootNodeNeedsUpdate; private boolean mEnabled; Loading Loading @@ -425,8 +424,6 @@ public final class ThreadedRenderer { /** * Indicates whether threaded rendering is currently requested but not * necessarily enabled yet. * * @return True to request threaded rendering, false otherwise. */ void setRequested(boolean requested) { mRequested = requested; Loading Loading @@ -596,6 +593,13 @@ public final class ThreadedRenderer { nSetOpaque(mNativeProxy, opaque && !mHasInsets); } /** * Enable/disable wide gamut rendering on this renderer. */ void setWideGamut(boolean wideGamut) { nSetWideGamut(mNativeProxy, wideGamut); } /** * Gets the current width of the surface. This is the width that the surface * was last set to in a call to {@link #setup(int, int, View.AttachInfo, Rect)}. Loading Loading @@ -933,11 +937,11 @@ public final class ThreadedRenderer { if (mInitialized) return; mInitialized = true; mAppContext = context.getApplicationContext(); initSched(context, renderProxy); initSched(renderProxy); initGraphicsStats(); } private void initSched(Context context, long renderProxy) { private void initSched(long renderProxy) { try { int tid = nGetRenderThreadTid(renderProxy); ActivityManager.getService().setRenderThread(tid); Loading Loading @@ -1007,6 +1011,7 @@ public final class ThreadedRenderer { private static native void nSetLightCenter(long nativeProxy, float lightX, float lightY, float lightZ); private static native void nSetOpaque(long nativeProxy, boolean opaque); private static native void nSetWideGamut(long nativeProxy, boolean wideGamut); private static native int nSyncAndDrawFrame(long nativeProxy, long[] frameInfo, int size); private static native void nDestroy(long nativeProxy, long rootRenderNode); private static native void nRegisterAnimatingRenderNode(long rootRenderNode, long animatingNode); Loading
core/java/android/view/ViewRootImpl.java +5 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import android.app.ResourcesManager; import android.content.ClipData; import android.content.ClipDescription; import android.content.Context; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; Loading Loading @@ -960,8 +961,12 @@ public final class ViewRootImpl implements ViewParent, final boolean hasSurfaceInsets = insets.left != 0 || insets.right != 0 || insets.top != 0 || insets.bottom != 0; final boolean translucent = attrs.format != PixelFormat.OPAQUE || hasSurfaceInsets; final boolean wideGamut = attrs.getColorMode() == ActivityInfo.COLOR_MODE_WIDE_COLOR_GAMUT; mAttachInfo.mThreadedRenderer = ThreadedRenderer.create(mContext, translucent, attrs.getTitle().toString()); mAttachInfo.mThreadedRenderer.setWideGamut(wideGamut); if (mAttachInfo.mThreadedRenderer != null) { mAttachInfo.mHardwareAccelerated = mAttachInfo.mHardwareAccelerationRequested = true; Loading
core/java/android/view/WindowManager.java +9 −0 Original line number Diff line number Diff line Loading @@ -2090,6 +2090,7 @@ public interface WindowManager extends ViewManager { out.writeInt(needsMenuKey); out.writeInt(accessibilityIdOfAnchor); TextUtils.writeToParcel(accessibilityTitle, out, parcelableFlags); out.writeInt(mColorMode); out.writeLong(hideTimeoutMilliseconds); } Loading Loading @@ -2144,6 +2145,7 @@ public interface WindowManager extends ViewManager { needsMenuKey = in.readInt(); accessibilityIdOfAnchor = in.readInt(); accessibilityTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); mColorMode = in.readInt(); hideTimeoutMilliseconds = in.readLong(); } Loading Loading @@ -2189,6 +2191,8 @@ public interface WindowManager extends ViewManager { @TestApi public static final int ACCESSIBILITY_TITLE_CHANGED = 1 << 25; /** {@hide} */ public static final int COLOR_MODE_CHANGED = 1 << 26; /** {@hide} */ public static final int EVERYTHING_CHANGED = 0xffffffff; // internal buffer to backup/restore parameters under compatibility mode. Loading Loading @@ -2366,6 +2370,11 @@ public interface WindowManager extends ViewManager { changes |= ACCESSIBILITY_TITLE_CHANGED; } if (mColorMode != o.mColorMode) { mColorMode = o.mColorMode; changes |= COLOR_MODE_CHANGED; } // This can't change, it's only set at window creation time. hideTimeoutMilliseconds = o.hideTimeoutMilliseconds; Loading
core/jni/android_view_SurfaceControl.cpp +10 −1 Original line number Diff line number Diff line Loading @@ -221,11 +221,20 @@ static jobject nativeScreenshotBitmap(JNIEnv* env, jclass clazz, return NULL; } } sk_sp<SkColorSpace> colorSpace; if (screenshot->getDataSpace() == HAL_DATASPACE_DISPLAY_P3) { colorSpace = SkColorSpace::MakeRGB( SkColorSpace::kSRGB_RenderTargetGamma, SkColorSpace::kDCIP3_D65_Gamut); } else { colorSpace = SkColorSpace::MakeSRGB(); } SkImageInfo screenshotInfo = SkImageInfo::Make(screenshot->getWidth(), screenshot->getHeight(), colorType, alphaType, GraphicsJNI::defaultColorSpace()); colorSpace); const size_t rowBytes = screenshot->getStride() * android::bytesPerPixel(screenshot->getFormat()); Loading