OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebContentLa
yer.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebContentLa
yer.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebExternalT
extureLayer.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebExternalT
extureLayer.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFloatPoin
t.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFloatPoin
t.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFloatRect
.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFloatRect
.h" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSolidColo
rLayer.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSolidColo
rLayer.h" |
19 #include "ui/base/animation/animation.h" | 19 #include "ui/base/animation/animation.h" |
20 #include "ui/gfx/canvas_skia.h" | 20 #include "ui/gfx/canvas.h" |
21 #include "ui/gfx/compositor/compositor_switches.h" | 21 #include "ui/gfx/compositor/compositor_switches.h" |
22 #include "ui/gfx/compositor/layer_animator.h" | 22 #include "ui/gfx/compositor/layer_animator.h" |
23 #include "ui/gfx/interpolated_transform.h" | 23 #include "ui/gfx/interpolated_transform.h" |
24 #include "ui/gfx/point3.h" | 24 #include "ui/gfx/point3.h" |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 const float EPSILON = 1e-3f; | 28 const float EPSILON = 1e-3f; |
29 | 29 |
30 bool IsApproximateMultipleOf(float value, float base) { | 30 bool IsApproximateMultipleOf(float value, float base) { |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 if (!delegate_) | 318 if (!delegate_) |
319 return; | 319 return; |
320 delegate_ = NULL; | 320 delegate_ = NULL; |
321 for (size_t i = 0; i < children_.size(); ++i) | 321 for (size_t i = 0; i < children_.size(); ++i) |
322 children_[i]->SuppressPaint(); | 322 children_[i]->SuppressPaint(); |
323 } | 323 } |
324 | 324 |
325 void Layer::paintContents(WebKit::WebCanvas* web_canvas, | 325 void Layer::paintContents(WebKit::WebCanvas* web_canvas, |
326 const WebKit::WebRect& clip) { | 326 const WebKit::WebRect& clip) { |
327 TRACE_EVENT0("ui", "Layer::paintContents"); | 327 TRACE_EVENT0("ui", "Layer::paintContents"); |
328 gfx::CanvasSkia canvas(web_canvas); | 328 gfx::Canvas canvas(web_canvas); |
329 if (delegate_) | 329 if (delegate_) |
330 delegate_->OnPaintLayer(&canvas); | 330 delegate_->OnPaintLayer(&canvas); |
331 } | 331 } |
332 | 332 |
333 float Layer::GetCombinedOpacity() const { | 333 float Layer::GetCombinedOpacity() const { |
334 float opacity = opacity_; | 334 float opacity = opacity_; |
335 Layer* current = this->parent_; | 335 Layer* current = this->parent_; |
336 while (current) { | 336 while (current) { |
337 opacity *= current->opacity_; | 337 opacity *= current->opacity_; |
338 current = current->parent_; | 338 current = current->parent_; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 return; | 526 return; |
527 unsigned int color = 0xFF000000; | 527 unsigned int color = 0xFF000000; |
528 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; | 528 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; |
529 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); | 529 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); |
530 if (!opaque) | 530 if (!opaque) |
531 color |= 0xFF; | 531 color |= 0xFF; |
532 web_layer_.setDebugBorderColor(color); | 532 web_layer_.setDebugBorderColor(color); |
533 } | 533 } |
534 | 534 |
535 } // namespace ui | 535 } // namespace ui |
OLD | NEW |