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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/CompositorMutableState.cpp

Issue 2765053002: Avoid exposing cc::Layer tree to CompositorProxy (Closed)
Patch Set: Rebase onto blink reformat Created 3 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "platform/graphics/CompositorMutableState.h" 5 #include "platform/graphics/CompositorMutableState.h"
6 6
7 #include "cc/layers/layer_impl.h" 7 #include "platform/graphics/CompositorMutableProperties.h"
8 #include "cc/trees/layer_tree_impl.h"
9 #include "platform/graphics/CompositorMutation.h" 8 #include "platform/graphics/CompositorMutation.h"
10 9
11 namespace blink { 10 namespace blink {
12 CompositorMutableState::CompositorMutableState(CompositorMutation* mutation, 11 CompositorMutableState::CompositorMutableState(
13 cc::LayerImpl* main, 12 CompositorMutation* mutation,
14 cc::LayerImpl* scroll) 13 CompositorMutableProperties* properties)
15 : mutation_(mutation), main_layer_(main), scroll_layer_(scroll) {} 14 : mutation_(mutation), properties_(properties) {}
16 15
17 CompositorMutableState::~CompositorMutableState() {} 16 CompositorMutableState::~CompositorMutableState() {}
18 17
19 double CompositorMutableState::Opacity() const { 18 double CompositorMutableState::Opacity() const {
20 return main_layer_->Opacity(); 19 return properties_->opacity;
21 } 20 }
22 21
23 void CompositorMutableState::SetOpacity(double opacity) { 22 void CompositorMutableState::SetOpacity(double opacity) {
24 if (!main_layer_) 23 properties_->opacity = opacity;
25 return;
26 main_layer_->layer_tree_impl()->SetOpacityMutated(main_layer_->element_id(),
27 opacity);
28 mutation_->SetOpacity(opacity); 24 mutation_->SetOpacity(opacity);
29 } 25 }
30 26
31 const SkMatrix44& CompositorMutableState::Transform() const { 27 const SkMatrix44& CompositorMutableState::Transform() const {
32 return main_layer_ ? main_layer_->Transform().matrix() : SkMatrix44::I(); 28 return properties_->transform;
33 } 29 }
34 30
35 void CompositorMutableState::SetTransform(const SkMatrix44& matrix) { 31 void CompositorMutableState::SetTransform(const SkMatrix44& matrix) {
36 if (!main_layer_) 32 properties_->transform = matrix;
37 return;
38 main_layer_->layer_tree_impl()->SetTransformMutated(main_layer_->element_id(),
39 gfx::Transform(matrix));
40 mutation_->SetTransform(matrix); 33 mutation_->SetTransform(matrix);
41 } 34 }
42 35
43 float CompositorMutableState::ScrollLeft() const { 36 float CompositorMutableState::ScrollLeft() const {
44 return scroll_layer_ ? scroll_layer_->CurrentScrollOffset().x() : 0.0; 37 return properties_->scroll_left;
45 } 38 }
46 39
47 void CompositorMutableState::SetScrollLeft(float scroll_left) { 40 void CompositorMutableState::SetScrollLeft(float scroll_left) {
48 if (!scroll_layer_) 41 properties_->scroll_left = scroll_left;
49 return;
50
51 gfx::ScrollOffset offset = scroll_layer_->CurrentScrollOffset();
52 offset.set_x(scroll_left);
53 scroll_layer_->layer_tree_impl()
54 ->property_trees()
55 ->scroll_tree.OnScrollOffsetAnimated(
56 scroll_layer_->id(), scroll_layer_->scroll_tree_index(), offset,
57 scroll_layer_->layer_tree_impl());
58 mutation_->SetScrollLeft(scroll_left); 42 mutation_->SetScrollLeft(scroll_left);
59 } 43 }
60 44
61 float CompositorMutableState::ScrollTop() const { 45 float CompositorMutableState::ScrollTop() const {
62 return scroll_layer_ ? scroll_layer_->CurrentScrollOffset().y() : 0.0; 46 return properties_->scroll_top;
63 } 47 }
64 48
65 void CompositorMutableState::SetScrollTop(float scroll_top) { 49 void CompositorMutableState::SetScrollTop(float scroll_top) {
66 if (!scroll_layer_) 50 properties_->scroll_top = scroll_top;
67 return;
68 gfx::ScrollOffset offset = scroll_layer_->CurrentScrollOffset();
69 offset.set_y(scroll_top);
70 scroll_layer_->layer_tree_impl()
71 ->property_trees()
72 ->scroll_tree.OnScrollOffsetAnimated(
73 scroll_layer_->id(), scroll_layer_->scroll_tree_index(), offset,
74 scroll_layer_->layer_tree_impl());
75 mutation_->SetScrollTop(scroll_top); 51 mutation_->SetScrollTop(scroll_top);
76 } 52 }
77 53
78 } // namespace blink 54 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698