| 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.h" | 5 #include "cc/layers/picture_layer.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 9 #include "cc/blimp/client_picture_cache.h" | 9 #include "cc/blimp/client_picture_cache.h" |
| 10 #include "cc/blimp/engine_picture_cache.h" | 10 #include "cc/blimp/engine_picture_cache.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 recording_source_->SetNeedsDisplayRect(layer_rect); | 95 recording_source_->SetNeedsDisplayRect(layer_rect); |
| 96 Layer::SetNeedsDisplayRect(layer_rect); | 96 Layer::SetNeedsDisplayRect(layer_rect); |
| 97 } | 97 } |
| 98 | 98 |
| 99 bool PictureLayer::Update() { | 99 bool PictureLayer::Update() { |
| 100 update_source_frame_number_ = layer_tree_host()->SourceFrameNumber(); | 100 update_source_frame_number_ = layer_tree_host()->SourceFrameNumber(); |
| 101 bool updated = Layer::Update(); | 101 bool updated = Layer::Update(); |
| 102 | 102 |
| 103 gfx::Size layer_size = paint_properties().bounds; | 103 gfx::Size layer_size = paint_properties().bounds; |
| 104 | 104 |
| 105 recording_source_->SetBackgroundColor(UseTransformedRasterization() ? SK_Color
TRANSPARENT : SafeOpaqueBackgroundColor()); | 105 recording_source_->SetBackgroundColor(UseTransformedRasterization() |
| 106 ? SK_ColorTRANSPARENT |
| 107 : SafeOpaqueBackgroundColor()); |
| 106 recording_source_->SetRequiresClear( | 108 recording_source_->SetRequiresClear( |
| 107 !contents_opaque() && | 109 !contents_opaque() && |
| 108 !picture_layer_inputs_.client->FillsBoundsCompletely()); | 110 !picture_layer_inputs_.client->FillsBoundsCompletely()); |
| 109 | 111 |
| 110 TRACE_EVENT1("cc", "PictureLayer::Update", "source_frame_number", | 112 TRACE_EVENT1("cc", "PictureLayer::Update", "source_frame_number", |
| 111 layer_tree_host()->SourceFrameNumber()); | 113 layer_tree_host()->SourceFrameNumber()); |
| 112 devtools_instrumentation::ScopedLayerTreeTask update_layer( | 114 devtools_instrumentation::ScopedLayerTreeTask update_layer( |
| 113 devtools_instrumentation::kUpdateLayer, id(), layer_tree_host()->GetId()); | 115 devtools_instrumentation::kUpdateLayer, id(), layer_tree_host()->GetId()); |
| 114 | 116 |
| 115 // UpdateAndExpandInvalidation will give us an invalidation that covers | 117 // UpdateAndExpandInvalidation will give us an invalidation that covers |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 picture_layer_inputs_.recorded_viewport = gfx::Rect(); | 271 picture_layer_inputs_.recorded_viewport = gfx::Rect(); |
| 270 picture_layer_inputs_.display_list = nullptr; | 272 picture_layer_inputs_.display_list = nullptr; |
| 271 picture_layer_inputs_.painter_reported_memory_usage = 0; | 273 picture_layer_inputs_.painter_reported_memory_usage = 0; |
| 272 } | 274 } |
| 273 } | 275 } |
| 274 | 276 |
| 275 bool PictureLayer::UseTransformedRasterization() const { | 277 bool PictureLayer::UseTransformedRasterization() const { |
| 276 if (!picture_layer_inputs_.allow_transformed_rasterization) | 278 if (!picture_layer_inputs_.allow_transformed_rasterization) |
| 277 return false; | 279 return false; |
| 278 | 280 |
| 279 const TransformTree &transform_tree = GetLayerTree()->property_trees()->transf
orm_tree; | 281 const TransformTree& transform_tree = |
| 282 GetLayerTree()->property_trees()->transform_tree; |
| 280 DCHECK(!transform_tree.needs_update()); | 283 DCHECK(!transform_tree.needs_update()); |
| 281 if (transform_tree.Node(transform_tree_index())->to_screen_is_potentially_anim
ated) | 284 if (transform_tree.Node(transform_tree_index()) |
| 285 ->to_screen_is_potentially_animated) |
| 282 return false; | 286 return false; |
| 283 | 287 |
| 284 const gfx::Transform& to_screen = transform_tree.ToScreen(transform_tree_index
()); | 288 const gfx::Transform& to_screen = |
| 289 transform_tree.ToScreen(transform_tree_index()); |
| 285 if (!to_screen.IsScaleOrTranslation()) | 290 if (!to_screen.IsScaleOrTranslation()) |
| 286 return false; | 291 return false; |
| 287 | 292 |
| 288 float origin_x = to_screen.matrix().getFloat(0, 3) + offset_to_transform_paren
t().x(); | 293 float origin_x = |
| 289 float origin_y = to_screen.matrix().getFloat(1, 3) + offset_to_transform_paren
t().y(); | 294 to_screen.matrix().getFloat(0, 3) + offset_to_transform_parent().x(); |
| 295 float origin_y = |
| 296 to_screen.matrix().getFloat(1, 3) + offset_to_transform_parent().y(); |
| 290 if (origin_x - floorf(origin_x) == 0.f && origin_y - floorf(origin_y) == 0.f) | 297 if (origin_x - floorf(origin_x) == 0.f && origin_y - floorf(origin_y) == 0.f) |
| 291 return false; | 298 return false; |
| 292 | 299 |
| 293 return true; | 300 return true; |
| 294 } | 301 } |
| 295 | 302 |
| 296 const DisplayItemList* PictureLayer::GetDisplayItemList() { | 303 const DisplayItemList* PictureLayer::GetDisplayItemList() { |
| 297 return picture_layer_inputs_.display_list.get(); | 304 return picture_layer_inputs_.display_list.get(); |
| 298 } | 305 } |
| 299 | 306 |
| 300 } // namespace cc | 307 } // namespace cc |
| OLD | NEW |