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

Side by Side Diff: cc/layers/surface_layer.cc

Issue 1057283003: Remove parts of //cc we aren't using (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « cc/layers/surface_layer.h ('k') | cc/layers/surface_layer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "cc/layers/surface_layer.h"
6
7 #include "cc/layers/surface_layer_impl.h"
8 #include "cc/output/swap_promise.h"
9 #include "cc/trees/layer_tree_host.h"
10
11 namespace cc {
12
13 class SatisfySwapPromise : public SwapPromise {
14 public:
15 SatisfySwapPromise(SurfaceSequence sequence,
16 const SurfaceLayer::SatisfyCallback& satisfy_callback)
17 : sequence_(sequence), satisfy_callback_(satisfy_callback) {}
18
19 ~SatisfySwapPromise() override {}
20
21 private:
22 void DidSwap(CompositorFrameMetadata* metadata) override {
23 metadata->satisfies_sequences.push_back(sequence_.sequence);
24 }
25
26 void DidNotSwap(DidNotSwapReason reason) override {
27 satisfy_callback_.Run(sequence_);
28 }
29 int64 TraceId() const override { return 0; }
30
31 SurfaceSequence sequence_;
32 SurfaceLayer::SatisfyCallback satisfy_callback_;
33
34 DISALLOW_COPY_AND_ASSIGN(SatisfySwapPromise);
35 };
36
37 scoped_refptr<SurfaceLayer> SurfaceLayer::Create(
38 const SatisfyCallback& satisfy_callback,
39 const RequireCallback& require_callback) {
40 return make_scoped_refptr(
41 new SurfaceLayer(satisfy_callback, require_callback));
42 }
43
44 SurfaceLayer::SurfaceLayer(const SatisfyCallback& satisfy_callback,
45 const RequireCallback& require_callback)
46 : Layer(),
47 surface_scale_(1.f),
48 satisfy_callback_(satisfy_callback),
49 require_callback_(require_callback) {
50 }
51
52 SurfaceLayer::~SurfaceLayer() {
53 DCHECK(!layer_tree_host());
54 DCHECK(destroy_sequence_.is_null());
55 }
56
57 void SurfaceLayer::SetSurfaceId(SurfaceId surface_id,
58 float scale,
59 const gfx::Size& size) {
60 SatisfyDestroySequence();
61 surface_id_ = surface_id;
62 surface_size_ = size;
63 surface_scale_ = scale;
64 CreateNewDestroySequence();
65
66 UpdateDrawsContent(HasDrawableContent());
67 SetNeedsPushProperties();
68 }
69
70 scoped_ptr<LayerImpl> SurfaceLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) {
71 return SurfaceLayerImpl::Create(tree_impl, id());
72 }
73
74 bool SurfaceLayer::HasDrawableContent() const {
75 return !surface_id_.is_null() && Layer::HasDrawableContent();
76 }
77
78 void SurfaceLayer::SetLayerTreeHost(LayerTreeHost* host) {
79 if (layer_tree_host() == host) {
80 Layer::SetLayerTreeHost(host);
81 return;
82 }
83
84 SatisfyDestroySequence();
85 Layer::SetLayerTreeHost(host);
86 CreateNewDestroySequence();
87 }
88
89 void SurfaceLayer::PushPropertiesTo(LayerImpl* layer) {
90 Layer::PushPropertiesTo(layer);
91 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer);
92
93 layer_impl->SetSurfaceId(surface_id_);
94 }
95
96 void SurfaceLayer::CalculateContentsScale(float ideal_contents_scale,
97 float* contents_scale_x,
98 float* contents_scale_y,
99 gfx::Size* content_bounds) {
100 *content_bounds = surface_size_;
101 *contents_scale_x = surface_scale_;
102 *contents_scale_y = surface_scale_;
103 }
104
105 void SurfaceLayer::CreateNewDestroySequence() {
106 DCHECK(destroy_sequence_.is_null());
107 if (layer_tree_host()) {
108 destroy_sequence_ = layer_tree_host()->CreateSurfaceSequence();
109 require_callback_.Run(surface_id_, destroy_sequence_);
110 }
111 }
112
113 void SurfaceLayer::SatisfyDestroySequence() {
114 if (!layer_tree_host())
115 return;
116 DCHECK(!destroy_sequence_.is_null());
117 scoped_ptr<SatisfySwapPromise> satisfy(
118 new SatisfySwapPromise(destroy_sequence_, satisfy_callback_));
119 layer_tree_host()->QueueSwapPromise(satisfy.Pass());
120 destroy_sequence_ = SurfaceSequence();
121 }
122
123 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/surface_layer.h ('k') | cc/layers/surface_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698