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

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

Issue 8222028: Use WebKit compositor in ui::Layer (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: rebase Created 9 years, 2 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
« no previous file with comments | « ui/gfx/compositor/layer.h ('k') | ui/gfx/compositor/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 (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 "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFloatPoint.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFloatRect.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h"
11 #include "ui/base/animation/animation.h" 14 #include "ui/base/animation/animation.h"
12 #include "ui/gfx/compositor/layer_animator.h" 15 #include "ui/gfx/compositor/layer_animator.h"
13 #include "ui/gfx/canvas_skia.h" 16 #include "ui/gfx/canvas_skia.h"
14 #include "ui/gfx/interpolated_transform.h" 17 #include "ui/gfx/interpolated_transform.h"
15 #include "ui/gfx/point3.h" 18 #include "ui/gfx/point3.h"
16 19
17 namespace { 20 namespace {
18 21
19 const float EPSILON = 1e-3f; 22 const float EPSILON = 1e-3f;
20 23
21 bool IsApproximateMultilpleOf(float value, float base) { 24 bool IsApproximateMultilpleOf(float value, float base) {
22 float remainder = fmod(fabs(value), base); 25 float remainder = fmod(fabs(value), base);
23 return remainder < EPSILON || base - remainder < EPSILON; 26 return remainder < EPSILON || base - remainder < EPSILON;
24 } 27 }
25 28
26 } // namespace 29 } // namespace
27 30
28 namespace ui { 31 namespace ui {
29 32
30 Layer::Layer(Compositor* compositor) 33 Layer::Layer(Compositor* compositor)
31 : type_(LAYER_HAS_TEXTURE), 34 : type_(LAYER_HAS_TEXTURE),
32 compositor_(compositor), 35 compositor_(compositor),
33 parent_(NULL), 36 parent_(NULL),
34 visible_(true), 37 visible_(true),
35 fills_bounds_opaquely_(true), 38 fills_bounds_opaquely_(true),
36 layer_updated_externally_(false), 39 layer_updated_externally_(false),
37 opacity_(1.0f), 40 opacity_(1.0f),
38 delegate_(NULL) { 41 delegate_(NULL) {
42 #if defined(USE_WEBKIT_COMPOSITOR)
43 CreateWebLayer();
44 #endif
39 } 45 }
40 46
41 Layer::Layer(Compositor* compositor, LayerType type) 47 Layer::Layer(Compositor* compositor, LayerType type)
42 : type_(type), 48 : type_(type),
43 compositor_(compositor), 49 compositor_(compositor),
44 parent_(NULL), 50 parent_(NULL),
45 visible_(true), 51 visible_(true),
46 fills_bounds_opaquely_(true), 52 fills_bounds_opaquely_(true),
47 layer_updated_externally_(false), 53 layer_updated_externally_(false),
48 opacity_(1.0f), 54 opacity_(1.0f),
49 delegate_(NULL) { 55 delegate_(NULL) {
56 #if defined(USE_WEBKIT_COMPOSITOR)
57 CreateWebLayer();
58 #endif
50 } 59 }
51 60
52 Layer::~Layer() { 61 Layer::~Layer() {
53 if (parent_) 62 if (parent_)
54 parent_->Remove(this); 63 parent_->Remove(this);
55 for (size_t i = 0; i < children_.size(); ++i) 64 for (size_t i = 0; i < children_.size(); ++i)
56 children_[i]->parent_ = NULL; 65 children_[i]->parent_ = NULL;
66 #if defined(USE_WEBKIT_COMPOSITOR)
67 web_layer_.removeFromParent();
68 #endif
57 } 69 }
58 70
59 Compositor* Layer::GetCompositor() { 71 Compositor* Layer::GetCompositor() {
60 return compositor_ ? compositor_ : parent_ ? parent_->GetCompositor() : NULL; 72 return compositor_ ? compositor_ : parent_ ? parent_->GetCompositor() : NULL;
61 } 73 }
62 74
63 void Layer::SetCompositor(Compositor* compositor) { 75 void Layer::SetCompositor(Compositor* compositor) {
64 // This function must only be called once, with a valid compositor, and only 76 // This function must only be called once, with a valid compositor, and only
65 // for the compositor's root layer. 77 // for the compositor's root layer.
66 DCHECK(!compositor_); 78 DCHECK(!compositor_);
67 DCHECK(compositor); 79 DCHECK(compositor);
68 DCHECK_EQ(compositor->root_layer(), this); 80 DCHECK_EQ(compositor->root_layer(), this);
69 compositor_ = compositor; 81 compositor_ = compositor;
70 } 82 }
71 83
72 void Layer::Add(Layer* child) { 84 void Layer::Add(Layer* child) {
73 if (child->parent_) 85 if (child->parent_)
74 child->parent_->Remove(child); 86 child->parent_->Remove(child);
75 child->parent_ = this; 87 child->parent_ = this;
76 children_.push_back(child); 88 children_.push_back(child);
89 #if defined(USE_WEBKIT_COMPOSITOR)
90 web_layer_.addChild(child->web_layer_);
91 #endif
77 92
78 RecomputeHole(); 93 RecomputeHole();
79 } 94 }
80 95
81 void Layer::Remove(Layer* child) { 96 void Layer::Remove(Layer* child) {
82 std::vector<Layer*>::iterator i = 97 std::vector<Layer*>::iterator i =
83 std::find(children_.begin(), children_.end(), child); 98 std::find(children_.begin(), children_.end(), child);
84 DCHECK(i != children_.end()); 99 DCHECK(i != children_.end());
85 children_.erase(i); 100 children_.erase(i);
86 child->parent_ = NULL; 101 child->parent_ = NULL;
102 #if defined(USE_WEBKIT_COMPOSITOR)
103 child->web_layer_.removeFromParent();
104 #endif
87 105
88 RecomputeHole(); 106 RecomputeHole();
89 107
90 child->DropTextures(); 108 child->DropTextures();
91 } 109 }
92 110
93 void Layer::MoveToFront(Layer* child) { 111 void Layer::MoveToFront(Layer* child) {
94 std::vector<Layer*>::iterator i = 112 std::vector<Layer*>::iterator i =
95 std::find(children_.begin(), children_.end(), child); 113 std::find(children_.begin(), children_.end(), child);
96 DCHECK(i != children_.end()); 114 DCHECK(i != children_.end());
97 children_.erase(i); 115 children_.erase(i);
98 children_.push_back(child); 116 children_.push_back(child);
117 #if defined(USE_WEBKIT_COMPOSITOR)
118 child->web_layer_.removeFromParent();
119 web_layer_.addChild(child->web_layer_);
120 #endif
99 } 121 }
100 122
101 bool Layer::Contains(const Layer* other) const { 123 bool Layer::Contains(const Layer* other) const {
102 for (const Layer* parent = other; parent; parent = parent->parent()) { 124 for (const Layer* parent = other; parent; parent = parent->parent()) {
103 if (parent == this) 125 if (parent == this)
104 return true; 126 return true;
105 } 127 }
106 return false; 128 return false;
107 } 129 }
108 130
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 bool was_drawn = IsDrawn(); 180 bool was_drawn = IsDrawn();
159 visible_ = visible; 181 visible_ = visible;
160 bool is_drawn = IsDrawn(); 182 bool is_drawn = IsDrawn();
161 if (was_drawn == is_drawn) 183 if (was_drawn == is_drawn)
162 return; 184 return;
163 185
164 if (!is_drawn) 186 if (!is_drawn)
165 DropTextures(); 187 DropTextures();
166 if (parent_) 188 if (parent_)
167 parent_->RecomputeHole(); 189 parent_->RecomputeHole();
190 #if defined(USE_WEBKIT_COMPOSITOR)
191 // TODO(piman): Expose a visibility flag on WebLayer.
192 web_layer_.setOpacity(visible_ ? opacity_ : 0.f);
193 #endif
168 } 194 }
169 195
170 bool Layer::IsDrawn() const { 196 bool Layer::IsDrawn() const {
171 const Layer* layer = this; 197 const Layer* layer = this;
172 while (layer && layer->visible_) 198 while (layer && layer->visible_)
173 layer = layer->parent_; 199 layer = layer->parent_;
174 return layer == NULL; 200 return layer == NULL;
175 } 201 }
176 202
177 bool Layer::ShouldDraw() { 203 bool Layer::ShouldDraw() const {
178 return type_ == LAYER_HAS_TEXTURE && GetCombinedOpacity() > 0.0f && 204 return type_ == LAYER_HAS_TEXTURE && GetCombinedOpacity() > 0.0f &&
179 !hole_rect_.Contains(gfx::Rect(gfx::Point(0, 0), bounds_.size())); 205 !hole_rect_.Contains(gfx::Rect(gfx::Point(0, 0), bounds_.size()));
180 } 206 }
181 207
182 // static 208 // static
183 void Layer::ConvertPointToLayer(const Layer* source, 209 void Layer::ConvertPointToLayer(const Layer* source,
184 const Layer* target, 210 const Layer* target,
185 gfx::Point* point) { 211 gfx::Point* point) {
186 const Layer* inner = NULL; 212 const Layer* inner = NULL;
187 const Layer* outer = NULL; 213 const Layer* outer = NULL;
(...skipping 11 matching lines...) Expand all
199 } 225 }
200 226
201 void Layer::SetFillsBoundsOpaquely(bool fills_bounds_opaquely) { 227 void Layer::SetFillsBoundsOpaquely(bool fills_bounds_opaquely) {
202 if (fills_bounds_opaquely_ == fills_bounds_opaquely) 228 if (fills_bounds_opaquely_ == fills_bounds_opaquely)
203 return; 229 return;
204 230
205 fills_bounds_opaquely_ = fills_bounds_opaquely; 231 fills_bounds_opaquely_ = fills_bounds_opaquely;
206 232
207 if (parent()) 233 if (parent())
208 parent()->RecomputeHole(); 234 parent()->RecomputeHole();
235 #if defined(USE_WEBKIT_COMPOSITOR)
236 web_layer_.setOpaque(fills_bounds_opaquely);
237 #endif
209 } 238 }
210 239
211 void Layer::SetExternalTexture(ui::Texture* texture) { 240 void Layer::SetExternalTexture(ui::Texture* texture) {
212 DCHECK(texture); 241 DCHECK(texture);
213 layer_updated_externally_ = true; 242 layer_updated_externally_ = true;
214 texture_ = texture; 243 texture_ = texture;
215 } 244 }
216 245
217 void Layer::SetCanvas(const SkCanvas& canvas, const gfx::Point& origin) { 246 void Layer::SetCanvas(const SkCanvas& canvas, const gfx::Point& origin) {
247 #if defined(USE_WEBKIT_COMPOSITOR)
248 NOTREACHED();
249 #else
218 DCHECK_EQ(type_, LAYER_HAS_TEXTURE); 250 DCHECK_EQ(type_, LAYER_HAS_TEXTURE);
219 251
220 if (!texture_.get()) 252 if (!texture_.get())
221 texture_ = GetCompositor()->CreateTexture(); 253 texture_ = GetCompositor()->CreateTexture();
222 254
223 texture_->SetCanvas(canvas, origin, bounds_.size()); 255 texture_->SetCanvas(canvas, origin, bounds_.size());
224 invalid_rect_ = gfx::Rect(); 256 invalid_rect_ = gfx::Rect();
257 #endif
225 } 258 }
226 259
227 void Layer::SchedulePaint(const gfx::Rect& invalid_rect) { 260 void Layer::SchedulePaint(const gfx::Rect& invalid_rect) {
261 #if defined(USE_WEBKIT_COMPOSITOR)
262 WebKit::WebFloatRect web_rect(invalid_rect.x(),
263 invalid_rect.y(),
264 invalid_rect.width(),
265 invalid_rect.height());
266 web_layer_.invalidateRect(web_rect);
267 #else
228 invalid_rect_ = invalid_rect_.Union(invalid_rect); 268 invalid_rect_ = invalid_rect_.Union(invalid_rect);
229 ScheduleDraw(); 269 ScheduleDraw();
270 #endif
230 } 271 }
231 272
232 void Layer::ScheduleDraw() { 273 void Layer::ScheduleDraw() {
233 if (GetCompositor()) 274 Compositor* compositor = GetCompositor();
234 GetCompositor()->ScheduleDraw(); 275 if (compositor)
276 compositor->ScheduleDraw();
235 } 277 }
236 278
237 void Layer::Draw() { 279 void Layer::Draw() {
280 #if defined(USE_WEBKIT_COMPOSITOR)
281 NOTREACHED();
282 #else
238 DCHECK(GetCompositor()); 283 DCHECK(GetCompositor());
239 if (!ShouldDraw()) 284 if (!ShouldDraw())
240 return; 285 return;
241 286
242 UpdateLayerCanvas(); 287 UpdateLayerCanvas();
243 288
244 // Layer drew nothing, no texture was created. 289 // Layer drew nothing, no texture was created.
245 if (!texture_.get()) 290 if (!texture_.get())
246 return; 291 return;
247 292
(...skipping 19 matching lines...) Expand all
267 texture_draw_params.has_valid_alpha_channel = has_valid_alpha_channel(); 312 texture_draw_params.has_valid_alpha_channel = has_valid_alpha_channel();
268 313
269 std::vector<gfx::Rect> regions_to_draw; 314 std::vector<gfx::Rect> regions_to_draw;
270 PunchHole(gfx::Rect(gfx::Point(), bounds().size()), hole_rect_, 315 PunchHole(gfx::Rect(gfx::Point(), bounds().size()), hole_rect_,
271 &regions_to_draw); 316 &regions_to_draw);
272 317
273 for (size_t i = 0; i < regions_to_draw.size(); ++i) { 318 for (size_t i = 0; i < regions_to_draw.size(); ++i) {
274 if (!regions_to_draw[i].IsEmpty()) 319 if (!regions_to_draw[i].IsEmpty())
275 texture_->Draw(texture_draw_params, regions_to_draw[i]); 320 texture_->Draw(texture_draw_params, regions_to_draw[i]);
276 } 321 }
322 #endif
277 } 323 }
278 324
279 void Layer::DrawTree() { 325 void Layer::DrawTree() {
326 #if defined(USE_WEBKIT_COMPOSITOR)
327 NOTREACHED();
328 #else
280 if (!visible_) 329 if (!visible_)
281 return; 330 return;
282 331
283 Draw(); 332 Draw();
284 for (size_t i = 0; i < children_.size(); ++i) 333 for (size_t i = 0; i < children_.size(); ++i)
285 children_.at(i)->DrawTree(); 334 children_.at(i)->DrawTree();
335 #endif
336 }
337
338 void Layer::notifyNeedsComposite() {
339 #if defined(USE_WEBKIT_COMPOSITOR)
340 ScheduleDraw();
341 #else
342 NOTREACHED();
343 #endif
344 }
345
346 void Layer::paintContents(WebKit::WebCanvas* web_canvas,
347 const WebKit::WebRect& clip) {
348 #if defined(USE_WEBKIT_COMPOSITOR)
349 gfx::CanvasSkia canvas(web_canvas);
350 delegate_->OnPaintLayer(&canvas);
351 #else
352 NOTREACHED();
353 #endif
286 } 354 }
287 355
288 float Layer::GetCombinedOpacity() const { 356 float Layer::GetCombinedOpacity() const {
289 float opacity = opacity_; 357 float opacity = opacity_;
290 Layer* current = this->parent_; 358 Layer* current = this->parent_;
291 while (current) { 359 while (current) {
292 opacity *= current->opacity_; 360 opacity *= current->opacity_;
293 current = current->parent_; 361 current = current->parent_;
294 } 362 }
295 return opacity; 363 return opacity;
296 } 364 }
297 365
298 void Layer::UpdateLayerCanvas() { 366 void Layer::UpdateLayerCanvas() {
367 #if defined(USE_WEBKIT_COMPOSITOR)
368 NOTREACHED();
369 #else
299 // If we have no delegate, that means that whoever constructed the Layer is 370 // If we have no delegate, that means that whoever constructed the Layer is
300 // setting its canvas directly with SetCanvas(). 371 // setting its canvas directly with SetCanvas().
301 if (!delegate_ || layer_updated_externally_) 372 if (!delegate_ || layer_updated_externally_)
302 return; 373 return;
303 gfx::Rect local_bounds = gfx::Rect(gfx::Point(), bounds_.size()); 374 gfx::Rect local_bounds = gfx::Rect(gfx::Point(), bounds_.size());
304 gfx::Rect draw_rect = texture_.get() ? invalid_rect_.Intersect(local_bounds) : 375 gfx::Rect draw_rect = texture_.get() ? invalid_rect_.Intersect(local_bounds) :
305 local_bounds; 376 local_bounds;
306 if (draw_rect.IsEmpty()) { 377 if (draw_rect.IsEmpty()) {
307 invalid_rect_ = gfx::Rect(); 378 invalid_rect_ = gfx::Rect();
308 return; 379 return;
309 } 380 }
310 scoped_ptr<gfx::Canvas> canvas(gfx::Canvas::CreateCanvas( 381 scoped_ptr<gfx::Canvas> canvas(gfx::Canvas::CreateCanvas(
311 draw_rect.width(), draw_rect.height(), false)); 382 draw_rect.width(), draw_rect.height(), false));
312 canvas->TranslateInt(-draw_rect.x(), -draw_rect.y()); 383 canvas->TranslateInt(-draw_rect.x(), -draw_rect.y());
313 delegate_->OnPaintLayer(canvas.get()); 384 delegate_->OnPaintLayer(canvas.get());
314 SetCanvas(*canvas->GetSkCanvas(), draw_rect.origin()); 385 SetCanvas(*canvas->GetSkCanvas(), draw_rect.origin());
386 #endif
315 } 387 }
316 388
317 void Layer::RecomputeHole() { 389 void Layer::RecomputeHole() {
318 if (type_ == LAYER_HAS_NO_TEXTURE) 390 if (type_ == LAYER_HAS_NO_TEXTURE)
319 return; 391 return;
320 392
321 // Reset to default. 393 // Reset to default.
322 hole_rect_ = gfx::Rect(); 394 hole_rect_ = gfx::Rect();
323 395
324 // Find the largest hole 396 // Find the largest hole
(...skipping 25 matching lines...) Expand all
350 candidate_hole = gfx::Rect(bounds().size()).Intersect(candidate_hole); 422 candidate_hole = gfx::Rect(bounds().size()).Intersect(candidate_hole);
351 423
352 // Ensure we have the largest hole. 424 // Ensure we have the largest hole.
353 if (candidate_hole.size().GetArea() > hole_rect_.size().GetArea()) 425 if (candidate_hole.size().GetArea() > hole_rect_.size().GetArea())
354 hole_rect_ = candidate_hole; 426 hole_rect_ = candidate_hole;
355 } 427 }
356 428
357 // Free up texture memory if the hole fills bounds of layer. 429 // Free up texture memory if the hole fills bounds of layer.
358 if (!ShouldDraw() && !layer_updated_externally_) 430 if (!ShouldDraw() && !layer_updated_externally_)
359 texture_ = NULL; 431 texture_ = NULL;
432
433 #if defined(USE_WEBKIT_COMPOSITOR)
434 RecomputeDrawsContent();
435 #endif
360 } 436 }
361 437
362 bool Layer::IsCompletelyOpaque() const { 438 bool Layer::IsCompletelyOpaque() const {
363 return fills_bounds_opaquely() && GetCombinedOpacity() == 1.0f; 439 return fills_bounds_opaquely() && GetCombinedOpacity() == 1.0f;
364 } 440 }
365 441
366 // static 442 // static
367 void Layer::PunchHole(const gfx::Rect& rect, 443 void Layer::PunchHole(const gfx::Rect& rect,
368 const gfx::Rect& region_to_punch_out, 444 const gfx::Rect& region_to_punch_out,
369 std::vector<gfx::Rect>* sides) { 445 std::vector<gfx::Rect>* sides) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 SetTransformImmediately(animator_->GetTargetTransform()); 535 SetTransformImmediately(animator_->GetTargetTransform());
460 } 536 }
461 animator_.reset(); 537 animator_.reset();
462 } 538 }
463 539
464 void Layer::SetBoundsImmediately(const gfx::Rect& bounds) { 540 void Layer::SetBoundsImmediately(const gfx::Rect& bounds) {
465 bounds_ = bounds; 541 bounds_ = bounds;
466 542
467 if (parent()) 543 if (parent())
468 parent()->RecomputeHole(); 544 parent()->RecomputeHole();
545 #if defined(USE_WEBKIT_COMPOSITOR)
546 web_layer_.setBounds(bounds.size());
547 RecomputeTransform();
548 RecomputeDrawsContent();
549 #endif
469 } 550 }
470 551
471 void Layer::SetTransformImmediately(const ui::Transform& transform) { 552 void Layer::SetTransformImmediately(const ui::Transform& transform) {
472 transform_ = transform; 553 transform_ = transform;
473 554
474 if (parent()) 555 if (parent())
475 parent()->RecomputeHole(); 556 parent()->RecomputeHole();
557 #if defined(USE_WEBKIT_COMPOSITOR)
558 RecomputeTransform();
559 #endif
476 } 560 }
477 561
478 void Layer::SetOpacityImmediately(float opacity) { 562 void Layer::SetOpacityImmediately(float opacity) {
479 bool was_opaque = GetCombinedOpacity() == 1.0f; 563 bool was_opaque = GetCombinedOpacity() == 1.0f;
480 opacity_ = opacity; 564 opacity_ = opacity;
481 bool is_opaque = GetCombinedOpacity() == 1.0f; 565 bool is_opaque = GetCombinedOpacity() == 1.0f;
482 566
483 // If our opacity has changed we need to recompute our hole, our parent's hole 567 // If our opacity has changed we need to recompute our hole, our parent's hole
484 // and the holes of all our descendants. 568 // and the holes of all our descendants.
485 if (was_opaque != is_opaque) { 569 if (was_opaque != is_opaque) {
486 if (parent_) 570 if (parent_)
487 parent_->RecomputeHole(); 571 parent_->RecomputeHole();
488 std::queue<Layer*> to_process; 572 std::queue<Layer*> to_process;
489 to_process.push(this); 573 to_process.push(this);
490 while (!to_process.empty()) { 574 while (!to_process.empty()) {
491 Layer* current = to_process.front(); 575 Layer* current = to_process.front();
492 to_process.pop(); 576 to_process.pop();
493 current->RecomputeHole(); 577 current->RecomputeHole();
494 for (size_t i = 0; i < current->children_.size(); ++i) 578 for (size_t i = 0; i < current->children_.size(); ++i)
495 to_process.push(current->children_.at(i)); 579 to_process.push(current->children_.at(i));
496 } 580 }
497 } 581 }
582 #if defined(USE_WEBKIT_COMPOSITOR)
583 if (visible_)
584 web_layer_.setOpacity(opacity);
585 RecomputeDrawsContent();
586 #endif
498 } 587 }
499 588
500 void Layer::SetBoundsFromAnimator(const gfx::Rect& bounds) { 589 void Layer::SetBoundsFromAnimator(const gfx::Rect& bounds) {
501 SetBoundsImmediately(bounds); 590 SetBoundsImmediately(bounds);
502 } 591 }
503 592
504 void Layer::SetTransformFromAnimator(const Transform& transform) { 593 void Layer::SetTransformFromAnimator(const Transform& transform) {
505 SetTransformImmediately(transform); 594 SetTransformImmediately(transform);
506 } 595 }
507 596
508 void Layer::SetOpacityFromAnimator(float opacity) { 597 void Layer::SetOpacityFromAnimator(float opacity) {
509 SetOpacityImmediately(opacity); 598 SetOpacityImmediately(opacity);
510 } 599 }
511 600
601 #if defined(USE_WEBKIT_COMPOSITOR)
602 void Layer::CreateWebLayer() {
603 web_layer_ = WebKit::WebContentLayer::create(this, this);
604 web_layer_.setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f));
605 web_layer_.setOpaque(true);
606 RecomputeDrawsContent();
607 }
608
609 void Layer::RecomputeTransform() {
610 ui::Transform transform = transform_;
611 transform.ConcatTranslate(bounds_.x(), bounds_.y());
612 web_layer_.setTransform(transform.matrix());
613 }
614
615 void Layer::RecomputeDrawsContent() {
616 web_layer_.setDrawsContent(ShouldDraw());
617 }
618 #endif
619
512 } // namespace ui 620 } // namespace ui
OLDNEW
« no previous file with comments | « ui/gfx/compositor/layer.h ('k') | ui/gfx/compositor/layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698