Commit 1bd879ed authored by Shao-Chuan Lee's avatar Shao-Chuan Lee Committed by Commit Bot

Revert "viz: Use Build Flags to Maintain Single Overlay Candidate Type"

This reverts commit b8dd353f.

Reason for revert: parent CL crrev.com/c/1725033 breaks betty-arcnext-chrome-pfq

Original change's description:
> viz: Use Build Flags to Maintain Single Overlay Candidate Type
>
> For each platform, we only use one overlay candidate type. Use build
> flags to manage that. This also helps unify different platform's
> ProcessForOverlay API.
>
> R=​rjkroege
>
> Bug: 963597
> Change-Id: Icf0de8b30928cb4e7c23a3573eb46591191fb804
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1664476
> Commit-Queue: weiliangc <weiliangc@chromium.org>
> Reviewed-by: Robert Kroeger <rjkroege@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#680522}

TBR=rjkroege@chromium.org,weiliangc@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 963597, 988114
Change-Id: I0a97ba8e96bdd5abe4f6250ad2f681a23327e282
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1725434
Commit-Queue: Shao-Chuan Lee <shaochuan@chromium.org>
Reviewed-by: default avatarShao-Chuan Lee <shaochuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682181}
parent 3b94fb21
......@@ -17,8 +17,12 @@ viz_component("service") {
"display/bsp_tree.h",
"display/bsp_walk_action.cc",
"display/bsp_walk_action.h",
"display/ca_layer_overlay.cc",
"display/ca_layer_overlay.h",
"display/color_lut_cache.cc",
"display/color_lut_cache.h",
"display/dc_layer_overlay.cc",
"display/dc_layer_overlay.h",
"display/direct_renderer.cc",
"display/direct_renderer.h",
"display/display.cc",
......@@ -231,8 +235,6 @@ viz_component("service") {
if (is_mac) {
sources += [
"display/ca_layer_overlay.cc",
"display/ca_layer_overlay.h",
"display_embedder/overlay_candidate_validator_mac.cc",
"display_embedder/overlay_candidate_validator_mac.h",
"display_embedder/software_output_device_mac.cc",
......@@ -277,8 +279,6 @@ viz_component("service") {
if (is_win) {
sources += [
"display/dc_layer_overlay.cc",
"display/dc_layer_overlay.h",
"display_embedder/output_device_backing.cc",
"display_embedder/output_device_backing.h",
"display_embedder/overlay_candidate_validator_win.cc",
......@@ -399,6 +399,7 @@ viz_source_set("unit_tests") {
"display/gl_renderer_copier_unittest.cc",
"display/gl_renderer_unittest.cc",
"display/layer_quad_unittest.cc",
"display/overlay_unittest.cc",
"display/renderer_pixeltest.cc",
"display/shader_unittest.cc",
"display/software_renderer_unittest.cc",
......@@ -462,10 +463,7 @@ viz_source_set("unit_tests") {
]
if (use_ozone) {
sources += [
"display/overlay_unittest.cc",
"display_embedder/software_output_device_ozone_unittest.cc",
]
sources += [ "display_embedder/software_output_device_ozone_unittest.cc" ]
deps += [
"//ui/compositor:test_support",
"//ui/ozone",
......@@ -473,23 +471,16 @@ viz_source_set("unit_tests") {
}
if (is_mac) {
sources += [
"display/overlay_ca_unittest.cc",
"display_embedder/software_output_device_mac_unittest.mm",
]
sources += [ "display_embedder/software_output_device_mac_unittest.mm" ]
libs = [ "IOSurface.framework" ]
}
if (is_win) {
sources += [
"display/overlay_dc_unittest.cc",
"display_embedder/output_device_backing_unittest.cc",
]
sources += [ "display_embedder/output_device_backing_unittest.cc" ]
}
if (is_android) {
sources += [
"display/overlay_unittest.cc",
"display_embedder/overlay_candidate_validator_surface_control_unittest.cc",
"frame_sinks/external_begin_frame_source_android_unittest.cc",
]
......
......@@ -33,7 +33,7 @@ include_rules = [
]
specific_include_rules = {
"dc_layer_overlay.cc|overlay_dc_unittest.cc": [
"dc_layer_overlay.cc|overlay_unittest.cc": [
# TODO(danakj): gl_switches.h brings runtime flags into the compositor which
# makes testing coverage harder/less clear, it should not be here.
"+ui/gl/gl_switches.h",
......
......@@ -69,12 +69,10 @@ static gfx::Transform window_matrix(int x, int y, int width, int height) {
return canvas;
}
#if defined(OS_WIN)
// 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.
constexpr int kNumberOfFramesBeforeDisablingDCLayers = 60;
#endif // defined(OS_WIN)
// Returns the bounding box that contains the specified rounded corner.
gfx::RectF ComputeRoundedCornerBoundingBox(const gfx::RRectF& rrect,
......@@ -130,10 +128,8 @@ void DirectRenderer::Initialize() {
if (context_provider) {
if (context_provider->ContextCapabilities().commit_overlay_planes)
allow_empty_swap_ = true;
#if defined(OS_WIN)
if (context_provider->ContextCapabilities().dc_layers)
supports_dc_layers_ = true;
#endif
if (context_provider->ContextCapabilities()
.disable_non_empty_post_sub_buffers) {
use_partial_swap_ = false;
......@@ -384,6 +380,8 @@ void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order,
resource_provider_, render_passes_in_draw_order,
output_surface_->color_matrix(), render_pass_filters_,
render_pass_backdrop_filters_, &current_frame()->overlay_list,
&current_frame()->ca_layer_overlay_list,
&current_frame()->dc_layer_overlay_list,
&current_frame()->root_damage_rect,
&current_frame()->root_content_bounds);
......@@ -394,9 +392,8 @@ void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order,
reshape_device_color_space_);
}
#if defined(OS_WIN)
bool was_using_dc_layers = using_dc_layers_;
if (!current_frame()->overlay_list.empty()) {
if (!current_frame()->dc_layer_overlay_list.empty()) {
DCHECK(supports_dc_layers_);
using_dc_layers_ = true;
frames_since_using_dc_layers_ = 0;
......@@ -407,7 +404,6 @@ void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order,
if (supports_dc_layers_ && (was_using_dc_layers != using_dc_layers_))
SetEnableDCLayers(using_dc_layers_);
#endif
// Draw all non-root render passes except for the root render pass.
for (const auto& pass : *render_passes_in_draw_order) {
......@@ -416,7 +412,6 @@ void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order,
DrawRenderPassAndExecuteCopyRequests(pass.get());
}
#if defined(OS_WIN)
if (supports_dc_layers_ &&
(did_reshape || (was_using_dc_layers != using_dc_layers_))) {
// The entire surface has to be redrawn if it was reshaped or if switching
......@@ -424,7 +419,6 @@ void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order,
// discarded and some contents would otherwise be undefined.
current_frame()->root_damage_rect = gfx::Rect(device_viewport_size);
}
#endif
// We can skip all drawing if the damage rect is now empty.
bool skip_drawing_root_render_pass =
......@@ -652,10 +646,8 @@ void DirectRenderer::DrawRenderPass(const RenderPass* render_pass) {
// set on the root framebuffer or else the rendering may modify something
// outside the damage rectangle, even if the damage rectangle is the size of
// the full backbuffer.
bool render_pass_requires_scissor = render_pass_is_clipped;
#if defined(OS_WIN)
render_pass_requires_scissor |= (supports_dc_layers_ && is_root_render_pass);
#endif
bool render_pass_requires_scissor =
(supports_dc_layers_ && is_root_render_pass) || render_pass_is_clipped;
bool has_external_stencil_test =
is_root_render_pass && output_surface_->HasExternalStencilTest();
bool should_clear_surface =
......@@ -760,7 +752,6 @@ void DirectRenderer::UseRenderPass(const RenderPass* render_pass) {
current_frame()->current_render_pass = render_pass;
if (render_pass == current_frame()->root_render_pass) {
BindFramebufferToOutputSurface();
output_surface_->SetDrawRectangle(current_frame()->root_damage_rect);
InitializeViewport(current_frame(), render_pass->output_rect,
gfx::Rect(current_frame()->device_viewport_size),
......
......@@ -12,8 +12,9 @@
#include "base/containers/circular_deque.h"
#include "base/containers/flat_map.h"
#include "base/macros.h"
#include "build/build_config.h"
#include "components/viz/common/quads/tile_draw_quad.h"
#include "components/viz/service/display/ca_layer_overlay.h"
#include "components/viz/service/display/dc_layer_overlay.h"
#include "components/viz/service/display/display_resource_provider.h"
#include "components/viz/service/display/overlay_processor.h"
#include "components/viz/service/viz_service_export.h"
......@@ -89,7 +90,9 @@ class VIZ_SERVICE_EXPORT DirectRenderer {
gfx::Transform projection_matrix;
gfx::Transform window_matrix;
OverlayProcessor::CandidateList overlay_list;
OverlayCandidateList overlay_list;
CALayerOverlayList ca_layer_overlay_list;
DCLayerOverlayList dc_layer_overlay_list;
// When we have buffer queue, the output surface could be treated as an
// overlay plane, and the struct to store that information is in
// |output_surface_plane|.
......@@ -235,7 +238,6 @@ class VIZ_SERVICE_EXPORT DirectRenderer {
bool use_partial_swap_ = false;
// Whether overdraw feedback is enabled and can be used.
bool overdraw_feedback_ = false;
#if defined(OS_WIN)
// Whether the SetDrawRectangle and EnableDCLayers commands are in
// use.
bool supports_dc_layers_ = false;
......@@ -244,7 +246,6 @@ class VIZ_SERVICE_EXPORT DirectRenderer {
// This counts the number of draws since the last time
// DirectComposition layers needed to be used.
int frames_since_using_dc_layers_ = 0;
#endif
// A map from RenderPass id to the single quad present in and replacing the
// RenderPass.
......
......@@ -2235,8 +2235,6 @@ void GLRenderer::DrawYUVVideoQuad(const YUVVideoDrawQuad* quad,
gfx::ColorSpace dst_color_space =
current_frame()->current_render_pass->color_space;
#if defined(OS_WIN)
// Force sRGB output on Windows for overlay candidate video quads to match
// DirectComposition behavior in case these switch between overlays and
// compositing. See https://crbug.com/811118 for details.
......@@ -2245,7 +2243,6 @@ void GLRenderer::DrawYUVVideoQuad(const YUVVideoDrawQuad* quad,
DCHECK(resource_provider_->IsOverlayCandidate(quad->u_plane_resource_id()));
dst_color_space = gfx::ColorSpace::CreateSRGB();
}
#endif
// TODO(jbauman): Use base::Optional when available.
std::unique_ptr<DisplayResourceProvider::ScopedSamplerGL> v_plane_lock;
......@@ -2670,13 +2667,9 @@ void GLRenderer::FinishDrawingFrame() {
// semantics during overlay refactoring.
ScheduleOutputSurfaceAsOverlay();
#if defined(OS_ANDROID) || defined(USE_OZONE)
ScheduleOverlays();
#elif defined(OS_MACOSX)
ScheduleCALayers();
#elif defined(OS_WIN)
ScheduleDCLayers();
#endif
ScheduleOverlays();
TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("viz.triangles"), "Triangles Drawn",
num_triangles_drawn_);
......@@ -3305,7 +3298,6 @@ bool GLRenderer::IsContextLost() {
return gl_->GetGraphicsResetStatusKHR() != GL_NO_ERROR;
}
#if defined(OS_MACOSX)
void GLRenderer::ScheduleCALayers() {
// The use of OverlayTextures for RenderPasses is only supported on the code
// paths for |release_overlay_resources_after_gpu_query| at the moment. See
......@@ -3318,7 +3310,8 @@ void GLRenderer::ScheduleCALayers() {
scoped_refptr<CALayerOverlaySharedState> shared_state;
size_t copied_render_pass_count = 0;
for (const CALayerOverlay& ca_layer_overlay : current_frame()->overlay_list) {
for (const CALayerOverlay& ca_layer_overlay :
current_frame()->ca_layer_overlay_list) {
if (ca_layer_overlay.rpdq) {
std::unique_ptr<OverlayTexture> overlay_texture =
ScheduleRenderPassDrawQuad(&ca_layer_overlay);
......@@ -3378,11 +3371,10 @@ void GLRenderer::ScheduleCALayers() {
ReduceAvailableOverlayTextures();
}
#endif // defined(OS_MACOSX)
#if defined(OS_WIN)
void GLRenderer::ScheduleDCLayers() {
for (DCLayerOverlay& dc_layer_overlay : current_frame()->overlay_list) {
for (DCLayerOverlay& dc_layer_overlay :
current_frame()->dc_layer_overlay_list) {
ResourceId resource_ids[] = {dc_layer_overlay.y_resource_id,
dc_layer_overlay.uv_resource_id};
GLuint texture_ids[2] = {};
......@@ -3423,9 +3415,7 @@ void GLRenderer::ScheduleDCLayers() {
clip_rect.height(), protected_video_type);
}
}
#endif // defined (OS_WIN)
#if defined(OS_ANDROID) || defined(USE_OZONE)
void GLRenderer::ScheduleOverlays() {
if (current_frame()->overlay_list.empty())
return;
......@@ -3444,7 +3434,6 @@ void GLRenderer::ScheduleOverlays() {
overlay_candidate.gpu_fence_id);
}
}
#endif // defined(OS_ANDROID) || defined(USE_OZONE)
void GLRenderer::ScheduleOutputSurfaceAsOverlay() {
if (!current_frame()->output_surface_plane)
......@@ -3465,7 +3454,6 @@ void GLRenderer::ScheduleOutputSurfaceAsOverlay() {
overlay_candidate.enable_blending, overlay_candidate.gpu_fence_id);
}
#if defined(OS_MACOSX)
// This function draws the RenderPassDrawQuad into a temporary
// texture/framebuffer, and then copies the result into an IOSurface. The
// inefficient (but simple) way to do this would be to:
......@@ -3739,7 +3727,6 @@ GLRenderer::ScheduleRenderPassDrawQuad(const CALayerOverlay* ca_layer_overlay) {
filter);
return overlay_texture;
}
#endif // defined(OS_MACOSX)
void GLRenderer::SetupOverdrawFeedback() {
gl_->StencilFunc(GL_ALWAYS, 1, 0xffffffff);
......
......@@ -13,7 +13,6 @@
#include "base/cancelable_callback.h"
#include "base/containers/circular_deque.h"
#include "base/macros.h"
#include "build/build_config.h"
#include "components/viz/common/gpu/context_cache_controller.h"
#include "components/viz/common/quads/debug_border_draw_quad.h"
#include "components/viz/common/quads/render_pass_draw_quad.h"
......@@ -32,14 +31,6 @@
#include "ui/gfx/geometry/quad_f.h"
#include "ui/latency/latency_info.h"
#if defined(OS_MACOSX)
#include "components/viz/service/display/ca_layer_overlay.h"
#endif
#if defined(OS_WIN)
#include "components/viz/service/display/dc_layer_overlay.h"
#endif
namespace base {
class SingleThreadTaskRunner;
}
......@@ -309,16 +300,9 @@ class VIZ_SERVICE_EXPORT GLRenderer : public DirectRenderer {
// nothing.
void ScheduleOutputSurfaceAsOverlay();
// Schedule overlays sends overlay candidate to the GPU.
#if defined(OS_ANDROID) || defined(USE_OZONE)
void ScheduleOverlays();
#elif defined(OS_MACOSX)
void ScheduleCALayers();
// Schedules the |ca_layer_overlay|, which is guaranteed to have a non-null
// |rpdq| parameter. Returns ownership of a GL texture that contains the
// output of the RenderPassDrawQuad.
std::unique_ptr<OverlayTexture> ScheduleRenderPassDrawQuad(
const CALayerOverlay* ca_layer_overlay);
void ScheduleDCLayers();
void ScheduleOverlays();
// Copies the contents of the render pass draw quad, including filter effects,
// to a GL texture, returned in |overlay_texture|. The resulting texture may
......@@ -335,9 +319,11 @@ class VIZ_SERVICE_EXPORT GLRenderer : public DirectRenderer {
const gfx::ColorSpace& color_space);
void ReduceAvailableOverlayTextures();
#elif defined(OS_WIN)
void ScheduleDCLayers();
#endif
// Schedules the |ca_layer_overlay|, which is guaranteed to have a non-null
// |rpdq| parameter. Returns ownership of a GL texture that contains the
// output of the RenderPassDrawQuad.
std::unique_ptr<OverlayTexture> ScheduleRenderPassDrawQuad(
const CALayerOverlay* ca_layer_overlay);
// Setup/flush all pending overdraw feedback to framebuffer.
void SetupOverdrawFeedback();
......
......@@ -2321,13 +2321,9 @@ TEST_F(GLRendererTest, DontOverlayWithCopyRequests) {
// added a fake strategy, so checking for Attempt calls checks if there was
// any attempt to overlay, which there shouldn't be. We can't use the quad
// list because the render pass is cleaned up by DrawFrame.
#if defined(USE_OZONE) || defined(OS_ANDROID)
EXPECT_CALL(processor->strategy(), Attempt(_, _, _, _, _, _)).Times(0);
#elif defined(OS_MACOSX)
EXPECT_CALL(*validator, AllowCALayerOverlays()).Times(0);
#elif defined(OS_WIN)
EXPECT_CALL(*validator, AllowDCLayerOverlays()).Times(0);
#endif
DrawFrame(&renderer, viewport_size);
Mock::VerifyAndClearExpectations(&processor->strategy());
Mock::VerifyAndClearExpectations(
......@@ -2346,17 +2342,13 @@ TEST_F(GLRendererTest, DontOverlayWithCopyRequests) {
premultiplied_alpha, gfx::PointF(0, 0), gfx::PointF(1, 1),
SK_ColorTRANSPARENT, vertex_opacity, flipped, nearest_neighbor,
/*secure_output_only=*/false, gfx::ProtectedVideoType::kClear);
#if defined(USE_OZONE) || defined(OS_ANDROID)
EXPECT_CALL(processor->strategy(), Attempt(_, _, _, _, _, _)).Times(1);
#elif defined(OS_MACOSX)
EXPECT_CALL(*validator, AllowCALayerOverlays())
.Times(1)
.WillOnce(::testing::Return(false));
#elif defined(OS_WIN)
EXPECT_CALL(*validator, AllowDCLayerOverlays())
.Times(1)
.WillOnce(::testing::Return(false));
#endif
EXPECT_CALL(processor->strategy(), Attempt(_, _, _, _, _, _)).Times(1);
DrawFrame(&renderer, viewport_size);
// If the CALayerOverlay path is taken, then the ordinary overlay path should
......@@ -2373,17 +2365,10 @@ TEST_F(GLRendererTest, DontOverlayWithCopyRequests) {
premultiplied_alpha, gfx::PointF(0, 0), gfx::PointF(1, 1),
SK_ColorTRANSPARENT, vertex_opacity, flipped, nearest_neighbor,
/*secure_output_only=*/false, gfx::ProtectedVideoType::kClear);
#if defined(OS_MACOSX)
EXPECT_CALL(*validator, AllowCALayerOverlays())
.Times(1)
.WillOnce(::testing::Return(true));
#elif defined(USE_OZONE) || defined(OS_ANDROID)
EXPECT_CALL(processor->strategy(), Attempt(_, _, _, _, _, _)).Times(1);
#elif defined(OS_WIN)
EXPECT_CALL(*validator, AllowDCLayerOverlays())
.Times(1)
.WillOnce(::testing::Return(true));
#endif
EXPECT_CALL(processor->strategy(), Attempt(_, _, _, _, _, _)).Times(0);
DrawFrame(&renderer, viewport_size);
// Transfer resources back from the parent to the child. Set no resources as
......@@ -2442,7 +2427,6 @@ class WaitSyncTokenCountingGLES2Interface : public TestGLES2Interface {
MOCK_METHOD1(WaitSyncTokenCHROMIUM, void(const GLbyte* sync_token));
};
#if defined(USE_OZONE) || defined(OS_ANDROID)
class MockOverlayScheduler {
public:
MOCK_METHOD7(Schedule,
......@@ -2574,7 +2558,6 @@ TEST_F(GLRendererTest, OverlaySyncTokensAreProcessed) {
child_resource_provider->RemoveImportedResource(resource_id);
child_resource_provider->ShutdownAndReleaseAllResources();
}
#endif // defined(USE_OZONE) || defined(OS_ANDROID)
class OutputColorMatrixMockGLES2Interface : public TestGLES2Interface {
public:
......@@ -2829,7 +2812,6 @@ TEST_F(GLRendererPartialSwapTest, NoPartialSwap) {
RunTest(false, false);
}
#if defined(OS_WIN)
TEST_F(GLRendererPartialSwapTest, SetDrawRectangle_PartialSwap) {
RunTest(true, true);
}
......@@ -2967,7 +2949,6 @@ TEST_F(GLRendererTest, DCLayerOverlaySwitch) {
child_resource_provider->RemoveImportedResource(resource_id);
child_resource_provider->ShutdownAndReleaseAllResources();
}
#endif
class GLRendererWithMockContextTest : public ::testing::Test {
protected:
......@@ -3014,7 +2995,6 @@ TEST_F(GLRendererWithMockContextTest,
Mock::VerifyAndClearExpectations(context_support_ptr_);
}
#if defined(USE_OZONE) || defined(OS_ANDROID)
class ContentBoundsOverlayProcessor : public OverlayProcessor {
public:
class Strategy : public OverlayProcessor::Strategy {
......@@ -3048,8 +3028,7 @@ class ContentBoundsOverlayProcessor : public OverlayProcessor {
std::make_unique<Strategy>(std::move(content_bounds_)));
}
// Empty mock methods since this test set up uses strategies, which are only
// for ozone and android.
// Returns true if draw quads can be represented as CALayers (Mac only).
MOCK_CONST_METHOD0(AllowCALayerOverlays, bool());
MOCK_CONST_METHOD0(AllowDCLayerOverlays, bool());
MOCK_CONST_METHOD0(NeedsSurfaceOccludingDamageRect, bool());
......@@ -3142,9 +3121,7 @@ TEST_F(GLRendererSwapWithBoundsTest, NonEmpty) {
content_bounds.push_back(gfx::Rect(20, 20, 30, 30));
RunTest(content_bounds);
}
#endif // defined(USE_OZONE) || defined(OS_ANDROID)
#if defined(OS_MACOSX)
class CALayerValidator : public OverlayCandidateValidator {
public:
bool AllowCALayerOverlays() const override { return true; }
......@@ -4059,7 +4036,6 @@ TEST_F(CALayerGLRendererTest, CALayerOverlaysCachedTexturesAreFreed) {
Mock::VerifyAndClearExpectations(&gl());
renderer().SwapBuffers(std::vector<ui::LatencyInfo>());
}
#endif
class FramebufferWatchingGLRenderer : public FakeRendererGL {
public:
......@@ -4191,7 +4167,6 @@ TEST_F(GLRendererTest, UndamagedRenderPassStillDrawnWhenNoPartialSwap) {
}
}
#if defined(USE_OZONE) || defined(OS_ANDROID)
class GLRendererWithGpuFenceTest : public GLRendererTest {
protected:
GLRendererWithGpuFenceTest() {
......@@ -4316,7 +4291,6 @@ TEST_F(GLRendererWithGpuFenceTest,
.Times(1);
DrawFrame(renderer_.get(), viewport_size);
}
#endif // defined(USE_OZONE) || defined(OS_ANDROID)
} // namespace
} // namespace viz
This diff is collapsed.
This diff is collapsed.
......@@ -43,7 +43,7 @@ class SendPromotionHintsBeforeReturning {
DISALLOW_COPY_AND_ASSIGN(SendPromotionHintsBeforeReturning);
};
#endif // defined(OS_ANDROID)
#endif
} // namespace
......@@ -111,11 +111,9 @@ std::unique_ptr<OverlayProcessor> OverlayProcessor::CreateOverlayProcessor(
return processor;
}
OverlayProcessor::OverlayProcessor(const ContextProvider* context_provider) {
#if defined(OS_WIN)
dc_processor_.reset(new DCLayerOverlayProcessor(context_provider));
#endif // defined(OS_WIN)
}
OverlayProcessor::OverlayProcessor(const ContextProvider* context_provider)
: dc_processor_(
std::make_unique<DCLayerOverlayProcessor>(context_provider)) {}
void OverlayProcessor::SetOverlayCandidateValidator(
std::unique_ptr<OverlayCandidateValidator> overlay_validator) {
......@@ -137,13 +135,9 @@ bool OverlayProcessor::ProcessForCALayers(
RenderPass* render_pass,
const OverlayProcessor::FilterOperationsMap& render_pass_filters,
const OverlayProcessor::FilterOperationsMap& render_pass_backdrop_filters,
CandidateList* ca_layer_overlays,
OverlayCandidateList* overlay_candidates,
CALayerOverlayList* ca_layer_overlays,
gfx::Rect* damage_rect) {
#if defined(OS_MACOSX)
// Skip overlay processing if we have copy request.
if (!render_pass->copy_requests.empty())
return true;
if (!overlay_validator_ || !overlay_validator_->AllowCALayerOverlays())
return false;
......@@ -154,13 +148,12 @@ bool OverlayProcessor::ProcessForCALayers(
return false;
// CALayer overlays are all-or-nothing. If all quads were replaced with
// layers then mark the output surface as already handled.
// layers then clear the list and remove the backbuffer from the overcandidate
// list.
output_surface_already_handled_ = true;
overlay_damage_rect_ = render_pass->output_rect;
*damage_rect = gfx::Rect();
return true;
#endif // defined(OS_MACOSX)
return false;
}
bool OverlayProcessor::ProcessForDCLayers(
......@@ -168,28 +161,18 @@ bool OverlayProcessor::ProcessForDCLayers(
RenderPassList* render_passes,
const OverlayProcessor::FilterOperationsMap& render_pass_filters,
const OverlayProcessor::FilterOperationsMap& render_pass_backdrop_filters,
CandidateList* dc_layer_overlays,
OverlayCandidateList* overlay_candidates,
DCLayerOverlayList* dc_layer_overlays,
gfx::Rect* damage_rect) {
#if defined(OS_WIN)
// Skip overlay processing if we have copy request.
if (!render_passes->back()->copy_requests.empty()) {
damage_rect->Union(
dc_processor_->previous_frame_overlay_damage_contribution());
// Update damage rect before calling ClearOverlayState, otherwise
// previous_frame_overlay_rect_union will be empty.
dc_processor_->ClearOverlayState();
return true;
}
if (!overlay_validator_ || !overlay_validator_->AllowDCLayerOverlays())
return false;
dc_processor_->Process(resource_provider,
gfx::RectF(render_passes->back()->output_rect),
render_passes, damage_rect, dc_layer_overlays);
DCHECK(overlay_candidates->empty());
return true;
#endif
return false;
}
void OverlayProcessor::ProcessForOverlays(
......@@ -198,7 +181,9 @@ void OverlayProcessor::ProcessForOverlays(
const SkMatrix44& output_color_matrix,
const OverlayProcessor::FilterOperationsMap& render_pass_filters,
const OverlayProcessor::FilterOperationsMap& render_pass_backdrop_filters,
CandidateList* candidates,
OverlayCandidateList* candidates,
CALayerOverlayList* ca_layer_overlays,
DCLayerOverlayList* dc_layer_overlays,
gfx::Rect* damage_rect,
std::vector<gfx::Rect>* content_bounds) {
TRACE_EVENT0("viz", "OverlayProcessor::ProcessForOverlays");
......@@ -212,30 +197,39 @@ void OverlayProcessor::ProcessForOverlays(
// Clear to get ready to handle output surface as overlay.
output_surface_already_handled_ = false;
// Reset |previous_frame_underlay_rect_| in case UpdateDamageRect() not being
// invoked. Also reset |previous_frame_underlay_was_unoccluded_|.
const gfx::Rect previous_frame_underlay_rect = previous_frame_underlay_rect_;
previous_frame_underlay_rect_ = gfx::Rect();
bool previous_frame_underlay_was_unoccluded =
previous_frame_underlay_was_unoccluded_;
previous_frame_underlay_was_unoccluded_ = false;
RenderPass* render_pass = render_passes->back().get();
// If we have any copy requests, we can't remove any quads for overlays or
// CALayers because the framebuffer would be missing the removed quads'
// contents.
if (!render_pass->copy_requests.empty()) {
damage_rect->Union(
dc_processor_->previous_frame_overlay_damage_contribution());
// Update damage rect before calling ClearOverlayState, otherwise
// previous_frame_overlay_rect_union will be empty.
dc_processor_->ClearOverlayState();
return;
}
// First attempt to process for CALayers.
if (ProcessForCALayers(resource_provider, render_passes->back().get(),
render_pass_filters, render_pass_backdrop_filters,
candidates, damage_rect)) {
candidates, ca_layer_overlays, damage_rect)) {
return;
}
if (ProcessForDCLayers(resource_provider, render_passes, render_pass_filters,
render_pass_backdrop_filters, candidates,
damage_rect)) {
return;
}
#if !defined(OS_MACOSX) && !defined(OS_WIN)
RenderPass* render_pass = render_passes->back().get();
// If we have any copy requests, we can't remove any quads for overlays or
// CALayers because the framebuffer would be missing the removed quads'
// contents.
if (!render_pass->copy_requests.empty()) {
// Reset |previous_frame_underlay_rect_| in case UpdateDamageRect() not
// being invoked. Also reset |previous_frame_underlay_was_unoccluded_|.
previous_frame_underlay_rect_ = gfx::Rect();
previous_frame_underlay_was_unoccluded_ = false;
dc_layer_overlays, damage_rect)) {
return;
}
......@@ -248,27 +242,22 @@ void OverlayProcessor::ProcessForOverlays(
}
if (success) {
UpdateDamageRect(candidates, previous_frame_underlay_rect_,
previous_frame_underlay_was_unoccluded_,
UpdateDamageRect(candidates, previous_frame_underlay_rect,
previous_frame_underlay_was_unoccluded,
&render_pass->quad_list, damage_rect);
} else {
if (!previous_frame_underlay_rect_.IsEmpty())
damage_rect->Union(previous_frame_underlay_rect_);
if (!previous_frame_underlay_rect.IsEmpty())
damage_rect->Union(previous_frame_underlay_rect);
DCHECK(candidates->empty());
previous_frame_underlay_rect_ = gfx::Rect();
previous_frame_underlay_was_unoccluded_ = false;
}
TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("viz.debug.overlay_planes"),
"Scheduled overlay planes", candidates->size());
#endif
}
// Subtract on-top opaque overlays from the damage rect, unless the overlays
// use the backbuffer as their content (in which case, add their combined rect
// Subtract on-top opaque overlays from the damage rect, unless the overlays use
// the backbuffer as their content (in which case, add their combined rect
// back to the damage at the end).
// Also subtract unoccluded underlays from the damage rect if we know that the
// same underlay was scheduled on the previous frame. If the renderer decides
......@@ -295,12 +284,13 @@ void OverlayProcessor::UpdateDamageRect(
// Track the underlay_rect from frame to frame. If it is the same and
// nothing is on top of it then that rect doesn't need to be damaged
// because the drawing is occurring on a different plane. If it is
// different then that indicates that a different underlay has been
// chosen and the previous underlay rect should be damaged because it
// has changed planes from the underlay plane to the main plane. It then
// checks that this is not a transition from occluded to unoccluded.
// different then that indicates that a different underlay has been chosen
// and the previous underlay rect should be damaged because it has changed
// planes from the underlay plane to the main plane.
// It then checks that this is not a transition from occluded to
// unoccluded.
//
// We also insist that the underlay is unoccluded for at least one frame,
// We also insist that the underlay is unoccluded for at leat one frame,
// else when content above the overlay transitions from not fully
// transparent to fully transparent, we still need to erase it from the
// framebuffer. Otherwise, the last non-transparent frame will remain.
......
......@@ -9,21 +9,14 @@
#include "base/containers/flat_map.h"
#include "base/macros.h"
#include "build/build_config.h"
#include "components/viz/common/display/overlay_strategy.h"
#include "components/viz/common/quads/render_pass.h"
#include "components/viz/service/display/ca_layer_overlay.h"
#include "components/viz/service/display/dc_layer_overlay.h"
#include "components/viz/service/display/overlay_candidate.h"
#include "components/viz/service/viz_service_export.h"
#include "gpu/ipc/common/surface_handle.h"
#if defined(OS_WIN)
#include "components/viz/service/display/dc_layer_overlay.h"
#endif
#if defined(OS_MACOSX)
#include "components/viz/service/display/ca_layer_overlay.h"
#endif
namespace cc {
class DisplayResourceProvider;
}
......@@ -35,19 +28,6 @@ class ContextProvider;
class VIZ_SERVICE_EXPORT OverlayProcessor {
public:
#if defined(OS_ANDROID)
using CandidateList = OverlayCandidateList;
#elif defined(OS_MACOSX)
using CandidateList = CALayerOverlayList;
#elif defined(OS_WIN)
using CandidateList = DCLayerOverlayList;
#elif defined(USE_OZONE)
using CandidateList = OverlayCandidateList;
#else
// Default.
using CandidateList = OverlayCandidateList;
#endif
using FilterOperationsMap =
base::flat_map<RenderPassId, cc::FilterOperations*>;
......@@ -126,7 +106,9 @@ class VIZ_SERVICE_EXPORT OverlayProcessor {
const SkMatrix44& output_color_matrix,
const FilterOperationsMap& render_pass_filters,
const FilterOperationsMap& render_pass_backdrop_filters,
CandidateList* overlay_candidates,
OverlayCandidateList* overlay_candidates,
CALayerOverlayList* ca_layer_overlays,
DCLayerOverlayList* dc_layer_overlays,
gfx::Rect* damage_rect,
std::vector<gfx::Rect>* content_bounds);
......@@ -138,11 +120,9 @@ class VIZ_SERVICE_EXPORT OverlayProcessor {
const gfx::BufferFormat& buffer_format,
const gfx::ColorSpace& color_space) const;
#if defined(OS_WIN)
void SetDCHasHwOverlaySupportForTesting() {
dc_processor_->SetHasHwOverlaySupport();
}
#endif
protected:
explicit OverlayProcessor(const ContextProvider* context_provider);
......@@ -161,14 +141,16 @@ class VIZ_SERVICE_EXPORT OverlayProcessor {
RenderPass* render_pass,
const FilterOperationsMap& render_pass_filters,
const FilterOperationsMap& render_pass_backdrop_filters,
CandidateList* overlay_candidates,
OverlayCandidateList* overlay_candidates,
CALayerOverlayList* ca_layer_overlays,
gfx::Rect* damage_rect);
bool ProcessForDCLayers(
DisplayResourceProvider* resource_provider,
RenderPassList* render_passes,
const FilterOperationsMap& render_pass_filters,
const FilterOperationsMap& render_pass_backdrop_filters,
CandidateList* overlay_candidates,
OverlayCandidateList* overlay_candidates,
DCLayerOverlayList* dc_layer_overlays,
gfx::Rect* damage_rect);
// Update |damage_rect| by removing damage casued by |candidates|.
void UpdateDamageRect(OverlayCandidateList* candidates,
......@@ -177,9 +159,7 @@ class VIZ_SERVICE_EXPORT OverlayProcessor {
const QuadList* quad_list,
gfx::Rect* damage_rect);
#if defined(OS_WIN)
std::unique_ptr<DCLayerOverlayProcessor> dc_processor_;
#endif
bool output_surface_already_handled_;
DISALLOW_COPY_AND_ASSIGN(OverlayProcessor);
......
......@@ -25,10 +25,6 @@ class Size;
struct PresentationFeedback;
} // namespace gfx
namespace gl {
class GLImage;
} // namespace gl
namespace viz {
class SkiaOutputDevice {
......
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