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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 if (!delegate_) | 312 if (!delegate_) |
313 return; | 313 return; |
314 delegate_ = NULL; | 314 delegate_ = NULL; |
315 for (size_t i = 0; i < children_.size(); ++i) | 315 for (size_t i = 0; i < children_.size(); ++i) |
316 children_[i]->SuppressPaint(); | 316 children_[i]->SuppressPaint(); |
317 } | 317 } |
318 | 318 |
319 void Layer::paintContents(WebKit::WebCanvas* web_canvas, | 319 void Layer::paintContents(WebKit::WebCanvas* web_canvas, |
320 const WebKit::WebRect& clip) { | 320 const WebKit::WebRect& clip) { |
321 TRACE_EVENT0("ui", "Layer::paintContents"); | 321 TRACE_EVENT0("ui", "Layer::paintContents"); |
322 gfx::CanvasSkia canvas(web_canvas); | 322 gfx::Canvas canvas(web_canvas); |
323 if (delegate_) | 323 if (delegate_) |
324 delegate_->OnPaintLayer(&canvas); | 324 delegate_->OnPaintLayer(&canvas); |
325 } | 325 } |
326 | 326 |
327 float Layer::GetCombinedOpacity() const { | 327 float Layer::GetCombinedOpacity() const { |
328 float opacity = opacity_; | 328 float opacity = opacity_; |
329 Layer* current = this->parent_; | 329 Layer* current = this->parent_; |
330 while (current) { | 330 while (current) { |
331 opacity *= current->opacity_; | 331 opacity *= current->opacity_; |
332 current = current->parent_; | 332 current = current->parent_; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 return; | 520 return; |
521 unsigned int color = 0xFF000000; | 521 unsigned int color = 0xFF000000; |
522 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; | 522 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; |
523 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); | 523 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); |
524 if (!opaque) | 524 if (!opaque) |
525 color |= 0xFF; | 525 color |= 0xFF; |
526 web_layer_.setDebugBorderColor(color); | 526 web_layer_.setDebugBorderColor(color); |
527 } | 527 } |
528 | 528 |
529 } // namespace ui | 529 } // namespace ui |
OLD | NEW |