Add raster side dark mode switch and initial functionality.
This patch adds enable-raster-side-dark-mode-for-images switch to
enable raster side dark mode for images and initial functionality
to enable RSDM for bitmap images. PaintFlags will carry the
|use_dark_mode_for_image_| bit for specifying whether the
compositor should use a dark mode filter when rasterizing images.
Bug: 1094005
Change-Id: I424c9397235733fb07df4f1cad7bb758399fded9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2445890
Reviewed-by: Philip Rogers <pdr@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Kent Tamura <tkent@chromium.org>
Reviewed-by: Khushal <khushalsagar@chromium.org>
Commit-Queue: Prashant Nevase <prashant.n@samsung.com>
Cr-Commit-Position: refs/heads/master@{#814106}
This commit is contained in:

committed by
Commit Bot

parent
198b6770b0
commit
6cb7c14c7e
cc/paint
chrome/browser/chromeos/login
content/browser/renderer_host
third_party/blink
@@ -62,6 +62,12 @@ class CC_PAINT_EXPORT PaintFlags {
|
|||||||
ALWAYS_INLINE SkFilterQuality getFilterQuality() const {
|
ALWAYS_INLINE SkFilterQuality getFilterQuality() const {
|
||||||
return static_cast<SkFilterQuality>(bitfields_.filter_quality_);
|
return static_cast<SkFilterQuality>(bitfields_.filter_quality_);
|
||||||
}
|
}
|
||||||
|
ALWAYS_INLINE bool useDarkModeForImage() const {
|
||||||
|
return bitfields_.use_dark_mode_for_image_;
|
||||||
|
}
|
||||||
|
ALWAYS_INLINE void setUseDarkModeForImage(bool use_dark_mode_for_image) {
|
||||||
|
bitfields_.use_dark_mode_for_image_ = use_dark_mode_for_image;
|
||||||
|
}
|
||||||
ALWAYS_INLINE SkScalar getStrokeWidth() const { return width_; }
|
ALWAYS_INLINE SkScalar getStrokeWidth() const { return width_; }
|
||||||
ALWAYS_INLINE void setStrokeWidth(SkScalar width) { width_ = width; }
|
ALWAYS_INLINE void setStrokeWidth(SkScalar width) { width_ = width; }
|
||||||
ALWAYS_INLINE SkScalar getStrokeMiter() const { return miter_limit_; }
|
ALWAYS_INLINE SkScalar getStrokeMiter() const { return miter_limit_; }
|
||||||
@@ -195,6 +201,9 @@ class CC_PAINT_EXPORT PaintFlags {
|
|||||||
uint32_t join_type_ : 2;
|
uint32_t join_type_ : 2;
|
||||||
uint32_t style_ : 2;
|
uint32_t style_ : 2;
|
||||||
uint32_t filter_quality_ : 2;
|
uint32_t filter_quality_ : 2;
|
||||||
|
// Specifies whether the compositor should use a dark mode filter when
|
||||||
|
// rasterizing image on the draw op with this PaintFlags.
|
||||||
|
uint32_t use_dark_mode_for_image_ : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
union {
|
union {
|
||||||
|
@@ -172,6 +172,7 @@ void DeriveCommandLine(const GURL& start_url,
|
|||||||
blink::switches::kEnableLowResTiling,
|
blink::switches::kEnableLowResTiling,
|
||||||
blink::switches::kEnablePreferCompositingToLCDText,
|
blink::switches::kEnablePreferCompositingToLCDText,
|
||||||
blink::switches::kEnableRGBA4444Textures,
|
blink::switches::kEnableRGBA4444Textures,
|
||||||
|
blink::switches::kEnableRasterSideDarkModeForImages,
|
||||||
blink::switches::kEnableZeroCopy,
|
blink::switches::kEnableZeroCopy,
|
||||||
blink::switches::kGpuRasterizationMSAASampleCount,
|
blink::switches::kGpuRasterizationMSAASampleCount,
|
||||||
chromeos::switches::kDefaultWallpaperLarge,
|
chromeos::switches::kDefaultWallpaperLarge,
|
||||||
|
@@ -3423,6 +3423,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
|
|||||||
blink::switches::kEnableLowResTiling,
|
blink::switches::kEnableLowResTiling,
|
||||||
blink::switches::kEnablePreferCompositingToLCDText,
|
blink::switches::kEnablePreferCompositingToLCDText,
|
||||||
blink::switches::kEnableRGBA4444Textures,
|
blink::switches::kEnableRGBA4444Textures,
|
||||||
|
blink::switches::kEnableRasterSideDarkModeForImages,
|
||||||
blink::switches::kMinHeightForGpuRasterTile,
|
blink::switches::kMinHeightForGpuRasterTile,
|
||||||
blink::switches::kMaxUntiledLayerWidth,
|
blink::switches::kMaxUntiledLayerWidth,
|
||||||
blink::switches::kMaxUntiledLayerHeight,
|
blink::switches::kMaxUntiledLayerHeight,
|
||||||
|
4
third_party/blink/common/switches.cc
vendored
4
third_party/blink/common/switches.cc
vendored
@@ -77,6 +77,10 @@ const char kEnablePreferCompositingToLCDText[] =
|
|||||||
// Enables RGBA_4444 textures.
|
// Enables RGBA_4444 textures.
|
||||||
const char kEnableRGBA4444Textures[] = "enable-rgba-4444-textures";
|
const char kEnableRGBA4444Textures[] = "enable-rgba-4444-textures";
|
||||||
|
|
||||||
|
// Enables raster side dark mode for images.
|
||||||
|
const char kEnableRasterSideDarkModeForImages[] =
|
||||||
|
"enable-raster-side-dark-mode-for-images";
|
||||||
|
|
||||||
// Enable rasterizer that writes directly to GPU memory associated with tiles.
|
// Enable rasterizer that writes directly to GPU memory associated with tiles.
|
||||||
const char kEnableZeroCopy[] = "enable-zero-copy";
|
const char kEnableZeroCopy[] = "enable-zero-copy";
|
||||||
|
|
||||||
|
1
third_party/blink/public/common/switches.h
vendored
1
third_party/blink/public/common/switches.h
vendored
@@ -31,6 +31,7 @@ BLINK_COMMON_EXPORT extern const char
|
|||||||
BLINK_COMMON_EXPORT extern const char kEnableLowResTiling[];
|
BLINK_COMMON_EXPORT extern const char kEnableLowResTiling[];
|
||||||
BLINK_COMMON_EXPORT extern const char kEnablePreferCompositingToLCDText[];
|
BLINK_COMMON_EXPORT extern const char kEnablePreferCompositingToLCDText[];
|
||||||
BLINK_COMMON_EXPORT extern const char kEnableRGBA4444Textures[];
|
BLINK_COMMON_EXPORT extern const char kEnableRGBA4444Textures[];
|
||||||
|
BLINK_COMMON_EXPORT extern const char kEnableRasterSideDarkModeForImages[];
|
||||||
BLINK_COMMON_EXPORT extern const char kEnableZeroCopy[];
|
BLINK_COMMON_EXPORT extern const char kEnableZeroCopy[];
|
||||||
BLINK_COMMON_EXPORT extern const char kForceLegacyDefaultReferrerPolicy[];
|
BLINK_COMMON_EXPORT extern const char kForceLegacyDefaultReferrerPolicy[];
|
||||||
BLINK_COMMON_EXPORT extern const char kGpuRasterizationMSAASampleCount[];
|
BLINK_COMMON_EXPORT extern const char kGpuRasterizationMSAASampleCount[];
|
||||||
|
@@ -4,13 +4,23 @@
|
|||||||
|
|
||||||
#include "third_party/blink/renderer/platform/graphics/dark_mode_filter_helper.h"
|
#include "third_party/blink/renderer/platform/graphics/dark_mode_filter_helper.h"
|
||||||
|
|
||||||
|
#include "base/command_line.h"
|
||||||
#include "base/hash/hash.h"
|
#include "base/hash/hash.h"
|
||||||
|
#include "third_party/blink/public/common/switches.h"
|
||||||
#include "third_party/blink/renderer/platform/graphics/dark_mode_image_cache.h"
|
#include "third_party/blink/renderer/platform/graphics/dark_mode_image_cache.h"
|
||||||
#include "third_party/blink/renderer/platform/graphics/graphics_context.h"
|
#include "third_party/blink/renderer/platform/graphics/graphics_context.h"
|
||||||
#include "third_party/blink/renderer/platform/graphics/image.h"
|
#include "third_party/blink/renderer/platform/graphics/image.h"
|
||||||
|
|
||||||
namespace blink {
|
namespace blink {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
bool IsRasterSideDarkModeForImagesEnabled() {
|
||||||
|
static bool enabled = base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||||
|
switches::kEnableRasterSideDarkModeForImages);
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
// static
|
// static
|
||||||
SkColor DarkModeFilterHelper::ApplyToColorIfNeeded(
|
SkColor DarkModeFilterHelper::ApplyToColorIfNeeded(
|
||||||
GraphicsContext* context,
|
GraphicsContext* context,
|
||||||
@@ -38,6 +48,13 @@ void DarkModeFilterHelper::ApplyToImageIfNeeded(GraphicsContext* context,
|
|||||||
if (!context->IsDarkModeEnabled())
|
if (!context->IsDarkModeEnabled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// For RSDM, just set the dark mode on flags and rest will be taken care at
|
||||||
|
// compositor side.
|
||||||
|
if (image->IsBitmapImage() && IsRasterSideDarkModeForImagesEnabled()) {
|
||||||
|
flags->setUseDarkModeForImage(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SkIRect rounded_src = src.roundOut();
|
SkIRect rounded_src = src.roundOut();
|
||||||
SkIRect rounded_dst = dst.roundOut();
|
SkIRect rounded_dst = dst.roundOut();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user