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

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

Issue 723343002: Update from https://crrev.com/304121 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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/surface_layer.h" 5 #include "cc/layers/surface_layer.h"
6 6
7 #include "cc/base/swap_promise.h" 7 #include "cc/base/swap_promise.h"
8 #include "cc/layers/surface_layer_impl.h" 8 #include "cc/layers/surface_layer_impl.h"
9 #include "cc/trees/layer_tree_host.h" 9 #include "cc/trees/layer_tree_host.h"
10 10
(...skipping 26 matching lines...) Expand all
37 scoped_refptr<SurfaceLayer> SurfaceLayer::Create( 37 scoped_refptr<SurfaceLayer> SurfaceLayer::Create(
38 const SatisfyCallback& satisfy_callback, 38 const SatisfyCallback& satisfy_callback,
39 const RequireCallback& require_callback) { 39 const RequireCallback& require_callback) {
40 return make_scoped_refptr( 40 return make_scoped_refptr(
41 new SurfaceLayer(satisfy_callback, require_callback)); 41 new SurfaceLayer(satisfy_callback, require_callback));
42 } 42 }
43 43
44 SurfaceLayer::SurfaceLayer(const SatisfyCallback& satisfy_callback, 44 SurfaceLayer::SurfaceLayer(const SatisfyCallback& satisfy_callback,
45 const RequireCallback& require_callback) 45 const RequireCallback& require_callback)
46 : Layer(), 46 : Layer(),
47 surface_scale_(1.f),
47 satisfy_callback_(satisfy_callback), 48 satisfy_callback_(satisfy_callback),
48 require_callback_(require_callback) { 49 require_callback_(require_callback) {
49 } 50 }
50 51
51 SurfaceLayer::~SurfaceLayer() { 52 SurfaceLayer::~SurfaceLayer() {
52 DCHECK(!layer_tree_host()); 53 DCHECK(!layer_tree_host());
53 DCHECK(destroy_sequence_.is_null()); 54 DCHECK(destroy_sequence_.is_null());
54 } 55 }
55 56
56 void SurfaceLayer::SetSurfaceId(SurfaceId surface_id) { 57 void SurfaceLayer::SetSurfaceId(SurfaceId surface_id,
58 float scale,
59 const gfx::Size& size) {
57 SatisfyDestroySequence(); 60 SatisfyDestroySequence();
58 surface_id_ = surface_id; 61 surface_id_ = surface_id;
62 surface_size_ = size;
63 surface_scale_ = scale;
59 CreateNewDestroySequence(); 64 CreateNewDestroySequence();
60 65
61 UpdateDrawsContent(HasDrawableContent()); 66 UpdateDrawsContent(HasDrawableContent());
62 SetNeedsPushProperties(); 67 SetNeedsPushProperties();
63 } 68 }
64 69
65 scoped_ptr<LayerImpl> SurfaceLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) { 70 scoped_ptr<LayerImpl> SurfaceLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) {
66 return SurfaceLayerImpl::Create(tree_impl, id()); 71 return SurfaceLayerImpl::Create(tree_impl, id());
67 } 72 }
68 73
(...skipping 12 matching lines...) Expand all
81 CreateNewDestroySequence(); 86 CreateNewDestroySequence();
82 } 87 }
83 88
84 void SurfaceLayer::PushPropertiesTo(LayerImpl* layer) { 89 void SurfaceLayer::PushPropertiesTo(LayerImpl* layer) {
85 Layer::PushPropertiesTo(layer); 90 Layer::PushPropertiesTo(layer);
86 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer); 91 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer);
87 92
88 layer_impl->SetSurfaceId(surface_id_); 93 layer_impl->SetSurfaceId(surface_id_);
89 } 94 }
90 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
91 void SurfaceLayer::CreateNewDestroySequence() { 105 void SurfaceLayer::CreateNewDestroySequence() {
92 DCHECK(destroy_sequence_.is_null()); 106 DCHECK(destroy_sequence_.is_null());
93 if (layer_tree_host()) { 107 if (layer_tree_host()) {
94 destroy_sequence_ = layer_tree_host()->CreateSurfaceSequence(); 108 destroy_sequence_ = layer_tree_host()->CreateSurfaceSequence();
95 require_callback_.Run(surface_id_, destroy_sequence_); 109 require_callback_.Run(surface_id_, destroy_sequence_);
96 } 110 }
97 } 111 }
98 112
99 void SurfaceLayer::SatisfyDestroySequence() { 113 void SurfaceLayer::SatisfyDestroySequence() {
100 if (!layer_tree_host()) 114 if (!layer_tree_host())
101 return; 115 return;
102 DCHECK(!destroy_sequence_.is_null()); 116 DCHECK(!destroy_sequence_.is_null());
103 scoped_ptr<SatisfySwapPromise> satisfy( 117 scoped_ptr<SatisfySwapPromise> satisfy(
104 new SatisfySwapPromise(destroy_sequence_, satisfy_callback_)); 118 new SatisfySwapPromise(destroy_sequence_, satisfy_callback_));
105 layer_tree_host()->QueueSwapPromise(satisfy.Pass()); 119 layer_tree_host()->QueueSwapPromise(satisfy.Pass());
106 destroy_sequence_ = SurfaceSequence(); 120 destroy_sequence_ = SurfaceSequence();
107 } 121 }
108 122
109 } // namespace cc 123 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/surface_layer.h ('k') | cc/layers/surface_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698