| Index: cc/output/overlay_strategy_common.cc
|
| diff --git a/cc/output/overlay_strategy_single_on_top.cc b/cc/output/overlay_strategy_common.cc
|
| similarity index 52%
|
| copy from cc/output/overlay_strategy_single_on_top.cc
|
| copy to cc/output/overlay_strategy_common.cc
|
| index 71897ed4596cc1f72bc370bba044136649ff0fe3..606e8a514102483a1110b705a69a26f890fe9a2b 100644
|
| --- a/cc/output/overlay_strategy_single_on_top.cc
|
| +++ b/cc/output/overlay_strategy_common.cc
|
| @@ -1,12 +1,11 @@
|
| -// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Copyright 2015 The 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.
|
|
|
| -#include "cc/output/overlay_strategy_single_on_top.h"
|
| +#include "cc/output/overlay_strategy_common.h"
|
|
|
| #include <limits>
|
|
|
| -#include "cc/quads/draw_quad.h"
|
| #include "cc/quads/solid_color_draw_quad.h"
|
| #include "cc/quads/stream_video_draw_quad.h"
|
| #include "cc/quads/texture_draw_quad.h"
|
| @@ -16,30 +15,29 @@
|
|
|
| namespace cc {
|
|
|
| -OverlayStrategySingleOnTop::OverlayStrategySingleOnTop(
|
| - OverlayCandidateValidator* capability_checker,
|
| +OverlayStrategyCommon::OverlayStrategyCommon(
|
| ResourceProvider* resource_provider)
|
| - : capability_checker_(capability_checker),
|
| - resource_provider_(resource_provider) {}
|
| + : resource_provider_(resource_provider) {
|
| +}
|
| +OverlayStrategyCommon::~OverlayStrategyCommon() {
|
| +}
|
|
|
| -bool OverlayStrategySingleOnTop::IsOverlayQuad(const DrawQuad* draw_quad) {
|
| - unsigned int resource_id;
|
| - switch (draw_quad->material) {
|
| - case DrawQuad::TEXTURE_CONTENT:
|
| - resource_id = TextureDrawQuad::MaterialCast(draw_quad)->resource_id;
|
| - break;
|
| - case DrawQuad::STREAM_VIDEO_CONTENT:
|
| - resource_id = StreamVideoDrawQuad::MaterialCast(draw_quad)->resource_id;
|
| - break;
|
| - default:
|
| - return false;
|
| +bool OverlayStrategyCommon::IsInvisibleQuad(const DrawQuad* draw_quad) {
|
| + if (draw_quad->material == DrawQuad::SOLID_COLOR) {
|
| + const SolidColorDrawQuad* solid_quad =
|
| + SolidColorDrawQuad::MaterialCast(draw_quad);
|
| + SkColor color = solid_quad->color;
|
| + float opacity = solid_quad->opacity();
|
| + float alpha = (SkColorGetA(color) * (1.0f / 255.0f)) * opacity;
|
| + // Ignore transparent solid color quads.
|
| + return solid_quad->ShouldDrawWithBlending() &&
|
| + alpha < std::numeric_limits<float>::epsilon();
|
| }
|
| - return resource_provider_->AllowOverlay(resource_id);
|
| + return false;
|
| }
|
|
|
| -bool OverlayStrategySingleOnTop::GetTextureQuadInfo(
|
| - const TextureDrawQuad& quad,
|
| - OverlayCandidate* quad_info) {
|
| +bool OverlayStrategyCommon::GetTextureQuadInfo(const TextureDrawQuad& quad,
|
| + OverlayCandidate* quad_info) {
|
| gfx::OverlayTransform overlay_transform =
|
| OverlayCandidate::GetOverlayTransform(quad.quadTransform(), quad.flipped);
|
| if (quad.background_color != SK_ColorTRANSPARENT ||
|
| @@ -52,9 +50,8 @@ bool OverlayStrategySingleOnTop::GetTextureQuadInfo(
|
| return true;
|
| }
|
|
|
| -bool OverlayStrategySingleOnTop::GetVideoQuadInfo(
|
| - const StreamVideoDrawQuad& quad,
|
| - OverlayCandidate* quad_info) {
|
| +bool OverlayStrategyCommon::GetVideoQuadInfo(const StreamVideoDrawQuad& quad,
|
| + OverlayCandidate* quad_info) {
|
| gfx::OverlayTransform overlay_transform =
|
| OverlayCandidate::GetOverlayTransform(quad.quadTransform(), false);
|
| if (overlay_transform == gfx::OVERLAY_TRANSFORM_INVALID)
|
| @@ -94,9 +91,8 @@ bool OverlayStrategySingleOnTop::GetVideoQuadInfo(
|
| return true;
|
| }
|
|
|
| -bool OverlayStrategySingleOnTop::GetCandidateQuadInfo(
|
| - const DrawQuad& draw_quad,
|
| - OverlayCandidate* quad_info) {
|
| +bool OverlayStrategyCommon::GetCandidateQuadInfo(const DrawQuad& draw_quad,
|
| + OverlayCandidate* quad_info) {
|
| // All quad checks.
|
| if (draw_quad.needs_blending || draw_quad.shared_quad_state->opacity != 1.f ||
|
| draw_quad.shared_quad_state->blend_mode != SkXfermode::kSrcOver_Mode)
|
| @@ -119,78 +115,4 @@ bool OverlayStrategySingleOnTop::GetCandidateQuadInfo(
|
| return true;
|
| }
|
|
|
| -bool OverlayStrategySingleOnTop::IsInvisibleQuad(const DrawQuad* draw_quad) {
|
| - if (draw_quad->material == DrawQuad::SOLID_COLOR) {
|
| - const SolidColorDrawQuad* solid_quad =
|
| - SolidColorDrawQuad::MaterialCast(draw_quad);
|
| - SkColor color = solid_quad->color;
|
| - float opacity = solid_quad->opacity();
|
| - float alpha = (SkColorGetA(color) * (1.0f / 255.0f)) * opacity;
|
| - // Ignore transparent solid color quads.
|
| - return solid_quad->ShouldDrawWithBlending() &&
|
| - alpha < std::numeric_limits<float>::epsilon();
|
| - }
|
| - return false;
|
| -}
|
| -
|
| -bool OverlayStrategySingleOnTop::Attempt(
|
| - RenderPassList* render_passes_in_draw_order,
|
| - OverlayCandidateList* candidate_list) {
|
| - // Only attempt to handle very simple case for now.
|
| - if (!capability_checker_)
|
| - return false;
|
| -
|
| - RenderPass* root_render_pass = render_passes_in_draw_order->back();
|
| - DCHECK(root_render_pass);
|
| -
|
| - OverlayCandidate candidate;
|
| - QuadList& quad_list = root_render_pass->quad_list;
|
| - auto candidate_iterator = quad_list.end();
|
| - for (auto it = quad_list.begin(); it != quad_list.end(); ++it) {
|
| - const DrawQuad* draw_quad = *it;
|
| - if (IsOverlayQuad(draw_quad)) {
|
| - // Check that no prior quads overlap it.
|
| - bool intersects = false;
|
| - gfx::RectF rect = draw_quad->rect;
|
| - draw_quad->quadTransform().TransformRect(&rect);
|
| - for (auto overlap_iter = quad_list.cbegin(); overlap_iter != it;
|
| - ++overlap_iter) {
|
| - gfx::RectF overlap_rect = overlap_iter->rect;
|
| - overlap_iter->quadTransform().TransformRect(&overlap_rect);
|
| - if (rect.Intersects(overlap_rect) && !IsInvisibleQuad(*overlap_iter)) {
|
| - intersects = true;
|
| - break;
|
| - }
|
| - }
|
| - if (intersects || !GetCandidateQuadInfo(*draw_quad, &candidate))
|
| - continue;
|
| - candidate_iterator = it;
|
| - break;
|
| - }
|
| - }
|
| - if (candidate_iterator == quad_list.end())
|
| - return false;
|
| -
|
| - // Add our primary surface.
|
| - OverlayCandidateList candidates;
|
| - OverlayCandidate main_image;
|
| - main_image.display_rect = root_render_pass->output_rect;
|
| - candidates.push_back(main_image);
|
| -
|
| - // Add the overlay.
|
| - candidate.plane_z_order = 1;
|
| - candidates.push_back(candidate);
|
| -
|
| - // Check for support.
|
| - capability_checker_->CheckOverlaySupport(&candidates);
|
| -
|
| - // If the candidate can be handled by an overlay, create a pass for it.
|
| - if (candidates[1].overlay_handled) {
|
| - quad_list.EraseAndInvalidateAllPointers(candidate_iterator);
|
| - candidate_list->swap(candidates);
|
| - return true;
|
| - }
|
| - return false;
|
| -}
|
| -
|
| } // namespace cc
|
|
|