Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2461)

Unified Diff: cc/output/direct_renderer.cc

Issue 2743663006: Allow switching DirectCompositionSurfaceWin between drawing modes. (Closed)
Patch Set: fix release current in resize Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/output/direct_renderer.cc
diff --git a/cc/output/direct_renderer.cc b/cc/output/direct_renderer.cc
index 3819e7e3dd87f8bd9e848c6601bc38830400580b..83530d3645307842cfdec7bad4ecf5b802807fc0 100644
--- a/cc/output/direct_renderer.cc
+++ b/cc/output/direct_renderer.cc
@@ -25,6 +25,7 @@
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/transform.h"
+namespace {
static gfx::Transform OrthoProjectionMatrix(float left,
float right,
float bottom,
@@ -62,6 +63,13 @@ static gfx::Transform window_matrix(int x, int y, int width, int height) {
return canvas;
}
+// Switching between enabling DC layers and not is expensive, so only
+// switch away after a large number of frames not needing DC layers have
+// been produced.
+const int kNumberOfFramesBeforeDisablingDCLayers = 60;
+
+} // namespace
+
namespace cc {
DirectRenderer::DrawingFrame::DrawingFrame() = default;
@@ -87,8 +95,8 @@ void DirectRenderer::Initialize() {
if (context_provider) {
if (context_provider->ContextCapabilities().commit_overlay_planes)
allow_empty_swap_ = true;
- if (context_provider->ContextCapabilities().set_draw_rectangle)
- use_set_draw_rectangle_ = true;
+ if (context_provider->ContextCapabilities().dc_layers)
+ supports_dc_layers_ = true;
}
initialized_ = true;
@@ -314,6 +322,24 @@ void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order,
&current_frame()->dc_layer_overlay_list,
&current_frame()->root_damage_rect,
&current_frame()->root_content_bounds);
+ if (!current_frame()->dc_layer_overlay_list.empty()) {
+ if (!using_dc_layers_) {
+ DCHECK(supports_dc_layers_);
+ using_dc_layers_ = true;
+ current_frame()->root_damage_rect =
+ current_frame()->root_render_pass->output_rect;
+ }
+ frames_since_using_dc_layers_ = 0;
+ } else {
+ if (++frames_since_using_dc_layers_ >=
+ kNumberOfFramesBeforeDisablingDCLayers) {
+ if (using_dc_layers_) {
+ using_dc_layers_ = false;
+ current_frame()->root_damage_rect =
+ current_frame()->root_render_pass->output_rect;
+ }
+ }
+ }
// We can skip all drawing if the damage rect is now empty.
bool skip_drawing_root_render_pass =
@@ -523,7 +549,7 @@ void DirectRenderer::DrawRenderPass(const RenderPass* render_pass) {
// outside the damage rectangle, even if the damage rectangle is the size of
// the full backbuffer.
bool render_pass_is_clipped =
- (use_set_draw_rectangle_ && is_root_render_pass) ||
+ (supports_dc_layers_ && is_root_render_pass) ||
!render_pass_scissor_in_draw_space.Contains(surface_rect_in_draw_space);
bool has_external_stencil_test =
is_root_render_pass && output_surface_->HasExternalStencilTest();
@@ -597,8 +623,10 @@ bool DirectRenderer::UseRenderPass(const RenderPass* render_pass) {
if (render_pass == current_frame()->root_render_pass) {
BindFramebufferToOutputSurface();
- if (use_set_draw_rectangle_)
+ if (supports_dc_layers_) {
+ SetEnableDCLayers(using_dc_layers_);
output_surface_->SetDrawRectangle(current_frame()->root_damage_rect);
+ }
InitializeViewport(current_frame(), render_pass->output_rect,
gfx::Rect(current_frame()->device_viewport_size),
current_frame()->device_viewport_size);

Powered by Google App Engine
This is Rietveld 408576698