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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 | 11 |
12 #include "base/atomic_sequence_num.h" | 12 #include "base/atomic_sequence_num.h" |
13 #include "base/location.h" | 13 #include "base/location.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
18 #include "cc/animation/mutable_properties.h" | 18 #include "cc/animation/mutable_properties.h" |
19 #include "cc/base/simple_enclosed_region.h" | 19 #include "cc/base/simple_enclosed_region.h" |
20 #include "cc/debug/frame_viewer_instrumentation.h" | 20 #include "cc/debug/frame_viewer_instrumentation.h" |
21 #include "cc/input/main_thread_scrolling_reason.h" | 21 #include "cc/input/main_thread_scrolling_reason.h" |
22 #include "cc/layers/layer_client.h" | 22 #include "cc/layers/layer_client.h" |
23 #include "cc/layers/layer_impl.h" | 23 #include "cc/layers/layer_impl.h" |
24 #include "cc/layers/layer_proto_converter.h" | 24 #include "cc/layers/layer_proto_converter.h" |
25 #include "cc/layers/layer_settings.h" | |
26 #include "cc/layers/scrollbar_layer_interface.h" | 25 #include "cc/layers/scrollbar_layer_interface.h" |
27 #include "cc/output/copy_output_request.h" | 26 #include "cc/output/copy_output_request.h" |
28 #include "cc/output/copy_output_result.h" | 27 #include "cc/output/copy_output_result.h" |
29 #include "cc/proto/cc_conversions.h" | 28 #include "cc/proto/cc_conversions.h" |
30 #include "cc/proto/gfx_conversions.h" | 29 #include "cc/proto/gfx_conversions.h" |
31 #include "cc/proto/layer.pb.h" | 30 #include "cc/proto/layer.pb.h" |
32 #include "cc/proto/skia_conversions.h" | 31 #include "cc/proto/skia_conversions.h" |
33 #include "cc/trees/draw_property_utils.h" | 32 #include "cc/trees/draw_property_utils.h" |
34 #include "cc/trees/layer_tree_host.h" | 33 #include "cc/trees/layer_tree_host.h" |
35 #include "cc/trees/layer_tree_impl.h" | 34 #include "cc/trees/layer_tree_impl.h" |
36 #include "third_party/skia/include/core/SkImageFilter.h" | 35 #include "third_party/skia/include/core/SkImageFilter.h" |
37 #include "ui/gfx/geometry/rect_conversions.h" | 36 #include "ui/gfx/geometry/rect_conversions.h" |
38 #include "ui/gfx/geometry/vector2d_conversions.h" | 37 #include "ui/gfx/geometry/vector2d_conversions.h" |
39 | 38 |
40 namespace cc { | 39 namespace cc { |
41 | 40 |
42 base::StaticAtomicSequenceNumber g_next_layer_id; | 41 base::StaticAtomicSequenceNumber g_next_layer_id; |
43 | 42 |
44 scoped_refptr<Layer> Layer::Create(const LayerSettings& settings) { | 43 scoped_refptr<Layer> Layer::Create() { |
45 return make_scoped_refptr(new Layer(settings)); | 44 return make_scoped_refptr(new Layer()); |
46 } | 45 } |
47 | 46 |
48 Layer::Layer(const LayerSettings& settings) | 47 Layer::Layer() |
49 : needs_push_properties_(false), | 48 : needs_push_properties_(false), |
50 num_dependents_need_push_properties_(0), | 49 num_dependents_need_push_properties_(0), |
51 // Layer IDs start from 1. | 50 // Layer IDs start from 1. |
52 layer_id_(g_next_layer_id.GetNext() + 1), | 51 layer_id_(g_next_layer_id.GetNext() + 1), |
53 ignore_set_needs_commit_(false), | 52 ignore_set_needs_commit_(false), |
54 sorting_context_id_(0), | 53 sorting_context_id_(0), |
55 parent_(nullptr), | 54 parent_(nullptr), |
56 layer_tree_host_(nullptr), | 55 layer_tree_host_(nullptr), |
57 scroll_clip_layer_id_(INVALID_ID), | 56 scroll_clip_layer_id_(INVALID_ID), |
58 num_descendants_that_draw_content_(0), | 57 num_descendants_that_draw_content_(0), |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 blend_mode_(SkXfermode::kSrcOver_Mode), | 89 blend_mode_(SkXfermode::kSrcOver_Mode), |
91 draw_blend_mode_(SkXfermode::kSrcOver_Mode), | 90 draw_blend_mode_(SkXfermode::kSrcOver_Mode), |
92 scroll_parent_(nullptr), | 91 scroll_parent_(nullptr), |
93 layer_or_descendant_is_drawn_tracker_(0), | 92 layer_or_descendant_is_drawn_tracker_(0), |
94 sorted_for_recursion_tracker_(0), | 93 sorted_for_recursion_tracker_(0), |
95 visited_tracker_(0), | 94 visited_tracker_(0), |
96 clip_parent_(nullptr), | 95 clip_parent_(nullptr), |
97 replica_layer_(nullptr), | 96 replica_layer_(nullptr), |
98 client_(nullptr), | 97 client_(nullptr), |
99 num_unclipped_descendants_(0), | 98 num_unclipped_descendants_(0), |
100 frame_timing_requests_dirty_(false) { | 99 frame_timing_requests_dirty_(false) {} |
101 } | |
102 | 100 |
103 Layer::~Layer() { | 101 Layer::~Layer() { |
104 // Our parent should be holding a reference to us so there should be no | 102 // Our parent should be holding a reference to us so there should be no |
105 // way for us to be destroyed while we still have a parent. | 103 // way for us to be destroyed while we still have a parent. |
106 DCHECK(!parent()); | 104 DCHECK(!parent()); |
107 // Similarly we shouldn't have a layer tree host since it also keeps a | 105 // Similarly we shouldn't have a layer tree host since it also keeps a |
108 // reference to us. | 106 // reference to us. |
109 DCHECK(!layer_tree_host()); | 107 DCHECK(!layer_tree_host()); |
110 | 108 |
111 RemoveFromScrollTree(); | 109 RemoveFromScrollTree(); |
(...skipping 1837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1949 this, layer_tree_host_->property_trees()->transform_tree); | 1947 this, layer_tree_host_->property_trees()->transform_tree); |
1950 } | 1948 } |
1951 | 1949 |
1952 gfx::Transform Layer::screen_space_transform() const { | 1950 gfx::Transform Layer::screen_space_transform() const { |
1953 DCHECK_NE(transform_tree_index_, -1); | 1951 DCHECK_NE(transform_tree_index_, -1); |
1954 return draw_property_utils::ScreenSpaceTransform( | 1952 return draw_property_utils::ScreenSpaceTransform( |
1955 this, layer_tree_host_->property_trees()->transform_tree); | 1953 this, layer_tree_host_->property_trees()->transform_tree); |
1956 } | 1954 } |
1957 | 1955 |
1958 } // namespace cc | 1956 } // namespace cc |
OLD | NEW |