OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 16 matching lines...) Expand all Loading... | |
27 #include "cc/quads/solid_color_draw_quad.h" | 27 #include "cc/quads/solid_color_draw_quad.h" |
28 #include "cc/quads/tile_draw_quad.h" | 28 #include "cc/quads/tile_draw_quad.h" |
29 #include "cc/tiles/tile_manager.h" | 29 #include "cc/tiles/tile_manager.h" |
30 #include "cc/tiles/tiling_set_raster_queue_all.h" | 30 #include "cc/tiles/tiling_set_raster_queue_all.h" |
31 #include "cc/trees/layer_tree_impl.h" | 31 #include "cc/trees/layer_tree_impl.h" |
32 #include "cc/trees/occlusion.h" | 32 #include "cc/trees/occlusion.h" |
33 #include "ui/gfx/geometry/quad_f.h" | 33 #include "ui/gfx/geometry/quad_f.h" |
34 #include "ui/gfx/geometry/rect_conversions.h" | 34 #include "ui/gfx/geometry/rect_conversions.h" |
35 #include "ui/gfx/geometry/size_conversions.h" | 35 #include "ui/gfx/geometry/size_conversions.h" |
36 | 36 |
37 #if defined(USE_X11) && !defined(OS_CHROMEOS) | |
38 #include "base/command_line.h" | |
39 #include "ui/gfx/x/x11_switches.h" | |
40 #endif | |
41 | |
37 namespace { | 42 namespace { |
38 // This must be > 1 as we multiply or divide by this to find a new raster | 43 // This must be > 1 as we multiply or divide by this to find a new raster |
39 // scale during pinch. | 44 // scale during pinch. |
40 const float kMaxScaleRatioDuringPinch = 2.0f; | 45 const float kMaxScaleRatioDuringPinch = 2.0f; |
41 | 46 |
42 // When creating a new tiling during pinch, snap to an existing | 47 // When creating a new tiling during pinch, snap to an existing |
43 // tiling's scale if the desired scale is within this ratio. | 48 // tiling's scale if the desired scale is within this ratio. |
44 const float kSnapToExistingTilingRatio = 1.2f; | 49 const float kSnapToExistingTilingRatio = 1.2f; |
45 | 50 |
46 // Even for really wide viewports, at some point GPU raster should use | 51 // Even for really wide viewports, at some point GPU raster should use |
(...skipping 26 matching lines...) Expand all Loading... | |
73 ideal_source_scale_(0.f), | 78 ideal_source_scale_(0.f), |
74 ideal_contents_scale_(0.f), | 79 ideal_contents_scale_(0.f), |
75 raster_page_scale_(0.f), | 80 raster_page_scale_(0.f), |
76 raster_device_scale_(0.f), | 81 raster_device_scale_(0.f), |
77 raster_source_scale_(0.f), | 82 raster_source_scale_(0.f), |
78 raster_contents_scale_(0.f), | 83 raster_contents_scale_(0.f), |
79 low_res_raster_contents_scale_(0.f), | 84 low_res_raster_contents_scale_(0.f), |
80 was_screen_space_transform_animating_(false), | 85 was_screen_space_transform_animating_(false), |
81 only_used_low_res_last_append_quads_(false), | 86 only_used_low_res_last_append_quads_(false), |
82 is_mask_(is_mask), | 87 is_mask_(is_mask), |
83 nearest_neighbor_(false) { | 88 nearest_neighbor_(false), |
89 has_alpha_channel_(true) { | |
84 layer_tree_impl()->RegisterPictureLayerImpl(this); | 90 layer_tree_impl()->RegisterPictureLayerImpl(this); |
91 | |
92 #if defined(USE_X11) && !defined(OS_CHROMEOS) | |
93 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
94 switches::kWindowDepth)) { | |
95 has_alpha_channel_ = | |
96 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
97 switches::kWindowDepth) == "32"; | |
98 } | |
99 #endif | |
trchen
2016/02/25 02:30:12
This doesn't make sense to me. Why does it have to
Julien Isorce Samsung
2016/02/25 11:33:55
You are right it should be static but I found this
| |
85 } | 100 } |
86 | 101 |
87 PictureLayerImpl::~PictureLayerImpl() { | 102 PictureLayerImpl::~PictureLayerImpl() { |
88 if (twin_layer_) | 103 if (twin_layer_) |
89 twin_layer_->twin_layer_ = nullptr; | 104 twin_layer_->twin_layer_ = nullptr; |
90 layer_tree_impl()->UnregisterPictureLayerImpl(this); | 105 layer_tree_impl()->UnregisterPictureLayerImpl(this); |
91 } | 106 } |
92 | 107 |
93 const char* PictureLayerImpl::LayerTypeAsString() const { | 108 const char* PictureLayerImpl::LayerTypeAsString() const { |
94 return "cc::PictureLayerImpl"; | 109 return "cc::PictureLayerImpl"; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
305 // the best the layer can promise in the future, consider those as | 320 // the best the layer can promise in the future, consider those as |
306 // complete. But if a tile is ideal scale, we don't want to consider | 321 // complete. But if a tile is ideal scale, we don't want to consider |
307 // it incomplete and trying to replace it with a tile at a worse | 322 // it incomplete and trying to replace it with a tile at a worse |
308 // scale. | 323 // scale. |
309 if (iter->contents_scale() != raster_contents_scale_ && | 324 if (iter->contents_scale() != raster_contents_scale_ && |
310 iter->contents_scale() != ideal_contents_scale_ && | 325 iter->contents_scale() != ideal_contents_scale_ && |
311 geometry_rect.Intersects(scaled_viewport_for_tile_priority)) { | 326 geometry_rect.Intersects(scaled_viewport_for_tile_priority)) { |
312 append_quads_data->num_incomplete_tiles++; | 327 append_quads_data->num_incomplete_tiles++; |
313 } | 328 } |
314 | 329 |
330 const bool needs_blending = | |
331 has_alpha_channel_ && render_pass->has_transparent_background; | |
315 TileDrawQuad* quad = | 332 TileDrawQuad* quad = |
316 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); | 333 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); |
317 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, | 334 quad->SetAll(shared_quad_state, geometry_rect, opaque_rect, |
318 visible_geometry_rect, draw_info.resource_id(), | 335 visible_geometry_rect, needs_blending, |
trchen
2016/02/25 02:30:12
It doesn't make sense to force blending here, and
Julien Isorce Samsung
2016/02/25 11:33:55
For now all of this is still not clear to me. I'll
| |
319 texture_rect, draw_info.resource_size(), | 336 draw_info.resource_id(), texture_rect, |
320 draw_info.contents_swizzled(), nearest_neighbor_); | 337 draw_info.resource_size(), draw_info.contents_swizzled(), |
338 nearest_neighbor_); | |
321 ValidateQuadResources(quad); | 339 ValidateQuadResources(quad); |
322 iter->draw_info().set_was_ever_used_to_draw(); | 340 iter->draw_info().set_was_ever_used_to_draw(); |
323 has_draw_quad = true; | 341 has_draw_quad = true; |
324 break; | 342 break; |
325 } | 343 } |
326 case TileDrawInfo::SOLID_COLOR_MODE: { | 344 case TileDrawInfo::SOLID_COLOR_MODE: { |
327 SolidColorDrawQuad* quad = | 345 SolidColorDrawQuad* quad = |
328 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 346 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
329 quad->SetNew(shared_quad_state, geometry_rect, visible_geometry_rect, | 347 quad->SetNew(shared_quad_state, geometry_rect, visible_geometry_rect, |
330 draw_info.solid_color(), false); | 348 draw_info.solid_color(), false); |
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1264 | 1282 |
1265 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 1283 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { |
1266 return !layer_tree_impl()->IsRecycleTree(); | 1284 return !layer_tree_impl()->IsRecycleTree(); |
1267 } | 1285 } |
1268 | 1286 |
1269 bool PictureLayerImpl::HasValidTilePriorities() const { | 1287 bool PictureLayerImpl::HasValidTilePriorities() const { |
1270 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); | 1288 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); |
1271 } | 1289 } |
1272 | 1290 |
1273 } // namespace cc | 1291 } // namespace cc |
OLD | NEW |