Skip to content

Commit

Permalink
oop: Intergrate skia font remoting for OOP raster.
Browse files Browse the repository at this point in the history
Integrate SkStrikeServer/SkStrikeClient to remote glyph generation for
OOP raster. This includes the following changes:

1) Use a SkTextBlobCacheDiffCanvas during serialization to analyze text
blobs serialized as a part of raster commands. This is used to track
the set of glyphs that will be required to raster these commands.

2) Use the SkStrikeServer::DiscardableHandleManager to let skia
allocate and lock discardable handles. Each handle is allocated a
unique id that skia can internally serialize and map to an instance
of SkGlyphCache on the GPU process. This allows the renderer to pin
glyph caches on the GPU until dependent raster commands are executed
on the service.

3) In the GPU process, deserialize the font data prior to executing
the raster commands. The deserialization populates the requisite glyph
caches with the glyphs generated by the renderer. Once the raster
commands have been executed, unlock all the discardable handles.

R=enne@chromium.org, piman@chromium.org
TBR=bsalomon@chromium.org

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: Ifff356a30bb2ac235eea0bc80e00180a508bce81
Reviewed-on: https://chromium-review.googlesource.com/1006181
Commit-Queue: Khushal <khushalsagar@chromium.org>
Reviewed-by: Khushal <khushalsagar@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: enne <enne@chromium.org>
Reviewed-by: Antoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555647}
  • Loading branch information
khushalsagar authored and Commit Bot committed May 3, 2018
1 parent e535f97 commit a8d5064
Show file tree
Hide file tree
Showing 69 changed files with 1,605 additions and 484 deletions.
6 changes: 4 additions & 2 deletions cc/BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2014 The Chromium Authors. All rights reserved.
# Copyright 2014 T/e 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.

Expand Down Expand Up @@ -509,6 +509,8 @@ cc_static_library("test_support") {
"test/test_layer_tree_host_base.cc",
"test/test_layer_tree_host_base.h",
"test/test_occlusion_tracker.h",
"test/test_options_provider.cc",
"test/test_options_provider.h",
"test/test_skcanvas.cc",
"test/test_skcanvas.h",
"test/test_task_graph_runner.cc",
Expand All @@ -527,6 +529,7 @@ cc_static_library("test_support") {
":cc",
"//cc/animation",
"//gpu:test_support",
"//testing/gmock",
]
deps = [
"//base",
Expand All @@ -545,7 +548,6 @@ cc_static_library("test_support") {
"//gpu/skia_bindings",
"//media",
"//skia",
"//testing/gmock",
"//testing/gtest",
"//ui/gfx",
"//ui/gfx:test_support",
Expand Down
1 change: 1 addition & 0 deletions cc/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ include_rules = [
"+third_party/khronos/GLES2/gl2ext.h",
"+third_party/libyuv",
"+third_party/skia/include",
"+third_party/skia/src/core/SkRemoteGlyphCache.h",
"+ui/latency/latency_info.h",
"+ui/gfx",
"+ui/gl",
Expand Down
1 change: 1 addition & 0 deletions cc/paint/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ fuzzer_test("paint_op_buffer_fuzzer") {
"//cc:test_support",
"//cc/paint",
"//components/viz/test:test_support",
"//gpu/command_buffer/service:gles2",
]
}

Expand Down
1 change: 1 addition & 0 deletions cc/paint/DEPS
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
specific_include_rules = {
"paint_op_buffer_fuzzer.cc": [
"+components/viz/test",
"+gpu/command_buffer",
],
"transfer_cache_fuzzer.cc": [
"+components/viz/test",
Expand Down
6 changes: 4 additions & 2 deletions cc/paint/image_transfer_cache_entry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ uint32_t ClientImageTransferCacheEntry::Id() const {
bool ClientImageTransferCacheEntry::Serialize(base::span<uint8_t> data) const {
DCHECK_GE(data.size(), SerializedSize());

PaintOpWriter writer(data.data(), data.size(), nullptr, nullptr);
PaintOp::SerializeOptions options;
PaintOpWriter writer(data.data(), data.size(), options);
writer.Write(pixmap_->colorType());
writer.Write(pixmap_->width());
writer.Write(pixmap_->height());
Expand Down Expand Up @@ -90,7 +91,8 @@ size_t ServiceImageTransferCacheEntry::CachedSize() const {
bool ServiceImageTransferCacheEntry::Deserialize(
GrContext* context,
base::span<const uint8_t> data) {
PaintOpReader reader(data.data(), data.size(), nullptr);
PaintOp::DeserializeOptions options;
PaintOpReader reader(data.data(), data.size(), options);
SkColorType color_type;
reader.Read(&color_type);
uint32_t width;
Expand Down
43 changes: 43 additions & 0 deletions cc/paint/oop_pixeltest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "cc/layers/recording_source.h"
#include "cc/paint/display_item_list.h"
#include "cc/paint/paint_image_builder.h"
#include "cc/paint/paint_text_blob_builder.h"
#include "cc/raster/playback_image_provider.h"
#include "cc/raster/raster_source.h"
#include "cc/test/pixel_test_utils.h"
Expand Down Expand Up @@ -1067,6 +1068,48 @@ TEST_P(OopPixelTest, DrawRectColorSpace) {
ExpectEquals(actual, expected);
}

scoped_refptr<PaintTextBlob> buildTextBlob() {
SkFontStyle style;
PaintTypeface typeface =
PaintTypeface::FromFamilyNameAndFontStyle("monospace", style);

PaintFont font;
font.SetTypeface(typeface);
font.SetTextEncoding(SkPaint::kGlyphID_TextEncoding);
font.SetHinting(SkPaint::kNormal_Hinting);
font.SetTextSize(10u);

PaintTextBlobBuilder builder;
SkRect bounds = SkRect::MakeWH(100, 100);
const int glyphCount = 10;
const auto& runBuffer = builder.AllocRunPosH(font, glyphCount, 0, &bounds);
for (int i = 0; i < glyphCount; i++)
runBuffer.glyphs[i] = static_cast<SkGlyphID>(i);
return builder.TakeTextBlob();
}

TEST_P(OopPixelTest, DrawTextBlob) {
RasterOptions options;
options.resource_size = gfx::Size(100, 100);
options.content_size = options.resource_size;
options.full_raster_rect = gfx::Rect(options.content_size);
options.playback_rect = options.full_raster_rect;
options.color_space = gfx::ColorSpace::CreateSRGB();

auto display_item_list = base::MakeRefCounted<DisplayItemList>();
display_item_list->StartPaint();
PaintFlags flags;
flags.setStyle(PaintFlags::kFill_Style);
flags.setColor(SK_ColorGREEN);
display_item_list->push<DrawTextBlobOp>(buildTextBlob(), 0u, 0u, flags);
display_item_list->EndPaintOfUnpaired(options.full_raster_rect);
display_item_list->Finalize();

auto actual = Raster(display_item_list, options);
auto expected = RasterExpectedBitmap(display_item_list, options);
ExpectEquals(actual, expected);
}

INSTANTIATE_TEST_CASE_P(P, OopPixelTest, ::testing::Bool());

INSTANTIATE_TEST_CASE_P(P,
Expand Down
Loading

0 comments on commit a8d5064

Please sign in to comment.