Commit 050dee5a authored by Peng Huang's avatar Peng Huang Committed by Commit Bot

Using Skia DDL in raster decoder.

We would like to verify Skia DDL correctness for rastering work. So a
new flag --enable-oop-rasterization-ddl is added. With this flag, the
raster decoder will record raster work into a DDL first, and then play it
back into a SkSurface. Right now, recording and playing back are on the
GPU main thread. In future, the recording could be moved to raster worker
threads.

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;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: Iba462c6a2376b9ab6fc663c97b913e568a5a8bce
Reviewed-on: https://chromium-review.googlesource.com/1169150Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#588880}
parent efd3618b
...@@ -96,6 +96,9 @@ const gpu::GpuPreferences GetGpuPreferencesFromCommandLine() { ...@@ -96,6 +96,9 @@ const gpu::GpuPreferences GetGpuPreferencesFromCommandLine() {
gpu_preferences.disable_oop_rasterization = gpu_preferences.disable_oop_rasterization =
command_line->HasSwitch(switches::kDisableOopRasterization); command_line->HasSwitch(switches::kDisableOopRasterization);
gpu_preferences.enable_oop_rasterization_ddl =
command_line->HasSwitch(switches::kEnableOopRasterizationDDL);
gpu_preferences.enable_vulkan = gpu_preferences.enable_vulkan =
command_line->HasSwitch(switches::kEnableVulkan); command_line->HasSwitch(switches::kEnableVulkan);
......
...@@ -481,6 +481,9 @@ const char kDisableOopRasterization[] = "disable-oop-rasterization"; ...@@ -481,6 +481,9 @@ const char kDisableOopRasterization[] = "disable-oop-rasterization";
// would have been used. Enables the chromium_raster_transport extension. // would have been used. Enables the chromium_raster_transport extension.
const char kEnableOopRasterization[] = "enable-oop-rasterization"; const char kEnableOopRasterization[] = "enable-oop-rasterization";
// Turns on skia deferred display list for out of process raster.
const char kEnableOopRasterizationDDL[] = "enable-oop-rasterization-ddl";
// The number of multisample antialiasing samples for GPU rasterization. // The number of multisample antialiasing samples for GPU rasterization.
// Requires MSAA support on GPU to have an effect. 0 disables MSAA. // Requires MSAA support on GPU to have an effect. 0 disables MSAA.
const char kGpuRasterizationMSAASampleCount[] = const char kGpuRasterizationMSAASampleCount[] =
......
...@@ -152,6 +152,7 @@ CONTENT_EXPORT extern const char kForceDisplayList2dCanvas[]; ...@@ -152,6 +152,7 @@ CONTENT_EXPORT extern const char kForceDisplayList2dCanvas[];
CONTENT_EXPORT extern const char kForceGpuRasterization[]; CONTENT_EXPORT extern const char kForceGpuRasterization[];
CONTENT_EXPORT extern const char kDisableOopRasterization[]; CONTENT_EXPORT extern const char kDisableOopRasterization[];
CONTENT_EXPORT extern const char kEnableOopRasterization[]; CONTENT_EXPORT extern const char kEnableOopRasterization[];
CONTENT_EXPORT extern const char kEnableOopRasterizationDDL[];
CONTENT_EXPORT extern const char kForceOverlayFullscreenVideo[]; CONTENT_EXPORT extern const char kForceOverlayFullscreenVideo[];
CONTENT_EXPORT extern const char kForcePresentationReceiverForTesting[]; CONTENT_EXPORT extern const char kForcePresentationReceiverForTesting[];
CONTENT_EXPORT extern const char kForceRendererAccessibility[]; CONTENT_EXPORT extern const char kForceRendererAccessibility[];
......
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
#include "gpu/command_buffer/service/vertex_attrib_manager.h" #include "gpu/command_buffer/service/vertex_attrib_manager.h"
#include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColorSpaceXformCanvas.h" #include "third_party/skia/include/core/SkColorSpaceXformCanvas.h"
#include "third_party/skia/include/core/SkDeferredDisplayListRecorder.h"
#include "third_party/skia/include/core/SkSurface.h" #include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/core/SkSurfaceProps.h" #include "third_party/skia/include/core/SkSurfaceProps.h"
#include "third_party/skia/include/core/SkTypeface.h" #include "third_party/skia/include/core/SkTypeface.h"
...@@ -746,6 +747,7 @@ class RasterDecoderImpl final : public RasterDecoder, ...@@ -746,6 +747,7 @@ class RasterDecoderImpl final : public RasterDecoder,
int commands_to_process_ = 0; int commands_to_process_ = 0;
bool supports_oop_raster_ = false; bool supports_oop_raster_ = false;
bool use_ddl_ = false;
bool has_robustness_extension_ = false; bool has_robustness_extension_ = false;
bool context_was_lost_ = false; bool context_was_lost_ = false;
...@@ -802,6 +804,8 @@ class RasterDecoderImpl final : public RasterDecoder, ...@@ -802,6 +804,8 @@ class RasterDecoderImpl final : public RasterDecoder,
// Raster helpers. // Raster helpers.
ServiceFontManager font_manager_; ServiceFontManager font_manager_;
sk_sp<SkSurface> sk_surface_; sk_sp<SkSurface> sk_surface_;
std::unique_ptr<SkDeferredDisplayListRecorder> recorder_;
std::unique_ptr<SkCanvas> raster_canvas_; std::unique_ptr<SkCanvas> raster_canvas_;
uint32_t raster_color_space_id_; uint32_t raster_color_space_id_;
std::vector<SkDiscardableHandleId> locked_handles_; std::vector<SkDiscardableHandleId> locked_handles_;
...@@ -1017,6 +1021,7 @@ ContextResult RasterDecoderImpl::Initialize( ...@@ -1017,6 +1021,7 @@ ContextResult RasterDecoderImpl::Initialize(
} }
supports_oop_raster_ = !!raster_decoder_context_state_->gr_context; supports_oop_raster_ = !!raster_decoder_context_state_->gr_context;
use_ddl_ = group_->gpu_preferences().enable_oop_rasterization_ddl;
} }
return ContextResult::kSuccess; return ContextResult::kSuccess;
...@@ -3107,9 +3112,21 @@ void RasterDecoderImpl::DoBeginRasterCHROMIUM( ...@@ -3107,9 +3112,21 @@ void RasterDecoderImpl::DoBeginRasterCHROMIUM(
sk_surface_.reset(); sk_surface_.reset();
return; return;
} }
SkCanvas* canvas = nullptr;
if (use_ddl_) {
SkSurfaceCharacterization characterization;
bool result = sk_surface_->characterize(&characterization);
DCHECK(result) << "Failed to characterize raster SkSurface.";
recorder_ =
std::make_unique<SkDeferredDisplayListRecorder>(characterization);
canvas = recorder_->getCanvas();
} else {
canvas = sk_surface_->getCanvas();
}
raster_canvas_ = SkCreateColorSpaceXformCanvas( raster_canvas_ = SkCreateColorSpaceXformCanvas(
sk_surface_->getCanvas(), canvas, color_space_entry->color_space().ToSkColorSpace());
color_space_entry->color_space().ToSkColorSpace());
raster_color_space_id_ = color_space_transfer_cache_id; raster_color_space_id_ = color_space_transfer_cache_id;
// All or nothing clearing, as no way to validate the client's input on what // All or nothing clearing, as no way to validate the client's input on what
...@@ -3207,6 +3224,7 @@ void RasterDecoderImpl::DoRasterCHROMIUM(GLuint raster_shm_id, ...@@ -3207,6 +3224,7 @@ void RasterDecoderImpl::DoRasterCHROMIUM(GLuint raster_shm_id,
} }
void RasterDecoderImpl::DoEndRasterCHROMIUM() { void RasterDecoderImpl::DoEndRasterCHROMIUM() {
TRACE_EVENT0("gpu", "RasterDecoderImpl::DoEndRasterCHROMIUM");
if (!sk_surface_) { if (!sk_surface_) {
LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBeginRasterCHROMIUM", LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBeginRasterCHROMIUM",
"EndRasterCHROMIUM without BeginRasterCHROMIUM"); "EndRasterCHROMIUM without BeginRasterCHROMIUM");
...@@ -3216,6 +3234,12 @@ void RasterDecoderImpl::DoEndRasterCHROMIUM() { ...@@ -3216,6 +3234,12 @@ void RasterDecoderImpl::DoEndRasterCHROMIUM() {
raster_decoder_context_state_->need_context_state_reset = true; raster_decoder_context_state_->need_context_state_reset = true;
raster_canvas_.reset(); raster_canvas_.reset();
if (use_ddl_) {
auto ddl = recorder_->detach();
recorder_ = nullptr;
sk_surface_->draw(ddl.get());
}
sk_surface_->prepareForExternalIO(); sk_surface_->prepareForExternalIO();
sk_surface_.reset(); sk_surface_.reset();
......
...@@ -197,6 +197,8 @@ struct GPU_EXPORT GpuPreferences { ...@@ -197,6 +197,8 @@ struct GPU_EXPORT GpuPreferences {
bool enable_oop_rasterization = false; bool enable_oop_rasterization = false;
bool disable_oop_rasterization = false; bool disable_oop_rasterization = false;
bool enable_oop_rasterization_ddl = false;
// Start the watchdog suspended, as the app is already backgrounded and won't // Start the watchdog suspended, as the app is already backgrounded and won't
// send a background/suspend signal. // send a background/suspend signal.
bool watchdog_starts_backgrounded = false; bool watchdog_starts_backgrounded = false;
......
...@@ -62,6 +62,7 @@ struct GpuPreferences { ...@@ -62,6 +62,7 @@ struct GpuPreferences {
bool ignore_gpu_blacklist; bool ignore_gpu_blacklist;
bool enable_oop_rasterization; bool enable_oop_rasterization;
bool disable_oop_rasterization; bool disable_oop_rasterization;
bool enable_oop_rasterization_ddl;
bool watchdog_starts_backgrounded; bool watchdog_starts_backgrounded;
bool enable_vulkan; bool enable_vulkan;
bool enable_gpu_benchmarking_extension; bool enable_gpu_benchmarking_extension;
......
...@@ -118,6 +118,7 @@ struct StructTraits<gpu::mojom::GpuPreferencesDataView, gpu::GpuPreferences> { ...@@ -118,6 +118,7 @@ struct StructTraits<gpu::mojom::GpuPreferencesDataView, gpu::GpuPreferences> {
out->ignore_gpu_blacklist = prefs.ignore_gpu_blacklist(); out->ignore_gpu_blacklist = prefs.ignore_gpu_blacklist();
out->enable_oop_rasterization = prefs.enable_oop_rasterization(); out->enable_oop_rasterization = prefs.enable_oop_rasterization();
out->disable_oop_rasterization = prefs.disable_oop_rasterization(); out->disable_oop_rasterization = prefs.disable_oop_rasterization();
out->enable_oop_rasterization_ddl = prefs.enable_oop_rasterization_ddl();
out->watchdog_starts_backgrounded = prefs.watchdog_starts_backgrounded(); out->watchdog_starts_backgrounded = prefs.watchdog_starts_backgrounded();
out->enable_vulkan = prefs.enable_vulkan(); out->enable_vulkan = prefs.enable_vulkan();
out->enable_gpu_benchmarking_extension = out->enable_gpu_benchmarking_extension =
...@@ -256,6 +257,9 @@ struct StructTraits<gpu::mojom::GpuPreferencesDataView, gpu::GpuPreferences> { ...@@ -256,6 +257,9 @@ struct StructTraits<gpu::mojom::GpuPreferencesDataView, gpu::GpuPreferences> {
static bool disable_oop_rasterization(const gpu::GpuPreferences& prefs) { static bool disable_oop_rasterization(const gpu::GpuPreferences& prefs) {
return prefs.disable_oop_rasterization; return prefs.disable_oop_rasterization;
} }
static bool enable_oop_rasterization_ddl(const gpu::GpuPreferences& prefs) {
return prefs.enable_oop_rasterization_ddl;
}
static bool watchdog_starts_backgrounded(const gpu::GpuPreferences& prefs) { static bool watchdog_starts_backgrounded(const gpu::GpuPreferences& prefs) {
return prefs.watchdog_starts_backgrounded; return prefs.watchdog_starts_backgrounded;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment