OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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/layer.h" | 5 #include "cc/layers/layer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
12 #include "cc/animation/animation.h" | 12 #include "cc/animation/animation.h" |
13 #include "cc/animation/animation_events.h" | 13 #include "cc/animation/animation_events.h" |
14 #include "cc/animation/layer_animation_controller.h" | 14 #include "cc/animation/layer_animation_controller.h" |
15 #include "cc/layers/layer_impl.h" | 15 #include "cc/layers/layer_impl.h" |
16 #include "cc/output/copy_output_request.h" | 16 #include "cc/output/copy_output_request.h" |
17 #include "cc/output/copy_output_result.h" | 17 #include "cc/output/copy_output_result.h" |
18 #include "cc/trees/layer_tree_host.h" | 18 #include "cc/trees/layer_tree_host.h" |
19 #include "cc/trees/layer_tree_impl.h" | 19 #include "cc/trees/layer_tree_impl.h" |
20 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h" | |
21 #include "third_party/skia/include/core/SkImageFilter.h" | 20 #include "third_party/skia/include/core/SkImageFilter.h" |
22 #include "ui/gfx/rect_conversions.h" | 21 #include "ui/gfx/rect_conversions.h" |
23 | 22 |
24 namespace cc { | 23 namespace cc { |
25 | 24 |
26 static int s_next_layer_id = 1; | 25 static int s_next_layer_id = 1; |
27 | 26 |
28 scoped_refptr<Layer> Layer::Create() { | 27 scoped_refptr<Layer> Layer::Create() { |
29 return make_scoped_refptr(new Layer()); | 28 return make_scoped_refptr(new Layer()); |
30 } | 29 } |
(...skipping 17 matching lines...) Expand all Loading... |
48 is_drawable_(false), | 47 is_drawable_(false), |
49 hide_layer_and_subtree_(false), | 48 hide_layer_and_subtree_(false), |
50 masks_to_bounds_(false), | 49 masks_to_bounds_(false), |
51 contents_opaque_(false), | 50 contents_opaque_(false), |
52 double_sided_(true), | 51 double_sided_(true), |
53 preserves_3d_(false), | 52 preserves_3d_(false), |
54 use_parent_backface_visibility_(false), | 53 use_parent_backface_visibility_(false), |
55 draw_checkerboard_for_missing_tiles_(false), | 54 draw_checkerboard_for_missing_tiles_(false), |
56 force_render_surface_(false), | 55 force_render_surface_(false), |
57 replica_layer_(NULL), | 56 replica_layer_(NULL), |
58 raster_scale_(0.f), | 57 raster_scale_(0.f) { |
59 layer_scroll_client_(NULL) { | |
60 if (layer_id_ < 0) { | 58 if (layer_id_ < 0) { |
61 s_next_layer_id = 1; | 59 s_next_layer_id = 1; |
62 layer_id_ = s_next_layer_id++; | 60 layer_id_ = s_next_layer_id++; |
63 } | 61 } |
64 | 62 |
65 layer_animation_controller_ = LayerAnimationController::Create(layer_id_); | 63 layer_animation_controller_ = LayerAnimationController::Create(layer_id_); |
66 layer_animation_controller_->AddValueObserver(this); | 64 layer_animation_controller_->AddValueObserver(this); |
67 } | 65 } |
68 | 66 |
69 Layer::~Layer() { | 67 Layer::~Layer() { |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 scroll_offset_ = scroll_offset; | 517 scroll_offset_ = scroll_offset; |
520 SetNeedsCommit(); | 518 SetNeedsCommit(); |
521 } | 519 } |
522 | 520 |
523 void Layer::SetScrollOffsetFromImplSide(gfx::Vector2d scroll_offset) { | 521 void Layer::SetScrollOffsetFromImplSide(gfx::Vector2d scroll_offset) { |
524 DCHECK(IsPropertyChangeAllowed()); | 522 DCHECK(IsPropertyChangeAllowed()); |
525 DCHECK(layer_tree_host_ && layer_tree_host_->CommitRequested()); | 523 DCHECK(layer_tree_host_ && layer_tree_host_->CommitRequested()); |
526 if (scroll_offset_ == scroll_offset) | 524 if (scroll_offset_ == scroll_offset) |
527 return; | 525 return; |
528 scroll_offset_ = scroll_offset; | 526 scroll_offset_ = scroll_offset; |
529 if (layer_scroll_client_) | 527 if (!did_scroll_callback_.is_null()) |
530 layer_scroll_client_->didScroll(); | 528 did_scroll_callback_.Run(); |
531 // Note: didScroll() could potentially change the layer structure. | 529 // Note: didScroll() could potentially change the layer structure. |
532 // "this" may have been destroyed during the process. | 530 // "this" may have been destroyed during the process. |
533 } | 531 } |
534 | 532 |
535 void Layer::SetMaxScrollOffset(gfx::Vector2d max_scroll_offset) { | 533 void Layer::SetMaxScrollOffset(gfx::Vector2d max_scroll_offset) { |
536 DCHECK(IsPropertyChangeAllowed()); | 534 DCHECK(IsPropertyChangeAllowed()); |
537 if (max_scroll_offset_ == max_scroll_offset) | 535 if (max_scroll_offset_ == max_scroll_offset) |
538 return; | 536 return; |
539 max_scroll_offset_ = max_scroll_offset; | 537 max_scroll_offset_ = max_scroll_offset; |
540 SetNeedsCommit(); | 538 SetNeedsCommit(); |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 | 895 |
898 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { | 896 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { |
899 return layer_tree_host_->rendering_stats_instrumentation(); | 897 return layer_tree_host_->rendering_stats_instrumentation(); |
900 } | 898 } |
901 | 899 |
902 bool Layer::SupportsLCDText() const { | 900 bool Layer::SupportsLCDText() const { |
903 return false; | 901 return false; |
904 } | 902 } |
905 | 903 |
906 } // namespace cc | 904 } // namespace cc |
OLD | NEW |