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

Side by Side Diff: ui/gfx/compositor/layer.cc

Issue 7273073: Animated Rotation (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Move compositing notifications to Layer Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/gfx/compositor/layer.h" 5 #include "ui/gfx/compositor/layer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/gfx/compositor/layer_observer.h"
10 #include "ui/gfx/point3.h" 11 #include "ui/gfx/point3.h"
11 12
12 namespace ui { 13 namespace ui {
13 14
14 Layer::Layer(Compositor* compositor) 15 Layer::Layer(Compositor* compositor)
15 : compositor_(compositor), 16 : compositor_(compositor),
16 texture_(compositor->CreateTexture()), 17 texture_(compositor->CreateTexture()),
17 parent_(NULL), 18 parent_(NULL),
18 fills_bounds_opaquely_(false) { 19 fills_bounds_opaquely_(false) {
19 } 20 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 if (texture == NULL) 102 if (texture == NULL)
102 texture_ = compositor_->CreateTexture(); 103 texture_ = compositor_->CreateTexture();
103 else 104 else
104 texture_ = texture; 105 texture_ = texture;
105 } 106 }
106 107
107 void Layer::SetCanvas(const SkCanvas& canvas, const gfx::Point& origin) { 108 void Layer::SetCanvas(const SkCanvas& canvas, const gfx::Point& origin) {
108 texture_->SetCanvas(canvas, origin, bounds_.size()); 109 texture_->SetCanvas(canvas, origin, bounds_.size());
109 } 110 }
110 111
112 void Layer::AddObserver(LayerObserver* observer) {
113 observer_list_.AddObserver(observer);
114 }
115
116 void Layer::RemoveObserver(LayerObserver* observer) {
117 observer_list_.RemoveObserver(observer);
118 }
119
111 void Layer::Draw() { 120 void Layer::Draw() {
112 ui::TextureDrawParams texture_draw_params; 121 ui::TextureDrawParams texture_draw_params;
113 for (Layer* layer = this; layer; layer = layer->parent_) { 122 for (Layer* layer = this; layer; layer = layer->parent_) {
114 texture_draw_params.transform.ConcatTransform(layer->transform_); 123 texture_draw_params.transform.ConcatTransform(layer->transform_);
115 texture_draw_params.transform.ConcatTranslate( 124 texture_draw_params.transform.ConcatTranslate(
116 static_cast<float>(layer->bounds_.x()), 125 static_cast<float>(layer->bounds_.x()),
117 static_cast<float>(layer->bounds_.y())); 126 static_cast<float>(layer->bounds_.y()));
118 } 127 }
119 128
120 // Only blend for transparent child layers. 129 // Only blend for transparent child layers.
(...skipping 24 matching lines...) Expand all
145 bounds_.width() - hole_rect_.right(), 154 bounds_.width() - hole_rect_.right(),
146 hole_rect_.height())); 155 hole_rect_.height()));
147 156
148 // bottom 157 // bottom
149 DrawRegion(texture_draw_params, gfx::Rect( 158 DrawRegion(texture_draw_params, gfx::Rect(
150 0, 159 0,
151 hole_rect_.bottom(), 160 hole_rect_.bottom(),
152 bounds_.width(), 161 bounds_.width(),
153 bounds_.height() - hole_rect_.bottom())); 162 bounds_.height() - hole_rect_.bottom()));
154 #endif 163 #endif
164 FOR_EACH_OBSERVER(LayerObserver, observer_list_, OnDraw(this));
155 } 165 }
156 166
157 void Layer::DrawRegion(const ui::TextureDrawParams& params, 167 void Layer::DrawRegion(const ui::TextureDrawParams& params,
158 const gfx::Rect& region_to_draw) { 168 const gfx::Rect& region_to_draw) {
159 if (!region_to_draw.IsEmpty()) 169 if (!region_to_draw.IsEmpty())
160 texture_->Draw(params, region_to_draw); 170 texture_->Draw(params, region_to_draw);
161 } 171 }
162 172
163 void Layer::RecomputeHole() { 173 void Layer::RecomputeHole() {
164 for (size_t i = 0; i < children_.size(); ++i) { 174 for (size_t i = 0; i < children_.size(); ++i) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 for (; p && p != ancestor; p = p->parent()) { 208 for (; p && p != ancestor; p = p->parent()) {
199 if (p->transform().HasChange()) 209 if (p->transform().HasChange())
200 transform->ConcatTransform(p->transform()); 210 transform->ConcatTransform(p->transform());
201 transform->ConcatTranslate(static_cast<float>(p->bounds().x()), 211 transform->ConcatTranslate(static_cast<float>(p->bounds().x()),
202 static_cast<float>(p->bounds().y())); 212 static_cast<float>(p->bounds().y()));
203 } 213 }
204 return p == ancestor; 214 return p == ancestor;
205 } 215 }
206 216
207 } // namespace ui 217 } // namespace ui
OLDNEW
« no previous file with comments | « ui/gfx/compositor/layer.h ('k') | ui/gfx/compositor/layer_observer.h » ('j') | views/view.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698