| OLD | NEW |
| 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/debug/trace_event.h" |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContentLayer.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContentLayer.h" |
| 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebExternalTextureLay
er.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebExternalTextureLay
er.h" |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFloatPoint.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFloatPoint.h" |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFloatRect.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFloatRect.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" |
| 16 #include "ui/base/animation/animation.h" | 17 #include "ui/base/animation/animation.h" |
| 17 #if defined(USE_WEBKIT_COMPOSITOR) | 18 #if defined(USE_WEBKIT_COMPOSITOR) |
| 18 #include "ui/gfx/compositor/compositor_cc.h" | 19 #include "ui/gfx/compositor/compositor_cc.h" |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 #endif | 298 #endif |
| 298 } | 299 } |
| 299 | 300 |
| 300 void Layer::ScheduleDraw() { | 301 void Layer::ScheduleDraw() { |
| 301 Compositor* compositor = GetCompositor(); | 302 Compositor* compositor = GetCompositor(); |
| 302 if (compositor) | 303 if (compositor) |
| 303 compositor->ScheduleDraw(); | 304 compositor->ScheduleDraw(); |
| 304 } | 305 } |
| 305 | 306 |
| 306 void Layer::Draw() { | 307 void Layer::Draw() { |
| 308 TRACE_EVENT0("ui", "Layer::Draw"); |
| 307 #if defined(USE_WEBKIT_COMPOSITOR) | 309 #if defined(USE_WEBKIT_COMPOSITOR) |
| 308 NOTREACHED(); | 310 NOTREACHED(); |
| 309 #else | 311 #else |
| 310 DCHECK(GetCompositor()); | 312 DCHECK(GetCompositor()); |
| 311 | 313 |
| 312 if (recompute_hole_ && !parent_) | 314 if (recompute_hole_ && !parent_) |
| 313 RecomputeHole(); | 315 RecomputeHole(); |
| 314 | 316 |
| 315 if (!ShouldDraw()) | 317 if (!ShouldDraw()) |
| 316 return; | 318 return; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 void Layer::notifyNeedsComposite() { | 371 void Layer::notifyNeedsComposite() { |
| 370 #if defined(USE_WEBKIT_COMPOSITOR) | 372 #if defined(USE_WEBKIT_COMPOSITOR) |
| 371 ScheduleDraw(); | 373 ScheduleDraw(); |
| 372 #else | 374 #else |
| 373 NOTREACHED(); | 375 NOTREACHED(); |
| 374 #endif | 376 #endif |
| 375 } | 377 } |
| 376 | 378 |
| 377 void Layer::paintContents(WebKit::WebCanvas* web_canvas, | 379 void Layer::paintContents(WebKit::WebCanvas* web_canvas, |
| 378 const WebKit::WebRect& clip) { | 380 const WebKit::WebRect& clip) { |
| 381 TRACE_EVENT0("ui", "Layer::paintContents"); |
| 379 #if defined(USE_WEBKIT_COMPOSITOR) | 382 #if defined(USE_WEBKIT_COMPOSITOR) |
| 380 gfx::CanvasSkia canvas(web_canvas); | 383 gfx::CanvasSkia canvas(web_canvas); |
| 381 delegate_->OnPaintLayer(&canvas); | 384 delegate_->OnPaintLayer(&canvas); |
| 382 #else | 385 #else |
| 383 NOTREACHED(); | 386 NOTREACHED(); |
| 384 #endif | 387 #endif |
| 385 } | 388 } |
| 386 | 389 |
| 387 float Layer::GetCombinedOpacity() const { | 390 float Layer::GetCombinedOpacity() const { |
| 388 float opacity = opacity_; | 391 float opacity = opacity_; |
| 389 Layer* current = this->parent_; | 392 Layer* current = this->parent_; |
| 390 while (current) { | 393 while (current) { |
| 391 opacity *= current->opacity_; | 394 opacity *= current->opacity_; |
| 392 current = current->parent_; | 395 current = current->parent_; |
| 393 } | 396 } |
| 394 return opacity; | 397 return opacity; |
| 395 } | 398 } |
| 396 | 399 |
| 397 void Layer::UpdateLayerCanvas() { | 400 void Layer::UpdateLayerCanvas() { |
| 401 TRACE_EVENT0("ui", "Layer::UpdateLayerCanvas"); |
| 398 #if defined(USE_WEBKIT_COMPOSITOR) | 402 #if defined(USE_WEBKIT_COMPOSITOR) |
| 399 NOTREACHED(); | 403 NOTREACHED(); |
| 400 #else | 404 #else |
| 401 // If we have no delegate, that means that whoever constructed the Layer is | 405 // If we have no delegate, that means that whoever constructed the Layer is |
| 402 // setting its canvas directly with SetCanvas(). | 406 // setting its canvas directly with SetCanvas(). |
| 403 if (!delegate_ || layer_updated_externally_) | 407 if (!delegate_ || layer_updated_externally_) |
| 404 return; | 408 return; |
| 405 gfx::Rect local_bounds = gfx::Rect(gfx::Point(), bounds_.size()); | 409 gfx::Rect local_bounds = gfx::Rect(gfx::Point(), bounds_.size()); |
| 406 gfx::Rect draw_rect = texture_.get() ? invalid_rect_.Intersect(local_bounds) : | 410 gfx::Rect draw_rect = texture_.get() ? invalid_rect_.Intersect(local_bounds) : |
| 407 local_bounds; | 411 local_bounds; |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 #else | 688 #else |
| 685 unsigned int texture_id = 0; | 689 unsigned int texture_id = 0; |
| 686 #endif | 690 #endif |
| 687 web_layer_.to<WebKit::WebExternalTextureLayer>().setTextureId( | 691 web_layer_.to<WebKit::WebExternalTextureLayer>().setTextureId( |
| 688 should_draw ? texture_id : 0); | 692 should_draw ? texture_id : 0); |
| 689 } | 693 } |
| 690 } | 694 } |
| 691 #endif | 695 #endif |
| 692 | 696 |
| 693 } // namespace ui | 697 } // namespace ui |
| OLD | NEW |