| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "cc/output/overlay_strategy_common.h" | |
| 6 | |
| 7 #include "cc/quads/solid_color_draw_quad.h" | |
| 8 | |
| 9 namespace cc { | |
| 10 | |
| 11 OverlayStrategyCommon::OverlayStrategyCommon( | |
| 12 OverlayCandidateValidator* capability_checker, | |
| 13 OverlayStrategyCommonDelegate* delegate) | |
| 14 : capability_checker_(capability_checker), delegate_(delegate) {} | |
| 15 | |
| 16 OverlayStrategyCommon::~OverlayStrategyCommon() { | |
| 17 } | |
| 18 | |
| 19 bool OverlayStrategyCommon::Attempt(RenderPassList* render_passes_in_draw_order, | |
| 20 OverlayCandidateList* candidate_list, | |
| 21 float device_scale_factor) { | |
| 22 if (!capability_checker_) | |
| 23 return false; | |
| 24 RenderPass* root_render_pass = render_passes_in_draw_order->back(); | |
| 25 DCHECK(root_render_pass); | |
| 26 | |
| 27 bool created_overlay = false; | |
| 28 QuadList& quad_list = root_render_pass->quad_list; | |
| 29 for (auto it = quad_list.begin(); it != quad_list.end();) { | |
| 30 OverlayCandidate candidate; | |
| 31 if (!OverlayCandidate::FromDrawQuad(*it, &candidate)) { | |
| 32 ++it; | |
| 33 continue; | |
| 34 } | |
| 35 | |
| 36 OverlayResult result = delegate_->TryOverlay( | |
| 37 capability_checker_, render_passes_in_draw_order, candidate_list, | |
| 38 candidate, &it, device_scale_factor); | |
| 39 switch (result) { | |
| 40 case DID_NOT_CREATE_OVERLAY: | |
| 41 ++it; | |
| 42 break; | |
| 43 case CREATED_OVERLAY_STOP_LOOKING: | |
| 44 return true; | |
| 45 case CREATED_OVERLAY_KEEP_LOOKING: | |
| 46 created_overlay = true; | |
| 47 break; | |
| 48 } | |
| 49 } | |
| 50 | |
| 51 return created_overlay; | |
| 52 } | |
| 53 | |
| 54 // static | |
| 55 bool OverlayStrategyCommon::IsInvisibleQuad(const DrawQuad* draw_quad) { | |
| 56 if (draw_quad->material == DrawQuad::SOLID_COLOR) { | |
| 57 const SolidColorDrawQuad* solid_quad = | |
| 58 SolidColorDrawQuad::MaterialCast(draw_quad); | |
| 59 SkColor color = solid_quad->color; | |
| 60 float opacity = solid_quad->shared_quad_state->opacity; | |
| 61 float alpha = (SkColorGetA(color) * (1.0f / 255.0f)) * opacity; | |
| 62 return solid_quad->ShouldDrawWithBlending() && | |
| 63 alpha < std::numeric_limits<float>::epsilon(); | |
| 64 } | |
| 65 return false; | |
| 66 } | |
| 67 | |
| 68 } // namespace cc | |
| OLD | NEW |