0

Reland "Move Skia SkFontLCDConfig globals to Chromium"

This is a reland of 78b97c899e

Also updated the tsan_suppressions.cc file with the updated names of the
globals that were moved.

Original change's description:
> Move Skia SkFontLCDConfig globals to Chromium
>
> This change eliminates the usage of the deprecated SkFontLCDConfig,
> which stores font-related monitor properties in some global variables.
> Chromium is the only client of this deprecated API, and the Skia team
> has wanted to remove it for some time.
>
> Unfortunately, the use is fairly widespread within Chromium:
> 1. The globals are set directly in a handful of places via calls to
>    SkFontLCDConfig functions.
> 2. The globals are used (indirectly) whenever an SkSurfaceProps is
>    initialized with the kLegacyFontHost_InitType flag, and also when
>    an SkCanvas or SkSurface are created without specifying the props.
>
> The correct long-term plan would be to retrieve the values from the
> Display (ideally per-monitor values) and pass them along as needed.
> But given the extensive usage, the only reasonable short-term approach
> is to lift the globals out of Skia and bring them "in-house" into
> Chromium.
>
> To that end:
> -- Undefines SK_LEGACY_SURFACE_PROPS.
> -- New globals and APIs in /skia/ext/legacy_display_globals.*
> -- Replaced "SkSurfaceProps(kLegacyFontHost_InitType)" with calls to
>    new API:  skia::LegacyDisplayGlobals::GetSkSurfaceProps()
> -- Found places where SkCanvas and SkSurface were created and props
>    weren't already specified; passing the LegacyDisplayGlobals in most
>    cases, but `nullptr` (or empty SkSurfaceProps) if it was clear
>    without doing much analysis that no text was being drawn.
>
> This gets us closer to the end-goal by allowing Skia to fully remove
> the deprecated APIs, and also surfacing a lot of places where the use
> of the globals was hidden by indirect usage.
>
> Change-Id: I8fffaee4933c03ee828d2ffab858f53d92c59f4d
> Bug: 1126992, skia:3934
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2378763
> Reviewed-by: Scott Violet <sky@chromium.org>
> Reviewed-by: Ben Wagner <bungeman@chromium.org>
> Reviewed-by: Michael Spang <spang@chromium.org>
> Commit-Queue: Ian Prest <iapres@microsoft.com>
> Cr-Commit-Position: refs/heads/master@{#818197}

TBR=sky@chromium.org

Bug: 1126992, 328826, skia:3934
Change-Id: I8911a67cb8a9d4079b993feaff29ff8abd02dd94
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2486073
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Ian Prest <iapres@microsoft.com>
Commit-Queue: Ian Prest <iapres@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#818688}
This commit is contained in:
Ian Prest
2020-10-19 23:31:02 +00:00
committed by Commit Bot
parent 91fb74f534
commit e598eece8a
97 changed files with 322 additions and 247 deletions
build/sanitizers
cc
chrome
components
content
extensions/common
gpu
media
printing
services/image_annotation/public/cpp
skia
third_party/blink/renderer
ui

@ -68,8 +68,7 @@ char kTSanDefaultSuppressions[] =
"deadlock:cc::VideoLayerImpl::WillDraw\n"
// http://crbug.com/328826
"race:gLCDOrder\n"
"race:gLCDOrientation\n"
"race:skia::(anonymous namespace)::g_pixel_geometry\n"
// http://crbug.com/328868
"race:PR_Lock\n"

@ -18,6 +18,7 @@
#include "cc/raster/raster_buffer_provider.h"
#include "cc/trees/layer_tree_host_impl.h"
#include "cc/trees/layer_tree_impl.h"
#include "skia/ext/legacy_display_globals.h"
#include "ui/gfx/geometry/axis_transform2d.h"
#include "ui/gfx/geometry/rect.h"
@ -56,7 +57,7 @@ void RunBenchmark(RasterSource* raster_source,
SkBitmap bitmap;
bitmap.allocPixels(SkImageInfo::MakeN32Premul(content_rect.width(),
content_rect.height()));
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, skia::LegacyDisplayGlobals::GetSkSurfaceProps());
// Pass an empty settings to make sure that the decode cache is used to
// replace all images.

@ -47,6 +47,7 @@
#include "gpu/command_buffer/common/shared_image_trace_utils.h"
#include "gpu/command_buffer/common/shared_image_usage.h"
#include "gpu/config/gpu_feature_info.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/khronos/GLES2/gl2.h"
#include "third_party/khronos/GLES2/gl2ext.h"
#include "third_party/skia/include/core/SkFont.h"
@ -368,7 +369,9 @@ void HeadsUpDisplayLayerImpl::UpdateHudTexture(
context_provider->GrContext(),
pool_resource.color_space().ToSkColorSpace(), mailbox_texture_id,
backing->texture_target, pool_resource.size(),
pool_resource.format(), false /* can_use_lcd_text */,
pool_resource.format(),
skia::LegacyDisplayGlobals::ComputeSurfaceProps(
false /* can_use_lcd_text */),
0 /* msaa_sample_count */);
SkSurface* surface = scoped_surface.surface();
if (!surface) {
@ -395,8 +398,9 @@ void HeadsUpDisplayLayerImpl::UpdateHudTexture(
if (!staging_surface_ ||
gfx::SkISizeToSize(staging_surface_->getCanvas()->getBaseLayerSize()) !=
pool_resource.size()) {
SkSurfaceProps props = skia::LegacyDisplayGlobals::GetSkSurfaceProps();
staging_surface_ = SkSurface::MakeRasterN32Premul(
pool_resource.size().width(), pool_resource.size().height());
pool_resource.size().width(), pool_resource.size().height(), &props);
}
SkiaPaintCanvas canvas(staging_surface_->getCanvas());
@ -435,8 +439,9 @@ void HeadsUpDisplayLayerImpl::UpdateHudTexture(
pool_resource.size().width(), pool_resource.size().height());
auto* backing =
static_cast<HudSoftwareBacking*>(pool_resource.software_backing());
SkSurfaceProps props = skia::LegacyDisplayGlobals::GetSkSurfaceProps();
sk_sp<SkSurface> surface = SkSurface::MakeRasterDirect(
info, backing->shared_mapping.memory(), info.minRowBytes());
info, backing->shared_mapping.memory(), info.minRowBytes(), &props);
SkiaPaintCanvas canvas(surface->getCanvas());
DrawHudContents(&canvas);

@ -35,7 +35,6 @@
#include "gpu/skia_bindings/grcontext_for_gles2_interface.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/khronos/GLES2/gl2ext.h"
#include "third_party/skia/include/core/SkFontLCDConfig.h"
#include "third_party/skia/include/core/SkGraphics.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/GrBackendSurface.h"
@ -48,18 +47,6 @@
namespace cc {
namespace {
class ScopedEnableLCDText {
public:
ScopedEnableLCDText() {
order_ = SkFontLCDConfig::GetSubpixelOrder();
SkFontLCDConfig::SetSubpixelOrder(SkFontLCDConfig::kRGB_LCDOrder);
}
~ScopedEnableLCDText() { SkFontLCDConfig::SetSubpixelOrder(order_); }
private:
SkFontLCDConfig::LCDOrder order_;
};
scoped_refptr<DisplayItemList> MakeNoopDisplayItemList() {
auto display_item_list = base::MakeRefCounted<DisplayItemList>();
display_item_list->StartPaint();
@ -335,8 +322,7 @@ class OopPixelTest : public testing::Test,
uint32_t flags = 0;
SkSurfaceProps surface_props(flags, kUnknown_SkPixelGeometry);
if (options.use_lcd_text) {
surface_props =
SkSurfaceProps(flags, SkSurfaceProps::kLegacyFontHost_InitType);
surface_props = SkSurfaceProps(flags, kRGB_H_SkPixelGeometry);
}
SkImageInfo image_info = SkImageInfo::MakeN32Premul(
options.resource_size.width(), options.resource_size.height(),
@ -519,7 +505,7 @@ TEST_P(OopImagePixelTest, DrawImage) {
SkImageInfo::MakeN32Premul(image_size.width(), image_size.height()),
SkBitmap::kZeroPixels_AllocFlag);
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawColor(SK_ColorMAGENTA);
SkPaint green;
green.setColor(SK_ColorGREEN);
@ -558,7 +544,7 @@ TEST_P(OopImagePixelTest, DrawImageScaled) {
SkImageInfo::MakeN32Premul(image_size.width(), image_size.height()),
SkBitmap::kZeroPixels_AllocFlag);
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawColor(SK_ColorMAGENTA);
SkPaint green;
green.setColor(SK_ColorGREEN);
@ -595,7 +581,7 @@ TEST_P(OopImagePixelTest, DrawImageShaderScaled) {
SkImageInfo::MakeN32Premul(image_size.width(), image_size.height()),
SkBitmap::kZeroPixels_AllocFlag);
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawColor(SK_ColorMAGENTA);
SkPaint green;
green.setColor(SK_ColorGREEN);
@ -635,7 +621,7 @@ TEST_P(OopImagePixelTest, DrawRecordShaderWithImageScaled) {
SkImageInfo::MakeN32Premul(image_size.width(), image_size.height()),
SkBitmap::kZeroPixels_AllocFlag);
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawColor(SK_ColorMAGENTA);
SkPaint green;
green.setColor(SK_ColorGREEN);
@ -727,7 +713,7 @@ TEST_P(OopImagePixelTest, DrawImageWithTargetColorSpace) {
SkImageInfo::MakeN32Premul(image_size.width(), image_size.height()),
SkBitmap::kZeroPixels_AllocFlag);
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawColor(SK_ColorMAGENTA);
SkPaint green;
green.setColor(SK_ColorGREEN);
@ -772,7 +758,7 @@ TEST_P(OopImagePixelTest, DrawImageWithSourceColorSpace) {
color_space),
SkBitmap::kZeroPixels_AllocFlag);
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawColor(SK_ColorMAGENTA);
SkPaint green;
green.setColor(SK_ColorGREEN);
@ -817,7 +803,7 @@ TEST_P(OopImagePixelTest, DrawImageWithSourceAndTargetColorSpace) {
color_space),
SkBitmap::kZeroPixels_AllocFlag);
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawColor(SK_ColorMAGENTA);
SkPaint green;
green.setColor(SK_ColorGREEN);
@ -858,7 +844,7 @@ TEST_P(OopImagePixelTest, DrawImageWithSetMatrix) {
SkImageInfo::MakeN32Premul(image_size.width(), image_size.height()),
SkBitmap::kZeroPixels_AllocFlag);
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawColor(SK_ColorMAGENTA);
SkPaint green;
green.setColor(SK_ColorGREEN);
@ -920,7 +906,7 @@ TEST_F(OopPixelTest, DrawMailboxBackedImage) {
SkBitmap expected_bitmap;
expected_bitmap.allocPixels(backing_info);
SkCanvas canvas(expected_bitmap);
SkCanvas canvas(expected_bitmap, SkSurfaceProps{});
canvas.drawColor(SK_ColorMAGENTA);
SkPaint green;
green.setColor(SK_ColorGREEN);
@ -1014,7 +1000,7 @@ TEST_P(OopClearPixelTest, ClearingOpaqueCorner) {
options.resource_size.height()),
SkBitmap::kZeroPixels_AllocFlag);
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawColor(options.preclear_color);
SkPaint green;
green.setColor(options.background_color);
@ -1065,7 +1051,7 @@ TEST_F(OopPixelTest, ClearingOpaqueCornerExactEdge) {
SkBitmap::kZeroPixels_AllocFlag);
// Expect a one pixel border on the bottom/right edge.
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawColor(options.preclear_color);
SkPaint green;
green.setColor(options.background_color);
@ -1110,7 +1096,7 @@ TEST_F(OopPixelTest, ClearingOpaqueCornerPartialRaster) {
SkBitmap::kZeroPixels_AllocFlag);
// Expect no clearing here because the playback rect is internal.
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawColor(options.preclear_color);
ExpectEquals(oop_result, bitmap, "oop");
@ -1156,7 +1142,7 @@ TEST_P(OopClearPixelTest, ClearingOpaqueLeftEdge) {
options.resource_size.height()),
SkBitmap::kZeroPixels_AllocFlag);
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawColor(options.preclear_color);
SkPaint green;
green.setColor(options.background_color);
@ -1213,7 +1199,7 @@ TEST_P(OopClearPixelTest, ClearingOpaqueRightEdge) {
options.resource_size.height()),
SkBitmap::kZeroPixels_AllocFlag);
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawColor(options.preclear_color);
SkPaint green;
green.setColor(options.background_color);
@ -1269,7 +1255,7 @@ TEST_P(OopClearPixelTest, ClearingOpaqueTopEdge) {
options.resource_size.height()),
SkBitmap::kZeroPixels_AllocFlag);
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawColor(options.preclear_color);
SkPaint green;
green.setColor(options.background_color);
@ -1327,7 +1313,7 @@ TEST_P(OopClearPixelTest, ClearingOpaqueBottomEdge) {
options.resource_size.height()),
SkBitmap::kZeroPixels_AllocFlag);
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawColor(options.preclear_color);
SkPaint green;
green.setColor(options.background_color);
@ -1377,7 +1363,7 @@ TEST_F(OopPixelTest, ClearingOpaqueInternal) {
// Expect no clears here, as this tile does not intersect the edge of the
// tile.
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawColor(options.preclear_color);
ExpectEquals(oop_result, bitmap, "oop");
@ -1413,7 +1399,7 @@ TEST_F(OopPixelTest, ClearingTransparentCorner) {
options.resource_size.height()),
SkBitmap::kZeroPixels_AllocFlag);
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawColor(SK_ColorTRANSPARENT);
ExpectEquals(oop_result, bitmap, "oop");
@ -1453,7 +1439,7 @@ TEST_F(OopPixelTest, ClearingTransparentInternalTile) {
options.resource_size.height()),
SkBitmap::kZeroPixels_AllocFlag);
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawColor(SK_ColorTRANSPARENT);
ExpectEquals(oop_result, bitmap, "oop");
@ -1490,7 +1476,7 @@ TEST_F(OopPixelTest, ClearingTransparentCornerPartialRaster) {
// Result should be a red background with a cleared hole where the
// playback_rect is.
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawColor(options.preclear_color);
canvas.translate(-arbitrary_offset.x(), -arbitrary_offset.y());
canvas.clipRect(gfx::RectToSkRect(options.playback_rect));
@ -1709,8 +1695,6 @@ class OopRecordShaderPixelTest : public OopPixelTest,
public:
bool UseLcdText() const { return GetParam(); }
void RunTest() {
ScopedEnableLCDText enable_lcd;
RasterOptions options;
options.resource_size = gfx::Size(100, 100);
options.content_size = options.resource_size;
@ -1753,8 +1737,6 @@ class OopRecordFilterPixelTest : public OopPixelTest,
public:
bool UseLcdText() const { return GetParam(); }
void RunTest(const SkMatrix& mat) {
ScopedEnableLCDText enable_lcd;
RasterOptions options;
options.resource_size = gfx::Size(100, 100);
options.content_size = options.resource_size;
@ -2006,7 +1988,7 @@ TEST_F(OopPixelTest, ReadbackImagePixels) {
SkBitmap expected_bitmap;
expected_bitmap.allocPixels(dest_info);
SkCanvas canvas(expected_bitmap);
SkCanvas canvas(expected_bitmap, SkSurfaceProps{});
canvas.drawColor(SK_ColorMAGENTA);
SkPaint green;
green.setColor(SK_ColorGREEN);

@ -2760,7 +2760,7 @@ void PaintOpBuffer::Playback(SkCanvas* canvas,
!has_effects_preventing_lcd_text_for_save_layer_alpha_;
if (save_layer_alpha_should_preserve_lcd_text) {
// Check if the canvas supports LCD text.
SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
SkSurfaceProps props;
canvas->getProps(&props);
if (props.pixelGeometry() == kUnknown_SkPixelGeometry)
save_layer_alpha_should_preserve_lcd_text = false;

@ -13,6 +13,7 @@
#include "base/trace_event/trace_event.h"
#include "cc/paint/clear_for_opaque_raster.h"
#include "cc/paint/scoped_raster_flags.h"
#include "skia/ext/legacy_display_globals.h"
#include "ui/gfx/skia_util.h"
namespace cc {
@ -31,19 +32,6 @@ class ScopedFlagsOverride {
PaintOp::SerializeOptions* options_;
};
// Copied from viz::ClientResourceProvider.
SkSurfaceProps ComputeSurfaceProps(bool can_use_lcd_text) {
uint32_t flags = 0;
// Use unknown pixel geometry to disable LCD text.
SkSurfaceProps surface_props(flags, kUnknown_SkPixelGeometry);
if (can_use_lcd_text) {
// LegacyFontHost will get LCD text and skia figures out what type to use.
surface_props =
SkSurfaceProps(flags, SkSurfaceProps::kLegacyFontHost_InitType);
}
return surface_props;
}
PlaybackParams MakeParams(const SkCanvas* canvas) {
// We don't use an ImageProvider here since the ops are played onto a no-draw
// canvas for state tracking and don't need decoded images.
@ -81,7 +69,8 @@ PaintOpBufferSerializer::PaintOpBufferSerializer(
? std::make_unique<SkTextBlobCacheDiffCanvas>(
kMaxExtent,
kMaxExtent,
ComputeSurfaceProps(can_use_lcd_text),
skia::LegacyDisplayGlobals::ComputeSurfaceProps(
can_use_lcd_text),
strike_server,
std::move(color_space),
context_supports_distance_field_text)

@ -8,6 +8,7 @@
#include "cc/paint/display_item_list.h"
#include "cc/paint/paint_recorder.h"
#include "cc/paint/scoped_raster_flags.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/skia/include/core/SkAnnotation.h"
#include "third_party/skia/include/docs/SkPDFDocument.h"
@ -24,7 +25,8 @@ SkiaPaintCanvas::SkiaPaintCanvas(SkCanvas* canvas,
SkiaPaintCanvas::SkiaPaintCanvas(const SkBitmap& bitmap,
ImageProvider* image_provider)
: canvas_(new SkCanvas(bitmap)),
: canvas_(new SkCanvas(bitmap,
skia::LegacyDisplayGlobals::GetSkSurfaceProps())),
bitmap_(bitmap),
owned_(canvas_),
image_provider_(image_provider) {}

@ -34,6 +34,7 @@
#include "gpu/command_buffer/client/shared_image_interface.h"
#include "gpu/command_buffer/common/shared_image_trace_utils.h"
#include "gpu/command_buffer/common/shared_image_usage.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/skia/include/core/SkPictureRecorder.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
@ -79,8 +80,7 @@ class ScopedSkSurfaceForUnpremultiplyAndDither {
intermediate_size.height(),
std::move(color_space));
SkSurfaceProps surface_props =
viz::ClientResourceProvider::ScopedSkSurface::ComputeSurfaceProps(
can_use_lcd_text);
skia::LegacyDisplayGlobals::ComputeSurfaceProps(can_use_lcd_text);
surface_ = SkSurface::MakeRenderTarget(
context_provider->GrContext(), SkBudgeted::kNo, n32Info,
msaa_sample_count, kTopLeft_GrSurfaceOrigin, &surface_props);
@ -218,7 +218,9 @@ static void RasterizeSource(
if (!unpremultiply_and_dither) {
scoped_surface.emplace(context_provider->GrContext(), sk_color_space,
texture_id, texture_target, resource_size,
resource_format, playback_settings.use_lcd_text,
resource_format,
skia::LegacyDisplayGlobals::ComputeSurfaceProps(
playback_settings.use_lcd_text),
playback_settings.msaa_sample_count);
surface = scoped_surface->surface();
} else {

@ -10,6 +10,7 @@
#include "cc/raster/raster_source.h"
#include "components/viz/common/resources/platform_color.h"
#include "components/viz/common/resources/resource_format_utils.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkMath.h"
#include "third_party/skia/include/core/SkSurface.h"
@ -83,8 +84,7 @@ void RasterBufferProvider::PlaybackToMemory(
// Use unknown pixel geometry to disable LCD text.
SkSurfaceProps surface_props(0, kUnknown_SkPixelGeometry);
if (playback_settings.use_lcd_text) {
// LegacyFontHost will get LCD text and skia figures out what type to use.
surface_props = SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType);
surface_props = skia::LegacyDisplayGlobals::GetSkSurfaceProps();
}
if (!stride)
@ -121,7 +121,8 @@ void RasterBufferProvider::PlaybackToMemory(
"RasterBufferProvider::PlaybackToMemory::ConvertRGBA4444");
SkImageInfo dst_info = info.makeColorType(
ResourceFormatToClosestSkColorType(gpu_compositing, format));
auto dst_canvas = SkCanvas::MakeRasterDirect(dst_info, memory, stride);
auto dst_canvas =
SkCanvas::MakeRasterDirect(dst_info, memory, stride, &surface_props);
DCHECK(dst_canvas);
SkPaint paint;
paint.setDither(true);

@ -300,7 +300,7 @@ TEST(RasterSourceTest, RasterFullContents) {
SkBitmap bitmap;
bitmap.allocN32Pixels(canvas_rect.width(), canvas_rect.height());
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.clear(SK_ColorTRANSPARENT);
raster->PlaybackToCanvas(
@ -361,7 +361,7 @@ TEST(RasterSourceTest, RasterFullContentsWithRasterTranslation) {
SkBitmap bitmap;
bitmap.allocN32Pixels(canvas_rect.width(), canvas_rect.height());
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.clear(SK_ColorTRANSPARENT);
raster->PlaybackToCanvas(
@ -408,7 +408,7 @@ TEST(RasterSourceTest, RasterPartialContents) {
SkBitmap bitmap;
bitmap.allocN32Pixels(content_bounds.width(), content_bounds.height());
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.clear(SK_ColorTRANSPARENT);
// Playback the full rect which should make everything white.
@ -482,7 +482,7 @@ TEST(RasterSourceTest, RasterPartialContentsWithRasterTranslation) {
SkBitmap bitmap;
bitmap.allocN32Pixels(content_bounds.width(), content_bounds.height());
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.clear(SK_ColorTRANSPARENT);
// Playback the full rect which should make everything white.
@ -576,7 +576,7 @@ TEST(RasterSourceTest, RasterPartialClear) {
SkBitmap bitmap;
bitmap.allocN32Pixels(content_bounds.width(), content_bounds.height());
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.clear(SK_ColorTRANSPARENT);
// Playback the full rect which should make everything light gray (alpha=10).
@ -645,7 +645,7 @@ TEST(RasterSourceTest, RasterContentsTransparent) {
SkBitmap bitmap;
bitmap.allocN32Pixels(canvas_rect.width(), canvas_rect.height());
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
raster->PlaybackToCanvas(
&canvas, content_bounds, canvas_rect, canvas_rect,

@ -59,7 +59,7 @@ void DrawDisplayList(unsigned char* buffer,
SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height());
SkBitmap bitmap;
bitmap.installPixels(info, buffer, info.minRowBytes());
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.clipRect(gfx::RectToSkRect(layer_rect));
list->Raster(&canvas);
}

@ -202,7 +202,7 @@ class LayerTreeHostBlendingPixelTest
SkBitmap expected;
expected.allocN32Pixels(width, height);
SkCanvas canvas(expected);
SkCanvas canvas(expected, SkSurfaceProps{});
canvas.clear(SK_ColorWHITE);
canvas.drawImage(surface->makeImageSnapshot(), 0, 0);
@ -306,7 +306,7 @@ TEST_P(LayerTreeHostBlendingPixelTest, BlendingWithRoot) {
SkBitmap expected;
expected.allocN32Pixels(kRootWidth, kRootHeight);
SkCanvas canvas(expected);
SkCanvas canvas(expected, SkSurfaceProps{});
canvas.drawColor(kCSSOrange);
SkPaint paint;
paint.setBlendMode(current_blend_mode());
@ -337,7 +337,7 @@ TEST_P(LayerTreeHostBlendingPixelTest, BlendingWithBackdropFilter) {
SkBitmap expected;
expected.allocN32Pixels(kRootWidth, kRootHeight);
SkCanvas canvas(expected);
SkCanvas canvas(expected, SkSurfaceProps{});
SkiaPaintCanvas paint_canvas(&canvas);
PaintFlags grayscale;
grayscale.setColor(kCSSOrange);
@ -379,7 +379,7 @@ TEST_P(LayerTreeHostBlendingPixelTest, BlendingWithTransparent) {
SkBitmap expected;
expected.allocN32Pixels(kRootWidth, kRootHeight);
SkCanvas canvas(expected);
SkCanvas canvas(expected, SkSurfaceProps{});
canvas.drawColor(kCSSOrange);
SkPaint paint;
paint.setBlendMode(current_blend_mode());

@ -20,6 +20,7 @@
#include "media/base/video_frame.h"
#include "media/capture/mojom/video_capture_types.mojom.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/blink/public/common/input/web_input_event.h"
#include "third_party/blink/public/common/input/web_mouse_event.h"
#include "third_party/skia/include/core/SkCanvas.h"
@ -184,7 +185,7 @@ void DevToolsEyeDropper::UpdateCursor() {
kCursorSize * device_scale_factor);
result.eraseARGB(0, 0, 0, 0);
SkCanvas canvas(result);
SkCanvas canvas(result, skia::LegacyDisplayGlobals::GetSkSurfaceProps());
canvas.scale(device_scale_factor, device_scale_factor);
canvas.translate(0.5f, 0.5f);

@ -38,7 +38,7 @@ gfx::ImageSkia CreateEnclosedFaviconImage(gfx::Size size,
// Create a bitmap.
SkBitmap result;
result.allocN32Pixels(size.width(), size.height(), false);
SkCanvas canvas(result);
SkCanvas canvas(result, SkSurfaceProps{});
canvas.clear(SK_ColorTRANSPARENT);
// Draw the favicon image into the center of result image. If the favicon is

@ -760,7 +760,7 @@ SkBitmap GetBadgedWinIconBitmapForAvatar(const SkBitmap& app_icon_bitmap,
SkBitmap badged_bitmap;
badged_bitmap.allocN32Pixels(app_icon_bitmap.width(),
app_icon_bitmap.height());
SkCanvas offscreen_canvas(badged_bitmap);
SkCanvas offscreen_canvas(badged_bitmap, SkSurfaceProps{});
offscreen_canvas.clear(SK_ColorTRANSPARENT);
offscreen_canvas.drawBitmap(app_icon_bitmap, 0, 0);

@ -23,6 +23,7 @@
#include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "skia/ext/image_operations.h"
#include "skia/ext/legacy_display_globals.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h"
@ -79,7 +80,7 @@ void SetOverlayIcon(HWND hwnd,
// way profile icons are rendered in the profile switcher.
SkBitmap offscreen_bitmap;
offscreen_bitmap.allocN32Pixels(kOverlayIconSize, kOverlayIconSize);
SkCanvas offscreen_canvas(offscreen_bitmap);
SkCanvas offscreen_canvas(offscreen_bitmap, SkSurfaceProps{});
offscreen_canvas.clear(SK_ColorTRANSPARENT);
static const SkRRect overlay_icon_clip =
@ -131,7 +132,8 @@ void DrawTaskbarDecorationString(gfx::NativeWindow window,
auto badge = std::make_unique<SkBitmap>();
badge->allocN32Pixels(kOverlayIconSize, kOverlayIconSize);
SkCanvas canvas(*badge.get());
SkCanvas canvas(*badge.get(),
skia::LegacyDisplayGlobals::GetSkSurfaceProps());
SkPaint paint;
paint.setAntiAlias(true);

@ -364,7 +364,7 @@ SkBitmap CreateLowQualityResizedBitmap(const SkBitmap& source_bitmap,
SkBitmap scaled_bitmap;
scaled_bitmap.allocN32Pixels(scaled_size.width(), scaled_size.height());
scaled_bitmap.eraseARGB(0, 0, 0, 0);
SkCanvas canvas(scaled_bitmap);
SkCanvas canvas(scaled_bitmap, SkSurfaceProps{});
SkRect scaled_bounds = RectToSkRect(gfx::Rect(scaled_size));
// Note(oshima): The following scaling code doesn't work with
// a mask image.

@ -51,7 +51,7 @@ SkBitmap GetGAIAPictureForNTP(const gfx::Image& image) {
const int kLength = 27;
SkBitmap bmp = skia::ImageOperations::Resize(*image.ToSkBitmap(),
skia::ImageOperations::RESIZE_BEST, kLength, kLength);
SkCanvas canvas(bmp);
SkCanvas canvas(bmp, SkSurfaceProps{});
// Draw a gray border on the inside of the icon.
SkPaint paint;

@ -40,7 +40,7 @@ void QRCodeGeneratorServiceImpl::InitializeDinoBitmap() {
dino_bitmap_.allocN32Pixels(dino_image::kDinoWidth, dino_image::kDinoHeight);
dino_bitmap_.eraseARGB(0xFF, 0xFF, 0xFF, 0xFF);
SkCanvas canvas(dino_bitmap_);
SkCanvas canvas(dino_bitmap_, SkSurfaceProps{});
SkPaint paint;
paint.setColor(SK_ColorBLACK);
@ -176,7 +176,7 @@ void QRCodeGeneratorServiceImpl::RenderBitmap(
bitmap.allocN32Pixels(data_size.width() * kModuleSizePixels,
data_size.height() * kModuleSizePixels);
bitmap.eraseARGB(0xFF, 0xFF, 0xFF, 0xFF);
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
SkPaint paint_black;
paint_black.setColor(SK_ColorBLACK);
SkPaint paint_white;

@ -16,6 +16,7 @@ include_rules = [
"+net/base",
"+services/data_decoder/public/cpp",
"+services/viz/privileged/mojom/compositing/vsync_parameter_observer.mojom.h",
"+skia/ext",
"+third_party/blink/public/common",
"+third_party/khronos",
"+third_party/skia",

@ -32,6 +32,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/unguessable_token.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "third_party/skia/include/core/SkSurface.h"
@ -884,10 +885,11 @@ std::unique_ptr<ClientBase::Buffer> ClientBase::CreateBuffer(
return nullptr;
}
SkSurfaceProps props = skia::LegacyDisplayGlobals::GetSkSurfaceProps();
buffer->sk_surface = SkSurface::MakeRasterDirect(
SkImageInfo::Make(size.width(), size.height(), kColorType,
kOpaque_SkAlphaType),
mapped_data, stride);
mapped_data, stride, &props);
DCHECK(buffer->sk_surface);
}

@ -127,7 +127,7 @@ SkBitmap ResizeBitmapByDownsamplingIfPossible(
if (!best_bitmap.isOpaque())
bitmap.eraseARGB(0, 0, 0, 0);
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawBitmapRect(best_bitmap,
SkRect::MakeIWH(desired_size, desired_size), nullptr);
return bitmap;

@ -43,7 +43,7 @@ SkBitmap SampleNearestNeighbor(const SkBitmap& contents, int desired_size) {
bitmap.eraseARGB(0, 0, 0, 0);
{
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawBitmapRect(contents, SkRect::MakeIWH(desired_size, desired_size),
nullptr);
}

@ -75,7 +75,7 @@ SkBitmap CreateBitmapFromPicture(const SkPicture* pic) {
SkBitmap bitmap;
bitmap.allocPixels(
SkImageInfo::MakeN32Premul(cull_rect.width(), cull_rect.height()));
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
SkMatrix matrix;
matrix.setScaleTranslate(1, 1, -cull_rect.x(), -cull_rect.y());
canvas.drawPicture(pic, &matrix, nullptr);

@ -138,7 +138,7 @@ TEST_F(PaintPreviewRecorderRenderViewTest, TestCaptureMainFrameAndClipping) {
SkBitmap bitmap;
ASSERT_TRUE(bitmap.tryAllocN32Pixels(pic->cullRect().width(),
pic->cullRect().height()));
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawPicture(pic);
// This should be inside the top right corner of the first top level div.
// Success means there was no horizontal clipping as this region is red,
@ -191,7 +191,7 @@ TEST_F(PaintPreviewRecorderRenderViewTest, TestCaptureMainFrameWithScroll) {
SkBitmap bitmap;
ASSERT_TRUE(bitmap.tryAllocN32Pixels(pic->cullRect().width(),
pic->cullRect().height()));
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawPicture(pic);
// This should be inside the top right corner of the top div. Success means
// there was no horizontal or vertical clipping as this region is red,

@ -8,6 +8,7 @@ include_rules = [
"+components/safe_browsing/core/features.h",
"+cc/paint",
"+crypto",
"+skia/ext",
"+third_party/skia/include",
"+third_party/smhasher",
"+ui/base/page_transition_types.h",

@ -30,6 +30,7 @@
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_thread.h"
#include "crypto/sha2.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/blink/public/platform/web_url.h"
#include "third_party/blink/public/platform/web_url_request.h"
#include "third_party/blink/public/web/web_document.h"
@ -184,7 +185,7 @@ void PhishingClassifier::ExtractVisualFeatures() {
SkAlphaType::kUnpremul_SkAlphaType, rec2020);
if (!bitmap_->tryAllocPixels(bitmap_info))
return VisualExtractionFinished(/*success=*/false);
SkCanvas sk_canvas(*bitmap_);
SkCanvas sk_canvas(*bitmap_, skia::LegacyDisplayGlobals::GetSkSurfaceProps());
cc::SkiaPaintCanvas cc_canvas(&sk_canvas);
auto tracker = std::make_unique<paint_preview::PaintPreviewTracker>(
base::UnguessableToken::Create(), frame->GetEmbeddingToken(),

@ -5,6 +5,7 @@ include_rules = [
"+content/public/child", # Windows direct write proxy access.
"+content/public/utility",
"+mojo/public/cpp",
"+skia/ext",
"+third_party/skia/include",
"+ui/gfx/geometry",
]

@ -17,6 +17,7 @@
#include "components/paint_preview/common/serial_utils.h"
#include "components/paint_preview/common/serialized_recording.h"
#include "components/services/paint_preview_compositor/public/mojom/paint_preview_compositor.mojom.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkImageInfo.h"
@ -92,7 +93,7 @@ base::Optional<SkBitmap> CreateBitmap(sk_sp<SkPicture> skp,
clip_rect.width(), clip_rect.height(), kOpaque_SkAlphaType))) {
return base::nullopt;
}
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, skia::LegacyDisplayGlobals::GetSkSurfaceProps());
SkMatrix matrix;
matrix.setScaleTranslate(scale_factor, scale_factor, -clip_rect.x(),
-clip_rect.y());

@ -601,7 +601,7 @@ TEST(PaintPreviewCompositorTest, TestComposite) {
SkBitmap bitmap;
bitmap.allocPixels(
SkImageInfo::MakeN32(rect.width(), rect.height(), kOpaque_SkAlphaType));
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.scale(scale_factor, scale_factor);
DrawDummyTestPicture(&canvas, SK_ColorDKGRAY, root_frame_scroll_extent);
compositor.BitmapForSeparatedFrame(
@ -673,7 +673,7 @@ TEST(PaintPreviewCompositorTest, TestCompositeWithMemoryBuffer) {
SkBitmap bitmap;
bitmap.allocPixels(
SkImageInfo::MakeN32(rect.width(), rect.height(), kOpaque_SkAlphaType));
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.scale(scale_factor, scale_factor);
DrawDummyTestPicture(&canvas, SK_ColorDKGRAY, root_frame_scroll_extent);
compositor.BitmapForSeparatedFrame(
@ -723,7 +723,7 @@ TEST(PaintPreviewCompositorTest, TestCompositeMainFrameNoDependencies) {
SkBitmap bitmap;
bitmap.allocPixels(
SkImageInfo::MakeN32(rect.width(), rect.height(), kOpaque_SkAlphaType));
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.scale(scale_factor, scale_factor);
DrawDummyTestPicture(&canvas, SK_ColorDKGRAY, root_frame_scroll_extent);
compositor.BitmapForMainFrame(
@ -778,7 +778,7 @@ TEST(PaintPreviewCompositorTest, TestCompositeMainFrameOneDependency) {
SkBitmap bitmap;
bitmap.allocPixels(
SkImageInfo::MakeN32(rect.width(), rect.height(), kOpaque_SkAlphaType));
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.scale(scale_factor, scale_factor);
DrawDummyTestPicture(&canvas, SK_ColorDKGRAY, root_frame_scroll_extent);
// Draw the subframe where we embedded it while populating the proto.
@ -837,7 +837,7 @@ TEST(PaintPreviewCompositorTest, TestCompositeMainFrameOneDependencyScrolled) {
SkBitmap bitmap;
bitmap.allocPixels(
SkImageInfo::MakeN32(rect.width(), rect.height(), kOpaque_SkAlphaType));
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.scale(scale_factor, scale_factor);
DrawDummyTestPicture(&canvas, SK_ColorDKGRAY, root_frame_scroll_extent);
// Draw the subframe where we embedded it while populating the proto.
@ -899,7 +899,7 @@ TEST(PaintPreviewCompositorTest,
SkBitmap bitmap;
bitmap.allocPixels(
SkImageInfo::MakeN32(rect.width(), rect.height(), kOpaque_SkAlphaType));
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.scale(scale_factor, scale_factor);
// Offset the canvas to simulate the root frame being scrolled.
canvas.translate(-root_frame_clip_rect.x(), -root_frame_clip_rect.y());

@ -365,7 +365,7 @@ ClientResourceProvider::ScopedSkSurface::ScopedSkSurface(
GLenum texture_target,
const gfx::Size& size,
ResourceFormat format,
bool can_use_lcd_text,
SkSurfaceProps surface_props,
int msaa_sample_count) {
GrGLTextureInfo texture_info;
texture_info.fID = texture_id;
@ -373,7 +373,6 @@ ClientResourceProvider::ScopedSkSurface::ScopedSkSurface(
texture_info.fFormat = TextureStorageFormat(format);
GrBackendTexture backend_texture(size.width(), size.height(),
GrMipMapped::kNo, texture_info);
SkSurfaceProps surface_props = ComputeSurfaceProps(can_use_lcd_text);
// This type is used only for gpu raster, which implies gpu compositing.
bool gpu_compositing = true;
surface_ = SkSurface::MakeFromBackendTexture(
@ -387,19 +386,6 @@ ClientResourceProvider::ScopedSkSurface::~ScopedSkSurface() {
surface_->flushAndSubmit();
}
SkSurfaceProps ClientResourceProvider::ScopedSkSurface::ComputeSurfaceProps(
bool can_use_lcd_text) {
uint32_t flags = 0;
// Use unknown pixel geometry to disable LCD text.
SkSurfaceProps surface_props(flags, kUnknown_SkPixelGeometry);
if (can_use_lcd_text) {
// LegacyFontHost will get LCD text and skia figures out what type to use.
surface_props =
SkSurfaceProps(flags, SkSurfaceProps::kLegacyFontHost_InitType);
}
return surface_props;
}
void ClientResourceProvider::ValidateResource(ResourceId id) const {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(id);

@ -118,14 +118,12 @@ class VIZ_CLIENT_EXPORT ClientResourceProvider {
GLenum texture_target,
const gfx::Size& size,
ResourceFormat format,
bool can_use_lcd_text,
SkSurfaceProps surface_props,
int msaa_sample_count);
~ScopedSkSurface();
SkSurface* surface() const { return surface_.get(); }
static SkSurfaceProps ComputeSurfaceProps(bool can_use_lcd_text);
private:
sk_sp<SkSurface> surface_;

@ -202,6 +202,7 @@ viz_component("service") {
"//media/mojo/services",
"//services/tracing/public/cpp:cpp",
"//services/viz/privileged/mojom",
"//skia",
"//skia:skcms",
"//third_party/libyuv",
"//ui/display/types",

@ -10,6 +10,7 @@ include_rules = [
"+gpu/ipc/common/surface_handle.h",
"+services/viz/privileged/mojom",
"+services/viz/public/mojom",
"+skia/ext",
"+third_party/skia",
"+ui/latency",
"+ui/ozone/public",

@ -3541,7 +3541,7 @@ TEST_P(GPURendererPixelTest, TileDrawQuadForceAntiAliasingOff) {
SkBitmap bitmap;
bitmap.allocN32Pixels(32, 32);
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.clear(SK_ColorTRANSPARENT);
gfx::Size tile_size(32, 32);
@ -4006,7 +4006,7 @@ TEST_P(RendererPixelTest, TileDrawQuadNearestNeighbor) {
SkImageInfo info = SkImageInfo::Make(2, 2, ct, kPremul_SkAlphaType);
SkBitmap bitmap;
bitmap.allocPixels(info);
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
draw_point_color(&canvas, 0, 0, SK_ColorGREEN);
draw_point_color(&canvas, 0, 1, SK_ColorBLUE);
draw_point_color(&canvas, 1, 0, SK_ColorBLUE);
@ -4061,7 +4061,7 @@ TEST_F(SoftwareRendererPixelTest, TextureDrawQuadNearestNeighbor) {
SkBitmap bitmap;
bitmap.allocN32Pixels(2, 2);
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
draw_point_color(&canvas, 0, 0, SK_ColorGREEN);
draw_point_color(&canvas, 0, 1, SK_ColorBLUE);
draw_point_color(&canvas, 1, 0, SK_ColorBLUE);
@ -4113,7 +4113,7 @@ TEST_F(SoftwareRendererPixelTest, TextureDrawQuadLinear) {
SkBitmap bitmap;
bitmap.allocN32Pixels(2, 2);
{
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
draw_point_color(&canvas, 0, 0, SK_ColorGREEN);
draw_point_color(&canvas, 0, 1, SK_ColorBLUE);
draw_point_color(&canvas, 1, 0, SK_ColorBLUE);
@ -4459,7 +4459,7 @@ TEST_P(GPURendererPixelTest, TextureQuadBatching) {
SkBitmap bitmap;
bitmap.allocPixels(
SkImageInfo::MakeN32Premul(mask_rect.width(), mask_rect.height()));
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
SkPaint paint;
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(SkIntToScalar(4));
@ -4541,7 +4541,7 @@ TEST_P(GPURendererPixelTest, TileQuadClamping) {
// layer rect red.
SkBitmap bitmap;
bitmap.allocN32Pixels(tile_size.width(), tile_size.height());
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
SkPaint red;
red.setColor(SK_ColorRED);
canvas.drawRect(SkRect::MakeWH(tile_size.width(), tile_size.height()), red);

@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/check.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "ui/gfx/vsync_provider.h"
@ -38,7 +39,8 @@ void SoftwareOutputDevice::Resize(const gfx::Size& viewport_pixel_size,
SkImageInfo::MakeN32(viewport_pixel_size.width(),
viewport_pixel_size.height(), kOpaque_SkAlphaType);
viewport_pixel_size_ = viewport_pixel_size;
surface_ = SkSurface::MakeRaster(info);
SkSurfaceProps props = skia::LegacyDisplayGlobals::GetSkSurfaceProps();
surface_ = SkSurface::MakeRaster(info, &props);
}
SkCanvas* SoftwareOutputDevice::BeginPaint(const gfx::Rect& damage_rect) {

@ -30,6 +30,7 @@
#include "components/viz/service/display/renderer_utils.h"
#include "components/viz/service/display/software_output_device.h"
#include "skia/ext/image_operations.h"
#include "skia/ext/legacy_display_globals.h"
#include "skia/ext/opacity_filter_canvas.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColor.h"
@ -146,7 +147,8 @@ void SoftwareRenderer::BindFramebufferToTexture(
DCHECK(it != render_pass_bitmaps_.end());
SkBitmap& bitmap = it->second;
current_framebuffer_canvas_ = std::make_unique<SkCanvas>(bitmap);
current_framebuffer_canvas_ = std::make_unique<SkCanvas>(
bitmap, skia::LegacyDisplayGlobals::GetSkSurfaceProps());
current_canvas_ = current_framebuffer_canvas_.get();
}
@ -876,7 +878,7 @@ sk_sp<SkShader> SoftwareRenderer::GetBackdropFilterShader(
if (!bitmap.tryAllocPixels(info))
base::TerminateBecauseOutOfMemory(info.computeMinByteSize());
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, skia::LegacyDisplayGlobals::GetSkSurfaceProps());
// Clip the filtered image to the (rounded) bounding box of the element.
if (backdrop_filter_bounds) {

@ -9,6 +9,7 @@
#include "components/viz/service/display_embedder/skia_output_surface_dependency.h"
#include "gpu/command_buffer/service/shared_context_state.h"
#include "gpu/command_buffer/service/shared_image_factory.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/skia/include/gpu/GrBackendSemaphore.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
@ -52,9 +53,8 @@ void OutputPresenter::Image::BeginWriteSkia() {
DCHECK(end_semaphores_.empty());
std::vector<GrBackendSemaphore> begin_semaphores;
// LegacyFontHost will get LCD text and skia figures out what type to use.
SkSurfaceProps surface_props(0 /* flags */,
SkSurfaceProps::kLegacyFontHost_InitType);
SkSurfaceProps surface_props =
skia::LegacyDisplayGlobals::GetSkSurfaceProps();
// Buffer queue is internal to GPU proc and handles texture initialization,
// so allow uncleared access.

@ -9,6 +9,7 @@
#include "base/check_op.h"
#include "base/notreached.h"
#include "components/viz/common/gpu/dawn_context_provider.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/dawn/src/include/dawn_native/D3D12Backend.h"
#include "ui/gfx/presentation_feedback.h"
#include "ui/gfx/vsync_provider.h"
@ -122,9 +123,8 @@ SkSurface* SkiaOutputDeviceDawn::BeginPaint(
GrBackendRenderTarget backend_target(
size_.width(), size_.height(), /*sampleCnt=*/0, /*stencilBits=*/0, info);
DCHECK(backend_target.isValid());
// LegacyFontHost will get LCD text and skia figures out what type to use.
SkSurfaceProps surface_props(/*flags=*/0,
SkSurfaceProps::kLegacyFontHost_InitType);
SkSurfaceProps surface_props =
skia::LegacyDisplayGlobals::GetSkSurfaceProps();
sk_surface_ = SkSurface::MakeFromBackendRenderTarget(
context_provider_->GetGrContext(), backend_target,
capabilities_.output_surface_origin == gfx::SurfaceOrigin::kTopLeft

@ -19,6 +19,7 @@
#include "gpu/command_buffer/service/shared_image_factory.h"
#include "gpu/command_buffer/service/texture_base.h"
#include "gpu/command_buffer/service/texture_manager.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/core/SkSurfaceProps.h"
#include "third_party/skia/include/gpu/GrBackendSurface.h"
@ -219,7 +220,7 @@ bool SkiaOutputDeviceGL::Reshape(const gfx::Size& size,
return false;
}
SkSurfaceProps surface_props =
SkSurfaceProps(0, SkSurfaceProps::kLegacyFontHost_InitType);
skia::LegacyDisplayGlobals::GetSkSurfaceProps();
GrGLFramebufferInfo framebuffer_info;
framebuffer_info.fFBOID = 0;

@ -7,6 +7,7 @@
#include <utility>
#include "gpu/command_buffer/service/skia_utils.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/skia/include/core/SkSurface.h"
namespace viz {
@ -136,9 +137,8 @@ SkSurface* SkiaOutputDeviceOffscreen::BeginPaint(
std::vector<GrBackendSemaphore>* end_semaphores) {
DCHECK(backend_texture_.isValid());
if (!sk_surface_) {
// LegacyFontHost will get LCD text and skia figures out what type to use.
SkSurfaceProps surface_props(0 /* flags */,
SkSurfaceProps::kLegacyFontHost_InitType);
SkSurfaceProps surface_props =
skia::LegacyDisplayGlobals::GetSkSurfaceProps();
sk_surface_ = SkSurface::MakeFromBackendTexture(
context_state_->gr_context(), backend_texture_,
capabilities_.output_surface_origin == gfx::SurfaceOrigin::kTopLeft

@ -18,6 +18,7 @@
#include "gpu/vulkan/vulkan_function_pointers.h"
#include "gpu/vulkan/vulkan_implementation.h"
#include "gpu/vulkan/vulkan_surface.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/GrBackendSemaphore.h"
#include "third_party/skia/include/gpu/GrBackendSurface.h"
@ -191,7 +192,7 @@ SkSurface* SkiaOutputDeviceVulkan::BeginPaint(
if (UNLIKELY(!sk_surface)) {
SkSurfaceProps surface_props =
SkSurfaceProps(0, SkSurfaceProps::kLegacyFontHost_InitType);
skia::LegacyDisplayGlobals::GetSkSurfaceProps();
const auto surface_format = vulkan_surface_->surface_format().format;
DCHECK(surface_format == VK_FORMAT_B8G8R8A8_UNORM ||
surface_format == VK_FORMAT_R8G8B8A8_UNORM);

@ -9,6 +9,7 @@
#include "gpu/command_buffer/common/swap_buffers_complete_params.h"
#include "gpu/command_buffer/service/gl_utils.h"
#include "gpu/command_buffer/service/shared_context_state.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "ui/gfx/buffer_format_util.h"
#include "ui/gl/gl_bindings.h"
@ -99,7 +100,7 @@ void SkiaOutputDeviceWebView::InitSkiaSurface(unsigned int fbo) {
last_frame_buffer_object_ = fbo;
SkSurfaceProps surface_props =
SkSurfaceProps(0, SkSurfaceProps::kLegacyFontHost_InitType);
skia::LegacyDisplayGlobals::GetSkSurfaceProps();
GrGLFramebufferInfo framebuffer_info;
framebuffer_info.fFBOID = fbo;

@ -33,6 +33,7 @@
#include "gpu/ipc/single_task_sequence.h"
#include "gpu/vulkan/buildflags.h"
#include "skia/buildflags.h"
#include "skia/ext/legacy_display_globals.h"
#include "ui/gfx/skia_util.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_gl_api_implementation.h"
@ -845,9 +846,8 @@ SkiaOutputSurfaceImpl::CreateSkSurfaceCharacterization(
return SkSurfaceCharacterization();
auto cache_max_resource_bytes = impl_on_gpu_->max_resource_cache_bytes();
// LegacyFontHost will get LCD text and skia figures out what type to use.
SkSurfaceProps surface_props(0 /*flags */,
SkSurfaceProps::kLegacyFontHost_InitType);
SkSurfaceProps surface_props =
skia::LegacyDisplayGlobals::GetSkSurfaceProps();
if (is_root_render_pass) {
const auto format_index = static_cast<int>(format);
const auto& color_type = capabilities_.sk_color_types[format_index];

@ -98,7 +98,7 @@ class VideoCaptureOverlayTest : public testing::Test {
kTestImageSize.width(), kTestImageSize.height(),
GetLinearSRGB().ToSkColorSpace());
CHECK(result.tryAllocPixels(info, info.minRowBytes()));
SkCanvas canvas(result);
SkCanvas canvas(result, SkSurfaceProps{});
canvas.drawColor(kTestImageBackground);
for (size_t i = 0; i < base::size(kTestImageColors); ++i) {
const size_t idx = (i + cycle) % base::size(kTestImageColors);

@ -23,7 +23,7 @@
#include "media/gpu/buildflags.h"
#include "services/metrics/public/cpp/delegating_ukm_recorder.h"
#include "services/metrics/public/cpp/mojo_ukm_recorder.h"
#include "third_party/skia/include/core/SkFontLCDConfig.h"
#include "skia/ext/legacy_display_globals.h"
namespace {
@ -166,11 +166,8 @@ void VizMainImpl::CreateGpuService(
discardable_shared_memory_manager_.get());
}
SkFontLCDConfig::SetSubpixelOrder(
gfx::FontRenderParams::SubpixelRenderingToSkiaLCDOrder(
subpixel_rendering));
SkFontLCDConfig::SetSubpixelOrientation(
gfx::FontRenderParams::SubpixelRenderingToSkiaLCDOrientation(
skia::LegacyDisplayGlobals::SetCachedPixelGeometry(
gfx::FontRenderParams::SubpixelRenderingToSkiaPixelGeometry(
subpixel_rendering));
gpu_service_->Bind(std::move(pending_receiver));

@ -243,7 +243,7 @@ void RenderWidgetHostViewBase::CopyMainAndPopupFromSurface(
const gfx::Vector2d offset, const SkBitmap& main_image,
const SkBitmap& popup_image) {
// Draw popup_image into main_image.
SkCanvas canvas(main_image);
SkCanvas canvas(main_image, SkSurfaceProps{});
canvas.drawBitmap(popup_image, offset.x(), offset.y());
std::move(final_callback).Run(main_image);
},

@ -18,6 +18,7 @@
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/ppb_image_data.h"
#include "ppapi/thunk/thunk.h"
#include "skia/ext/legacy_display_globals.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColorPriv.h"
@ -238,7 +239,8 @@ void* ImageDataSimpleBackend::Map() {
skia_bitmap_.setPixels(shm_mapping_.memory());
// Our platform bitmaps are set to opaque by default, which we don't want.
skia_bitmap_.setAlphaType(kPremul_SkAlphaType);
skia_canvas_ = std::make_unique<SkCanvas>(skia_bitmap_);
skia_canvas_ = std::make_unique<SkCanvas>(
skia_bitmap_, skia::LegacyDisplayGlobals::GetSkSurfaceProps());
}
return skia_bitmap_.isNull() ? nullptr : skia_bitmap_.getAddr32(0, 0);
}

@ -4,6 +4,7 @@
#include "content/renderer/render_view_impl.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/blink/public/platform/web_font_render_style.h"
namespace content {
@ -35,11 +36,8 @@ void RenderViewImpl::UpdateFontRenderingFromRendererPrefs() {
RendererPreferencesToSkiaHinting(prefs));
blink::WebFontRenderStyle::SetAutoHint(prefs.use_autohinter);
blink::WebFontRenderStyle::SetUseBitmaps(prefs.use_bitmaps);
SkFontLCDConfig::SetSubpixelOrder(
gfx::FontRenderParams::SubpixelRenderingToSkiaLCDOrder(
prefs.subpixel_rendering));
SkFontLCDConfig::SetSubpixelOrientation(
gfx::FontRenderParams::SubpixelRenderingToSkiaLCDOrientation(
skia::LegacyDisplayGlobals::SetCachedPixelGeometry(
gfx::FontRenderParams::SubpixelRenderingToSkiaPixelGeometry(
prefs.subpixel_rendering));
blink::WebFontRenderStyle::SetAntiAlias(prefs.should_antialias_text);
blink::WebFontRenderStyle::SetSubpixelRendering(

@ -4,9 +4,9 @@
#include "content/renderer/render_view_impl.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/blink/public/mojom/renderer_preferences.mojom.h"
#include "third_party/blink/public/platform/web_font_render_style.h"
#include "third_party/skia/include/core/SkFontLCDConfig.h"
#include "ui/gfx/font_render_params.h"
using blink::WebFontRenderStyle;
@ -56,11 +56,8 @@ void RenderViewImpl::UpdateFontRenderingFromRendererPrefs() {
WebFontRenderStyle::SetHinting(RendererPreferencesToSkiaHinting(prefs));
WebFontRenderStyle::SetAutoHint(prefs.use_autohinter);
WebFontRenderStyle::SetUseBitmaps(prefs.use_bitmaps);
SkFontLCDConfig::SetSubpixelOrder(
gfx::FontRenderParams::SubpixelRenderingToSkiaLCDOrder(
prefs.subpixel_rendering));
SkFontLCDConfig::SetSubpixelOrientation(
gfx::FontRenderParams::SubpixelRenderingToSkiaLCDOrientation(
skia::LegacyDisplayGlobals::SetCachedPixelGeometry(
gfx::FontRenderParams::SubpixelRenderingToSkiaPixelGeometry(
prefs.subpixel_rendering));
WebFontRenderStyle::SetAntiAlias(prefs.should_antialias_text);
WebFontRenderStyle::SetSubpixelRendering(

@ -4,9 +4,9 @@
#include "content/child/webthemeengine_impl_default.h"
#include "content/renderer/render_view_impl.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/blink/public/mojom/renderer_preferences.mojom.h"
#include "third_party/blink/public/web/win/web_font_rendering.h"
#include "third_party/skia/include/core/SkFontLCDConfig.h"
#include "ui/gfx/font_render_params.h"
using blink::WebFontRendering;
@ -27,11 +27,8 @@ void RenderViewImpl::UpdateFontRenderingFromRendererPrefs() {
blink::WebFontRendering::SetStatusFontMetrics(
prefs.status_font_family_name.c_str(), prefs.status_font_height);
SkFontLCDConfig::SetSubpixelOrder(
gfx::FontRenderParams::SubpixelRenderingToSkiaLCDOrder(
prefs.subpixel_rendering));
SkFontLCDConfig::SetSubpixelOrientation(
gfx::FontRenderParams::SubpixelRenderingToSkiaLCDOrientation(
skia::LegacyDisplayGlobals::SetCachedPixelGeometry(
gfx::FontRenderParams::SubpixelRenderingToSkiaPixelGeometry(
prefs.subpixel_rendering));
blink::WebFontRendering::SetAntialiasedTextEnabled(

@ -19,6 +19,7 @@
#include "gin/handle.h"
#include "gin/object_template_builder.h"
#include "skia/ext/benchmarking_canvas.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/blink/public/web/blink.h"
#include "third_party/blink/public/web/web_array_buffer.h"
#include "third_party/blink/public/web/web_array_buffer_converter.h"
@ -199,7 +200,7 @@ void SkiaBenchmarking::Rasterize(gin::Arguments* args) {
return;
bitmap.eraseARGB(0, 0, 0, 0);
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.translate(SkIntToScalar(-clip_rect.x()),
SkIntToScalar(-clip_rect.y()));
canvas.clipRect(gfx::RectToSkRect(snapped_clip));
@ -243,7 +244,9 @@ void SkiaBenchmarking::GetOps(gin::Arguments* args) {
if (!picture.get())
return;
SkCanvas canvas(picture->layer_rect.width(), picture->layer_rect.height());
SkSurfaceProps props = skia::LegacyDisplayGlobals::GetSkSurfaceProps();
SkCanvas canvas(picture->layer_rect.width(), picture->layer_rect.height(),
&props);
skia::BenchmarkingCanvas benchmarking_canvas(&canvas);
picture->picture->playback(&benchmarking_canvas);
@ -268,14 +271,14 @@ void SkiaBenchmarking::GetOpTimings(gin::Arguments* args) {
// Measure the total time by drawing straight into a bitmap-backed canvas.
SkBitmap bitmap;
bitmap.allocN32Pixels(bounds.width(), bounds.height());
SkCanvas bitmap_canvas(bitmap);
SkCanvas bitmap_canvas(bitmap, SkSurfaceProps{});
bitmap_canvas.clear(SK_ColorTRANSPARENT);
base::TimeTicks t0 = base::TimeTicks::Now();
picture->picture->playback(&bitmap_canvas);
base::TimeDelta total_time = base::TimeTicks::Now() - t0;
// Gather per-op timing info by drawing into a BenchmarkingCanvas.
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.clear(SK_ColorTRANSPARENT);
skia::BenchmarkingCanvas benchmarking_canvas(&canvas);
picture->picture->playback(&benchmarking_canvas);

@ -429,7 +429,7 @@ void TestPlugin::DrawSceneSoftware(void* memory) {
SkImageInfo::MakeN32Premul(rect_.width, rect_.height);
SkBitmap bitmap;
bitmap.installPixels(info, memory, info.minRowBytes());
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.clear(background_color);
if (scene_.primitive != PrimitiveNone) {

@ -271,7 +271,7 @@ void RenderIconForVisibilityAnalysis(const SkBitmap& icon,
DCHECK(rendered_icon->empty());
rendered_icon->allocN32Pixels(icon.width(), icon.height());
rendered_icon->eraseColor(background_color);
SkCanvas offscreen(*rendered_icon);
SkCanvas offscreen(*rendered_icon, SkSurfaceProps{});
offscreen.drawImage(SkImage::MakeFromBitmap(icon), 0, 0);
offscreen.drawColor(background_color, SkBlendMode::kDifference);
}

@ -59,6 +59,7 @@
#include "gpu/command_buffer/service/skia_utils.h"
#include "gpu/command_buffer/service/wrapped_sk_image.h"
#include "gpu/vulkan/buildflags.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkDeferredDisplayListRecorder.h"
#include "third_party/skia/include/core/SkPromiseImageTexture.h"
@ -1595,7 +1596,8 @@ void RasterDecoderImpl::SetUpForRasterCHROMIUMForTest() {
// backed surface for OOP raster commands.
auto info = SkImageInfo::MakeN32(10, 10, kPremul_SkAlphaType,
SkColorSpace::MakeSRGB());
sk_surface_for_testing_ = SkSurface::MakeRaster(info);
SkSurfaceProps props = skia::LegacyDisplayGlobals::GetSkSurfaceProps();
sk_surface_for_testing_ = SkSurface::MakeRaster(info, &props);
sk_surface_ = sk_surface_for_testing_.get();
raster_canvas_ = sk_surface_->getCanvas();
}
@ -2883,9 +2885,7 @@ void RasterDecoderImpl::DoBeginRasterCHROMIUM(GLuint sk_color,
uint32_t flags = 0;
SkSurfaceProps surface_props(flags, kUnknown_SkPixelGeometry);
if (can_use_lcd_text) {
// LegacyFontHost will get LCD text and skia figures out what type to use.
surface_props =
SkSurfaceProps(flags, SkSurfaceProps::kLegacyFontHost_InitType);
surface_props = skia::LegacyDisplayGlobals::GetSkSurfaceProps(flags);
}
SkColorType sk_color_type = viz::ResourceFormatToClosestSkColorType(

@ -6,6 +6,7 @@
#include "build/build_config.h"
#include "components/viz/common/resources/resource_format_utils.h"
#include "gpu/command_buffer/service/shared_context_state.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/skia/include/core/SkPromiseImageTexture.h"
#include "third_party/skia/include/gpu/GrBackendSurface.h"
#include "third_party/skia/include/gpu/mock/GrMockTypes.h"
@ -72,7 +73,9 @@ class TestSharedImageRepresentationSkia : public SharedImageRepresentationSkia {
if (!static_cast<TestSharedImageBacking*>(backing())->can_access()) {
return nullptr;
}
return SkSurface::MakeRasterN32Premul(size().width(), size().height());
SkSurfaceProps props = skia::LegacyDisplayGlobals::GetSkSurfaceProps();
return SkSurface::MakeRasterN32Premul(size().width(), size().height(),
&props);
}
void EndWriteAccess(sk_sp<SkSurface> surface) override {}
sk_sp<SkPromiseImageTexture> BeginReadAccess(

@ -28,6 +28,7 @@ if (use_x11) {
"//components/tracing:startup_tracing",
"//components/viz/common",
"//gpu/vulkan/init",
"//skia",
"//ui/display/types",
"//ui/events",
"//ui/events/platform",

@ -1,6 +1,7 @@
include_rules = [
"+components/tracing",
"+components/viz",
"+skia/ext",
"+third_party/skia",
"+ui",
]

@ -12,6 +12,7 @@
#include "gpu/vulkan/vulkan_function_pointers.h"
#include "gpu/vulkan/vulkan_implementation.h"
#include "gpu/vulkan/vulkan_surface.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkFont.h"
#include "third_party/skia/include/core/SkSurface.h"
@ -114,7 +115,8 @@ void VulkanDemo::CreateSkSurface() {
if (!sk_surface) {
SkSurfaceProps surface_props =
SkSurfaceProps(0, SkSurfaceProps::kLegacyFontHost_InitType);
skia::LegacyDisplayGlobals::GetSkSurfaceProps();
GrVkImageInfo vk_image_info;
vk_image_info.fImage = scoped_write_->image();
vk_image_info.fImageLayout = scoped_write_->image_layout();

@ -12,6 +12,7 @@ include_rules = [
"+mojo/public/cpp/system/platform_handle.h",
"+services/device/public",
"+services/viz/public/cpp/gpu/context_provider_command_buffer.h",
"+skia/ext",
"+third_party/dav1d",
"+third_party/ffmpeg",
"+third_party/libaom",

@ -98,6 +98,7 @@ source_set("capture_device_specific") {
"//media/capture/mojom:image_capture_types",
"//media/mojo/mojom",
"//media/parsers",
"//skia",
"//third_party/libyuv",
"//ui/gfx",
]

@ -23,6 +23,7 @@
#include "media/base/video_frame.h"
#include "media/capture/mojom/image_capture_types.h"
#include "media/capture/video/gpu_memory_buffer_utils.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkFont.h"
@ -429,7 +430,7 @@ void PacmanFramePainter::DrawPacman(base::TimeDelta elapsed_time,
paint.setStyle(SkPaint::kFill_Style);
SkFont font;
font.setEdging(SkFont::Edging::kAlias);
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, skia::LegacyDisplayGlobals::GetSkSurfaceProps());
const SkScalar unscaled_zoom = fake_device_state_->zoom / 100.f;
const SkScalar translate_x =

@ -68,7 +68,7 @@ TEST(MetafileSkiaTest, TestFrameContent) {
EXPECT_TRUE(pic->cullRect() == page_rect);
SkBitmap bitmap;
bitmap.allocN32Pixels(kPageSideLen, kPageSideLen);
SkCanvas bitmap_canvas(bitmap);
SkCanvas bitmap_canvas(bitmap, SkSurfaceProps{});
pic->playback(&bitmap_canvas);
// Check top left pixel color of the red square.
EXPECT_EQ(bitmap.getColor(0, 0), SK_ColorRED);

@ -26,7 +26,7 @@ SkBitmap ScaleImage(const SkBitmap& source, const float scale) {
dest.eraseColor(0);
// Use a canvas to scale the source image onto the new bitmap.
SkCanvas canvas(dest);
SkCanvas canvas(dest, SkSurfaceProps{});
canvas.scale(scale, scale);
canvas.drawBitmap(source, 0, 0, nullptr /* paint */);

@ -39,7 +39,7 @@ buildflag_header("buildflags") {
# External-facing config for dependent code.
config("skia_config") {
defines = [ "SK_LEGACY_SURFACE_PROPS" ]
defines = []
include_dirs = [ "//third_party/skia" ]
if (!is_ios) {
@ -249,6 +249,8 @@ component("skia") {
"ext/google_logging.cc",
"ext/image_operations.cc",
"ext/image_operations.h",
"ext/legacy_display_globals.cc",
"ext/legacy_display_globals.h",
"ext/opacity_filter_canvas.cc",
"ext/opacity_filter_canvas.h",
"ext/recursive_gaussian_convolution.cc",

@ -0,0 +1,44 @@
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "skia/ext/legacy_display_globals.h"
namespace skia {
namespace {
SkPixelGeometry g_pixel_geometry = kRGB_H_SkPixelGeometry;
}
// static
void LegacyDisplayGlobals::SetCachedPixelGeometry(
SkPixelGeometry pixel_geometry) {
g_pixel_geometry = pixel_geometry;
}
// static
SkPixelGeometry LegacyDisplayGlobals::GetCachedPixelGeometry() {
return g_pixel_geometry;
}
// static
SkSurfaceProps LegacyDisplayGlobals::GetSkSurfaceProps() {
return GetSkSurfaceProps(0);
}
// static
SkSurfaceProps LegacyDisplayGlobals::GetSkSurfaceProps(uint32_t flags) {
return SkSurfaceProps{flags, g_pixel_geometry};
}
SkSurfaceProps LegacyDisplayGlobals::ComputeSurfaceProps(
bool can_use_lcd_text) {
uint32_t flags = 0;
if (can_use_lcd_text) {
return LegacyDisplayGlobals::GetSkSurfaceProps(flags);
}
// Use unknown pixel geometry to disable LCD text.
return SkSurfaceProps{flags, kUnknown_SkPixelGeometry};
}
} // namespace skia

@ -0,0 +1,27 @@
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SKIA_EXT_LEGACY_DISPLAY_GLOBALS_H_
#define SKIA_EXT_LEGACY_DISPLAY_GLOBALS_H_
#include "third_party/skia/include/core/SkSurfaceProps.h"
namespace skia {
class SK_API LegacyDisplayGlobals {
public:
static void SetCachedPixelGeometry(SkPixelGeometry pixel_geometry);
static SkPixelGeometry GetCachedPixelGeometry();
// Returns a SkSurfaceProps with the cached geometry settings.
static SkSurfaceProps GetSkSurfaceProps();
static SkSurfaceProps GetSkSurfaceProps(uint32_t flags);
// Will turn off LCD text if |can_use_lcd_text| is false.
static SkSurfaceProps ComputeSurfaceProps(bool can_use_lcd_text);
};
} // namespace skia
#endif // SKIA_EXT_LEGACY_DISPLAY_GLOBALS_H_

@ -9,15 +9,16 @@
#include <string.h>
#include "base/debug/gdi_debug_util_win.h"
#include "base/memory/ptr_util.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/win/win_util.h"
#include "skia/ext/legacy_display_globals.h"
#include "skia/ext/platform_canvas.h"
#include "skia/ext/skia_utils_win.h"
#include "third_party/skia/include/core/SkMatrix.h"
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "third_party/skia/include/core/SkRect.h"
#include "third_party/skia/include/core/SkRefCnt.h"
namespace {
@ -143,7 +144,8 @@ std::unique_ptr<SkCanvas> CreatePlatformCanvasWithSharedSection(
SkBitmap bitmap;
if (bitmap.installPixels(info, pixels, row_bytes, unmap_view_proc,
nullptr)) {
return std::make_unique<SkCanvas>(bitmap);
return std::make_unique<SkCanvas>(
bitmap, LegacyDisplayGlobals::GetSkSurfaceProps());
}
}
}

@ -8,6 +8,7 @@
#include <windows.h>
#include "base/debug/gdi_debug_util_win.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/skia/include/core/SkRect.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/core/SkTypes.h"
@ -179,9 +180,11 @@ SkImageInfo PrepareAllocation(HDC context, BITMAP* backing) {
sk_sp<SkSurface> MapPlatformSurface(HDC context) {
BITMAP backing;
const SkImageInfo size(PrepareAllocation(context, &backing));
return size.isEmpty() ? nullptr
: SkSurface::MakeRasterDirect(size, backing.bmBits,
backing.bmWidthBytes);
SkSurfaceProps props = skia::LegacyDisplayGlobals::GetSkSurfaceProps();
return size.isEmpty()
? nullptr
: SkSurface::MakeRasterDirect(size, backing.bmBits,
backing.bmWidthBytes, &props);
}
SkBitmap MapPlatformBitmap(HDC context) {

@ -79,7 +79,7 @@ int main(int argc, char** argv) {
SkBitmap bitmap;
bitmap.allocN32Pixels(BitmapSize, BitmapSize);
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.clear(0x00000000);
for (int i = 1; i < argc; i++)

@ -1579,6 +1579,7 @@ source_set("unit_tests") {
"//components/paint_preview/common:common",
"//mojo/public/cpp/system",
"//services/network/trust_tokens:test_support",
"//skia",
"//skia:skcms",
"//testing/gmock",
"//testing/gtest",

@ -84,6 +84,7 @@ include_rules = [
"+services/service_manager/public",
"+skia/public/mojom",
"+skia/ext/image_operations.h",
"+skia/ext/legacy_display_globals.h",
"+skia/ext/skia_utils_mac.h",
"+third_party/blink/public/common",
"+third_party/blink/public/mojom",

@ -8687,7 +8687,7 @@ static void NodeImageTestValidation(const IntSize& reference_bitmap_size,
SkBitmap bitmap;
bitmap.allocN32Pixels(reference_bitmap_size.Width(),
reference_bitmap_size.Height());
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawColor(SK_ColorGREEN);
EXPECT_EQ(reference_bitmap_size.Width(), drag_image->Size().Width());

@ -537,7 +537,7 @@ TEST_F(WebViewTest, SetBaseBackgroundColorAndBlendWithExistingContent) {
// Set canvas background to red with alpha.
SkBitmap bitmap;
bitmap.allocN32Pixels(kWidth, kHeight);
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.clear(kAlphaRed);
PaintRecordBuilder builder;

@ -12,6 +12,7 @@
#include "base/single_thread_task_runner.h"
#include "gpu/command_buffer/client/shared_image_interface.h"
#include "gpu/config/gpu_feature_info.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/html/canvas/html_canvas_element.h"
@ -967,7 +968,8 @@ void ImageBitmap::RasterizeImageOnBackgroundThread(
DCHECK(!IsMainThread());
SkImageInfo info =
SkImageInfo::MakeN32Premul(dst_rect.Width(), dst_rect.Height());
sk_sp<SkSurface> surface = SkSurface::MakeRaster(info);
SkSurfaceProps props = skia::LegacyDisplayGlobals::GetSkSurfaceProps();
sk_sp<SkSurface> surface = SkSurface::MakeRaster(info, &props);
sk_sp<SkImage> skia_image;
if (surface) {
paint_record->Playback(surface->getCanvas());

@ -1941,7 +1941,7 @@ String AXNodeObject::ImageDataUrl(const IntSize& max_size) const {
} else {
bitmap.allocPixels(
SkImageInfo::MakeN32(width, height, kPremul_SkAlphaType));
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.clear(SK_ColorTRANSPARENT);
canvas.drawImageRect(image, SkRect::MakeIWH(width, height), nullptr);
}

@ -3,6 +3,7 @@ include_rules = [
"+media/capture/mojom/image_capture.mojom-blink-forward.h",
"+media/base",
"+skia/ext/legacy_display_globals.h",
"+skia/ext/platform_canvas.h",
"+third_party/libyuv",
"+third_party/skia/include/core",

@ -8,6 +8,7 @@
#include "media/base/video_frame.h"
#include "media/base/video_types.h"
#include "media/base/video_util.h"
#include "skia/ext/legacy_display_globals.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/blink/renderer/core/imagebitmap/image_bitmap.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_component.h"
@ -93,7 +94,8 @@ void ImageCaptureFrameGrabber::SingleShotFrameHandler::OnVideoFrameOnIOThread(
const SkImageInfo info = SkImageInfo::MakeN32(
frame->visible_rect().width(), frame->visible_rect().height(), alpha);
sk_sp<SkSurface> surface = SkSurface::MakeRaster(info);
SkSurfaceProps props = skia::LegacyDisplayGlobals::GetSkSurfaceProps();
sk_sp<SkSurface> surface = SkSurface::MakeRaster(info, &props);
DCHECK(surface);
auto wrapper_callback =

@ -68,7 +68,9 @@ class InterceptingCanvasBase : public SkCanvas {
protected:
explicit InterceptingCanvasBase(SkBitmap bitmap)
: SkCanvas(bitmap), call_nesting_depth_(0), call_count_(0) {}
: SkCanvas(bitmap, SkSurfaceProps{}),
call_nesting_depth_(0),
call_count_(0) {}
InterceptingCanvasBase(int width, int height)
: SkCanvas(width, height), call_nesting_depth_(0), call_count_(0) {}

@ -16,6 +16,7 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ref_counted_memory.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkImageInfo.h"
#include "third_party/skia/include/core/SkSurface.h"
@ -173,7 +174,8 @@ void X11SoftwareBitmapPresenter::Resize(const gfx::Size& pixel_size) {
SkImageInfo info = SkImageInfo::Make(viewport_pixel_size_.width(),
viewport_pixel_size_.height(),
color_type, kOpaque_SkAlphaType);
surface_ = SkSurface::MakeRaster(info);
SkSurfaceProps props = skia::LegacyDisplayGlobals::GetSkSurfaceProps();
surface_ = SkSurface::MakeRaster(info, &props);
}
}

@ -31,7 +31,7 @@ CanvasPainter::~CanvasPainter() {
if (!output_->tryAllocPixels(info))
return;
SkCanvas canvas(*output_);
SkCanvas canvas(*output_, SkSurfaceProps{});
canvas.clear(clear_color_);
// When pixel canvas is enabled, the recordings and canvas are already scaled

@ -9,38 +9,23 @@
namespace gfx {
// static
SkFontLCDConfig::LCDOrder FontRenderParams::SubpixelRenderingToSkiaLCDOrder(
SkPixelGeometry FontRenderParams::SubpixelRenderingToSkiaPixelGeometry(
FontRenderParams::SubpixelRendering subpixel_rendering) {
switch (subpixel_rendering) {
case gfx::FontRenderParams::SUBPIXEL_RENDERING_NONE:
return kRGB_H_SkPixelGeometry; // why not kUnknown_SkPixelGeometry ??
case gfx::FontRenderParams::SUBPIXEL_RENDERING_RGB:
return kRGB_H_SkPixelGeometry;
case gfx::FontRenderParams::SUBPIXEL_RENDERING_VRGB:
return SkFontLCDConfig::kRGB_LCDOrder;
return kRGB_V_SkPixelGeometry;
case gfx::FontRenderParams::SUBPIXEL_RENDERING_BGR:
return kBGR_H_SkPixelGeometry;
case gfx::FontRenderParams::SUBPIXEL_RENDERING_VBGR:
return SkFontLCDConfig::kBGR_LCDOrder;
return kBGR_V_SkPixelGeometry;
}
NOTREACHED();
return SkFontLCDConfig::kRGB_LCDOrder;
}
// static
SkFontLCDConfig::LCDOrientation
FontRenderParams::SubpixelRenderingToSkiaLCDOrientation(
FontRenderParams::SubpixelRendering subpixel_rendering) {
switch (subpixel_rendering) {
case gfx::FontRenderParams::SUBPIXEL_RENDERING_NONE:
case gfx::FontRenderParams::SUBPIXEL_RENDERING_RGB:
case gfx::FontRenderParams::SUBPIXEL_RENDERING_BGR:
return SkFontLCDConfig::kHorizontal_LCDOrientation;
case gfx::FontRenderParams::SUBPIXEL_RENDERING_VRGB:
case gfx::FontRenderParams::SUBPIXEL_RENDERING_VBGR:
return SkFontLCDConfig::kVertical_LCDOrientation;
}
NOTREACHED();
return SkFontLCDConfig::kHorizontal_LCDOrientation;
return kRGB_H_SkPixelGeometry;
}
FontRenderParamsQuery::FontRenderParamsQuery()

@ -10,7 +10,7 @@
#include "build/build_config.h"
#include "device/vr/buildflags/buildflags.h"
#include "third_party/skia/include/core/SkFontLCDConfig.h"
#include "third_party/skia/include/core/SkSurfaceProps.h"
#include "ui/gfx/font.h"
#include "ui/gfx/gfx_export.h"
@ -71,9 +71,7 @@ struct GFX_EXPORT FontRenderParams {
// subpixel order.
SubpixelRendering subpixel_rendering = SUBPIXEL_RENDERING_NONE;
static SkFontLCDConfig::LCDOrder SubpixelRenderingToSkiaLCDOrder(
SubpixelRendering subpixel_rendering);
static SkFontLCDConfig::LCDOrientation SubpixelRenderingToSkiaLCDOrientation(
static SkPixelGeometry SubpixelRenderingToSkiaPixelGeometry(
SubpixelRendering subpixel_rendering);
};

@ -443,7 +443,7 @@ TEST_F(IconUtilTest, TestTransparentIcon) {
bitmap.allocN32Pixels(size, size, false);
EXPECT_EQ(bitmap.alphaType(), kPremul_SkAlphaType);
{
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
canvas.drawColor(SK_ColorWHITE);
SkPaint paint;
paint.setColor(semi_transparent_red);

@ -9,6 +9,7 @@
#include "cc/paint/display_item_list.h"
#include "cc/paint/record_paint_canvas.h"
#include "cc/paint/skia_paint_canvas.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "ui/gfx/color_palette.h"
@ -98,7 +99,7 @@ const SkBitmap& ImageSkiaRep::GetBitmap() const {
// as it forces a rasterization on the UI thread.
bitmap_.allocN32Pixels(pixel_width(), pixel_height());
bitmap_.eraseColor(SK_ColorTRANSPARENT);
SkCanvas canvas(bitmap_);
SkCanvas canvas(bitmap_, skia::LegacyDisplayGlobals::GetSkSurfaceProps());
paint_record_->Playback(&canvas);
bitmap_.setImmutable();
}

@ -437,7 +437,7 @@ TEST_F(ImageTest, SkBitmapConversionPreservesOrientation) {
bitmap.eraseARGB(255, 0, 255, 0);
// Paint the upper half of the image in red (lower half is in green).
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
SkPaint red;
red.setColor(SK_ColorRED);
canvas.drawRect(SkRect::MakeWH(width, height / 2), red);
@ -478,7 +478,7 @@ TEST_F(ImageTest, SkBitmapConversionPreservesTransparency) {
bitmap.eraseARGB(0, 0, 255, 0);
// Paint the upper half of the image in red (lower half is transparent).
SkCanvas canvas(bitmap);
SkCanvas canvas(bitmap, SkSurfaceProps{});
SkPaint red;
red.setColor(SK_ColorRED);
canvas.drawRect(SkRect::MakeWH(width, height / 2), red);

@ -10,6 +10,7 @@
#include "base/logging.h"
#include "base/posix/eintr_wrapper.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "ui/gfx/buffer_format_util.h"
#include "ui/gfx/linux/drm_util_linux.h"
@ -222,8 +223,9 @@ class Buffer final : public ui::GbmBuffer {
return nullptr;
SkImageInfo info =
SkImageInfo::MakeN32Premul(size_.width(), size_.height());
return SkSurface::MakeRasterDirectReleaseProc(info, addr, stride,
&Buffer::UnmapGbmBo, this);
SkSurfaceProps props = skia::LegacyDisplayGlobals::GetSkSurfaceProps();
return SkSurface::MakeRasterDirectReleaseProc(
info, addr, stride, &Buffer::UnmapGbmBo, this, &props);
}
private:

@ -675,7 +675,7 @@ SkBitmap SkBitmapOperations::CreateColorMask(const SkBitmap& bitmap,
color_mask.allocN32Pixels(bitmap.width(), bitmap.height());
color_mask.eraseARGB(0, 0, 0, 0);
SkCanvas canvas(color_mask);
SkCanvas canvas(color_mask, SkSurfaceProps{});
SkPaint paint;
paint.setColorFilter(SkColorFilters::Blend(c, SkBlendMode::kSrcIn));
@ -699,7 +699,7 @@ SkBitmap SkBitmapOperations::CreateDropShadow(
bitmap.height() + shadow_margin.height());
image_with_shadow.eraseARGB(0, 0, 0, 0);
SkCanvas canvas(image_with_shadow);
SkCanvas canvas(image_with_shadow, SkSurfaceProps{});
canvas.translate(SkIntToScalar(shadow_margin.left()),
SkIntToScalar(shadow_margin.top()));
@ -749,7 +749,7 @@ SkBitmap SkBitmapOperations::Rotate(const SkBitmap& source,
break;
}
SkCanvas canvas(result);
SkCanvas canvas(result, SkSurfaceProps{});
canvas.clear(SkColorSetARGB(0, 0, 0, 0));
canvas.translate(SkFloatToScalar(result.width() * 0.5f),

@ -525,7 +525,7 @@ TEST(SkBitmapOperationsTest, RotateImage) {
// GGGYYY
src.allocN32Pixels(src_w, src_h);
SkCanvas canvas(src);
SkCanvas canvas(src, SkSurfaceProps{});
src.eraseARGB(0, 0, 0, 0);
// This region is a semi-transparent red to test non-opaque pixels.

@ -12,6 +12,7 @@
#include "base/location.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkFont.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
@ -83,9 +84,8 @@ bool SkiaGlRenderer::Initialize() {
void SkiaGlRenderer::RenderFrame() {
TRACE_EVENT0("ozone", "SkiaGlRenderer::RenderFrame");
// LegacyFontHost will get LCD text and skia figures out what type to use.
SkSurfaceProps surface_props =
SkSurfaceProps(0, SkSurfaceProps::kLegacyFontHost_InitType);
skia::LegacyDisplayGlobals::GetSkSurfaceProps();
if (!sk_surface_) {
GrGLFramebufferInfo framebuffer_info;

@ -8,6 +8,7 @@
#include <xf86drmMode.h>
#include "base/logging.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "ui/ozone/platform/drm/gpu/drm_device.h"
@ -88,7 +89,8 @@ bool DrmDumbBuffer::MapDumbBuffer(const SkImageInfo& info) {
return false;
}
surface_ = SkSurface::MakeRasterDirect(info, mmap_base_, stride_);
SkSurfaceProps props = skia::LegacyDisplayGlobals::GetSkSurfaceProps();
surface_ = SkSurface::MakeRasterDirect(info, mmap_base_, stride_, &props);
if (!surface_) {
LOG(ERROR) << "DrmDumbBuffer: Failed to create SkSurface: handle "
<< handle_;

@ -10,6 +10,7 @@
#include "base/check.h"
#include "base/stl_util.h"
#include "skia/ext/legacy_display_globals.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.h"
@ -385,10 +386,11 @@ bool MockDrmDevice::CreateDumbBuffer(const SkImageInfo& info,
*handle = allocate_buffer_count_++;
*stride = info.minRowBytes();
void* pixels = new char[info.computeByteSize(*stride)];
SkSurfaceProps props = skia::LegacyDisplayGlobals::GetSkSurfaceProps();
buffers_.push_back(SkSurface::MakeRasterDirectReleaseProc(
info, pixels, *stride,
[](void* pixels, void* context) { delete[] static_cast<char*>(pixels); },
/*context=*/nullptr));
/*context=*/nullptr, &props));
buffers_[*handle]->getCanvas()->clear(SK_ColorBLACK);
return true;

@ -14,6 +14,7 @@
#include "base/task/post_task.h"
#include "base/task/thread_pool.h"
#include "build/build_config.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "ui/gfx/buffer_format_util.h"
@ -72,8 +73,11 @@ class FileSurface : public SurfaceOzoneCanvas {
// SurfaceOzoneCanvas overrides:
void ResizeCanvas(const gfx::Size& viewport_size) override {
surface_ = SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(
viewport_size.width(), viewport_size.height()));
SkSurfaceProps props = skia::LegacyDisplayGlobals::GetSkSurfaceProps();
surface_ = SkSurface::MakeRaster(
SkImageInfo::MakeN32Premul(viewport_size.width(),
viewport_size.height()),
&props);
}
SkCanvas* GetCanvas() override { return surface_->getCanvas(); }
void PresentCanvas(const gfx::Rect& damage) override {

@ -9,6 +9,7 @@
#include "base/fuchsia/fuchsia_logging.h"
#include "base/memory/read_only_shared_memory_region.h"
#include "base/memory/writable_shared_memory_region.h"
#include "skia/ext/legacy_display_globals.h"
#include "ui/gfx/geometry/size_f.h"
#include "ui/gfx/skia_util.h"
#include "ui/gfx/vsync_provider.h"
@ -48,9 +49,10 @@ void ScenicWindowCanvas::Frame::Initialize(gfx::Size size,
scenic_memory = std::make_unique<scenic::Memory>(
scenic, memory_handle.PassPlatformHandle(), buffer_size,
fuchsia::images::MemoryType::HOST_MEMORY);
SkSurfaceProps props = skia::LegacyDisplayGlobals::GetSkSurfaceProps();
surface = SkSurface::MakeRasterDirect(
SkImageInfo::MakeN32Premul(size.width(), size.height()),
memory_mapping.memory(), bytes_per_row);
memory_mapping.memory(), bytes_per_row, &props);
dirty_region.setRect(gfx::RectToSkIRect(gfx::Rect(size)));
}

@ -13,6 +13,7 @@
#include "base/memory/unsafe_shared_memory_region.h"
#include "base/numerics/checked_math.h"
#include "base/posix/eintr_wrapper.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/skia/include/core/SkRegion.h"
#include "ui/gfx/skia_util.h"
#include "ui/gfx/vsync_provider.h"
@ -79,9 +80,10 @@ class WaylandCanvasSurface::SharedMemoryBuffer {
buffer_manager_->CreateShmBasedBuffer(
std::move(fd_pair.fd), checked_length.ValueOrDie(), size, buffer_id_);
SkSurfaceProps props = skia::LegacyDisplayGlobals::GetSkSurfaceProps();
sk_surface_ = SkSurface::MakeRasterDirect(
SkImageInfo::MakeN32Premul(size.width(), size.height()),
shm_mapping_.memory(), CalculateStride(size.width()));
shm_mapping_.memory(), CalculateStride(size.width()), &props);
if (!sk_surface_)
return false;

@ -65,7 +65,7 @@ bool GrabHwndSnapshot(HWND window_handle,
snapshot_bounds_in_window.y());
// Clear the region of the bitmap outside the clip rect to white.
SkCanvas image_canvas(bitmap);
SkCanvas image_canvas(bitmap, SkSurfaceProps{});
SkPaint paint;
paint.setColor(SK_ColorWHITE);

@ -73,7 +73,7 @@ void TableExample::CreateExampleView(View* container) {
icon1_.allocN32Pixels(16, 16);
icon2_.allocN32Pixels(16, 16);
SkCanvas canvas1(icon1_), canvas2(icon2_);
SkCanvas canvas1(icon1_, SkSurfaceProps{}), canvas2(icon2_, SkSurfaceProps{});
canvas1.drawColor(SK_ColorRED);
canvas2.drawColor(SK_ColorBLUE);