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

Side by Side Diff: cc/output/overlay_candidate.cc

Issue 1372103005: Refactor OverlayStrategySandwich and OverlayStrategyCommon (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@SolidColor
Patch Set: Delete OverlayStrategyCommon Created 5 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/output/overlay_candidate.h" 5 #include "cc/output/overlay_candidate.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 return FromIOSurfaceQuad(IOSurfaceDrawQuad::MaterialCast(quad), 204 return FromIOSurfaceQuad(IOSurfaceDrawQuad::MaterialCast(quad),
205 candidate); 205 candidate);
206 default: 206 default:
207 break; 207 break;
208 } 208 }
209 209
210 return false; 210 return false;
211 } 211 }
212 212
213 // static 213 // static
214 bool OverlayCandidate::IsInvisibleQuad(const DrawQuad* quad) {
215 if (quad->material == DrawQuad::SOLID_COLOR) {
216 SkColor color = SolidColorDrawQuad::MaterialCast(quad)->color;
217 float opacity = quad->shared_quad_state->opacity;
218 float alpha = (SkColorGetA(color) * (1.0f / 255.0f)) * opacity;
219 return quad->ShouldDrawWithBlending() &&
220 alpha < std::numeric_limits<float>::epsilon();
221 }
222 return false;
223 }
224
225 // static
214 bool OverlayCandidate::FromTextureQuad(const TextureDrawQuad* quad, 226 bool OverlayCandidate::FromTextureQuad(const TextureDrawQuad* quad,
215 OverlayCandidate* candidate) { 227 OverlayCandidate* candidate) {
216 if (!quad->allow_overlay()) 228 if (!quad->allow_overlay())
217 return false; 229 return false;
218 gfx::OverlayTransform overlay_transform = GetOverlayTransform( 230 gfx::OverlayTransform overlay_transform = GetOverlayTransform(
219 quad->shared_quad_state->quad_to_target_transform, quad->y_flipped); 231 quad->shared_quad_state->quad_to_target_transform, quad->y_flipped);
220 if (quad->background_color != SK_ColorTRANSPARENT || 232 if (quad->background_color != SK_ColorTRANSPARENT ||
221 quad->premultiplied_alpha || 233 quad->premultiplied_alpha ||
222 overlay_transform == gfx::OVERLAY_TRANSFORM_INVALID) 234 overlay_transform == gfx::OVERLAY_TRANSFORM_INVALID)
223 return false; 235 return false;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 if (overlay_transform != gfx::OVERLAY_TRANSFORM_NONE) 295 if (overlay_transform != gfx::OVERLAY_TRANSFORM_NONE)
284 return false; 296 return false;
285 candidate->resource_id = quad->io_surface_resource_id(); 297 candidate->resource_id = quad->io_surface_resource_id();
286 candidate->resource_size_in_pixels = quad->io_surface_size; 298 candidate->resource_size_in_pixels = quad->io_surface_size;
287 candidate->transform = overlay_transform; 299 candidate->transform = overlay_transform;
288 candidate->uv_rect = gfx::RectF(1.f, 1.f); 300 candidate->uv_rect = gfx::RectF(1.f, 1.f);
289 return true; 301 return true;
290 } 302 }
291 303
292 } // namespace cc 304 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698