Commit f532c2da authored by Malay Keshav's avatar Malay Keshav Committed by Commit Bot

Viz: Use glClear to draw solid color draw quads when possible

This patch uses glClear to draw the solid color draw quad whenever
possible. It also replaces the usage of color transform matrix used
in the fragment shader for solid color draw quad with a precomputed
color that is in the correct color space.

Improves draw time of a full screen solid color quad by approximately
80% on Atlas. (From ~1.5ms to about ~0.25ms)

Also adds a feature flag that is disabled by default and will be enabled
in subsequent CLs. (For easy revert of feature)

Bug: 1072895,1072910
Test: Manually tested on Chrome OS
Change-Id: I0d0174bffa802d146bce26f985bc3150e051dc05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2343970
Commit-Queue: Malay Keshav <malaykeshav@chromium.org>
Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813018}
parent 7ee16fb5
...@@ -42,6 +42,10 @@ const base::Feature kDynamicColorGamut{"DynamicColorGamut", ...@@ -42,6 +42,10 @@ const base::Feature kDynamicColorGamut{"DynamicColorGamut",
base::FEATURE_ENABLED_BY_DEFAULT}; base::FEATURE_ENABLED_BY_DEFAULT};
#endif #endif
// Uses glClear to composite solid color quads whenever possible.
const base::Feature kFastSolidColorDraw{"FastSolidColorDraw",
base::FEATURE_DISABLED_BY_DEFAULT};
// Viz for WebView architecture. // Viz for WebView architecture.
const base::Feature kVizForWebView{"VizForWebView", const base::Feature kVizForWebView{"VizForWebView",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
...@@ -127,6 +131,10 @@ bool IsDynamicColorGamutEnabled() { ...@@ -127,6 +131,10 @@ bool IsDynamicColorGamutEnabled() {
} }
#endif #endif
bool IsUsingFastPathForSolidColorQuad() {
return base::FeatureList::IsEnabled(kFastSolidColorDraw);
}
bool IsUsingVizForWebView() { bool IsUsingVizForWebView() {
// Viz for WebView requires shared images to be enabled. // Viz for WebView requires shared images to be enabled.
if (!base::FeatureList::IsEnabled(kEnableSharedImageForWebview)) if (!base::FeatureList::IsEnabled(kEnableSharedImageForWebview))
......
...@@ -20,6 +20,7 @@ VIZ_COMMON_EXPORT extern const base::Feature kDisableDeJelly; ...@@ -20,6 +20,7 @@ VIZ_COMMON_EXPORT extern const base::Feature kDisableDeJelly;
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
VIZ_COMMON_EXPORT extern const base::Feature kDynamicColorGamut; VIZ_COMMON_EXPORT extern const base::Feature kDynamicColorGamut;
#endif #endif
VIZ_COMMON_EXPORT extern const base::Feature kFastSolidColorDraw;
VIZ_COMMON_EXPORT extern const base::Feature kVizForWebView; VIZ_COMMON_EXPORT extern const base::Feature kVizForWebView;
VIZ_COMMON_EXPORT extern const base::Feature kVizFrameSubmissionForWebView; VIZ_COMMON_EXPORT extern const base::Feature kVizFrameSubmissionForWebView;
VIZ_COMMON_EXPORT extern const base::Feature kUsePreferredIntervalForVideo; VIZ_COMMON_EXPORT extern const base::Feature kUsePreferredIntervalForVideo;
...@@ -38,6 +39,7 @@ VIZ_COMMON_EXPORT bool IsUsingSkiaRenderer(); ...@@ -38,6 +39,7 @@ VIZ_COMMON_EXPORT bool IsUsingSkiaRenderer();
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
VIZ_COMMON_EXPORT bool IsDynamicColorGamutEnabled(); VIZ_COMMON_EXPORT bool IsDynamicColorGamutEnabled();
#endif #endif
VIZ_COMMON_EXPORT bool IsUsingFastPathForSolidColorQuad();
VIZ_COMMON_EXPORT bool IsUsingVizForWebView(); VIZ_COMMON_EXPORT bool IsUsingVizForWebView();
VIZ_COMMON_EXPORT bool IsUsingVizFrameSubmissionForWebView(); VIZ_COMMON_EXPORT bool IsUsingVizFrameSubmissionForWebView();
VIZ_COMMON_EXPORT bool IsUsingPreferredIntervalForVideo(); VIZ_COMMON_EXPORT bool IsUsingPreferredIntervalForVideo();
......
...@@ -372,6 +372,10 @@ class VIZ_SERVICE_EXPORT GLRenderer : public DirectRenderer { ...@@ -372,6 +372,10 @@ class VIZ_SERVICE_EXPORT GLRenderer : public DirectRenderer {
bool HasOutputColorMatrix() const; bool HasOutputColorMatrix() const;
// Returns true if the given solid color draw quad can be safely drawn using
// the glClear function call.
bool CanUseFastSolidColorDraw(const SolidColorDrawQuad* quad) const;
// A map from RenderPass id to the texture used to draw the RenderPass from. // A map from RenderPass id to the texture used to draw the RenderPass from.
base::flat_map<AggregatedRenderPassId, ScopedRenderPassTexture> base::flat_map<AggregatedRenderPassId, ScopedRenderPassTexture>
render_pass_textures_; render_pass_textures_;
...@@ -454,6 +458,7 @@ class VIZ_SERVICE_EXPORT GLRenderer : public DirectRenderer { ...@@ -454,6 +458,7 @@ class VIZ_SERVICE_EXPORT GLRenderer : public DirectRenderer {
bool use_timer_query_ = false; bool use_timer_query_ = false;
bool use_occlusion_query_ = false; bool use_occlusion_query_ = false;
bool use_swap_with_bounds_ = false; bool use_swap_with_bounds_ = false;
bool use_fast_path_solid_color_quad_ = false;
// If true, tints all the composited content to red. // If true, tints all the composited content to red.
bool tint_gl_composited_content_ = true; bool tint_gl_composited_content_ = true;
...@@ -477,6 +482,9 @@ class VIZ_SERVICE_EXPORT GLRenderer : public DirectRenderer { ...@@ -477,6 +482,9 @@ class VIZ_SERVICE_EXPORT GLRenderer : public DirectRenderer {
// quad type as string. // quad type as string.
base::queue<std::pair<unsigned, std::string>> timer_queries_; base::queue<std::pair<unsigned, std::string>> timer_queries_;
// Keeps track of areas that have been drawn to in the current render pass.
std::vector<gfx::Rect> drawn_rects_;
// This may be null if the compositor is run on a thread without a // This may be null if the compositor is run on a thread without a
// MessageLoop. // MessageLoop.
scoped_refptr<base::SingleThreadTaskRunner> current_task_runner_; scoped_refptr<base::SingleThreadTaskRunner> current_task_runner_;
......
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