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/compositor/layer.h" | 5 #include "ui/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" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 delegate_(NULL), | 88 delegate_(NULL), |
89 scale_content_(true), | 89 scale_content_(true), |
90 device_scale_factor_(1.0f) { | 90 device_scale_factor_(1.0f) { |
91 CreateWebLayer(); | 91 CreateWebLayer(); |
92 } | 92 } |
93 | 93 |
94 Layer::~Layer() { | 94 Layer::~Layer() { |
95 // Destroying the animator may cause observers to use the layer (and | 95 // Destroying the animator may cause observers to use the layer (and |
96 // indirectly the WebLayer). Destroy the animator first so that the WebLayer | 96 // indirectly the WebLayer). Destroy the animator first so that the WebLayer |
97 // is still around. | 97 // is still around. |
98 if (animator_) | 98 if (animator_.get()) |
99 animator_->SetDelegate(NULL); | 99 animator_->SetDelegate(NULL); |
100 animator_ = NULL; | 100 animator_ = NULL; |
101 if (compositor_) | 101 if (compositor_) |
102 compositor_->SetRootLayer(NULL); | 102 compositor_->SetRootLayer(NULL); |
103 if (parent_) | 103 if (parent_) |
104 parent_->Remove(this); | 104 parent_->Remove(this); |
105 if (layer_mask_) | 105 if (layer_mask_) |
106 SetMaskLayer(NULL); | 106 SetMaskLayer(NULL); |
107 if (layer_mask_back_link_) | 107 if (layer_mask_back_link_) |
108 layer_mask_back_link_->SetMaskLayer(NULL); | 108 layer_mask_back_link_->SetMaskLayer(NULL); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 RecomputeDebugBorderColor(); | 421 RecomputeDebugBorderColor(); |
422 } | 422 } |
423 RecomputeDrawsContentAndUVRect(); | 423 RecomputeDrawsContentAndUVRect(); |
424 } | 424 } |
425 | 425 |
426 void Layer::SetColor(SkColor color) { | 426 void Layer::SetColor(SkColor color) { |
427 GetAnimator()->SetColor(color); | 427 GetAnimator()->SetColor(color); |
428 } | 428 } |
429 | 429 |
430 bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) { | 430 bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) { |
431 if (type_ == LAYER_SOLID_COLOR || (!delegate_ && !texture_)) | 431 if (type_ == LAYER_SOLID_COLOR || (!delegate_ && !texture_.get())) |
432 return false; | 432 return false; |
433 | 433 |
434 damaged_region_.op(invalid_rect.x(), | 434 damaged_region_.op(invalid_rect.x(), |
435 invalid_rect.y(), | 435 invalid_rect.y(), |
436 invalid_rect.right(), | 436 invalid_rect.right(), |
437 invalid_rect.bottom(), | 437 invalid_rect.bottom(), |
438 SkRegion::kUnion_Op); | 438 SkRegion::kUnion_Op); |
439 ScheduleDraw(); | 439 ScheduleDraw(); |
440 return true; | 440 return true; |
441 } | 441 } |
442 | 442 |
443 void Layer::ScheduleDraw() { | 443 void Layer::ScheduleDraw() { |
444 Compositor* compositor = GetCompositor(); | 444 Compositor* compositor = GetCompositor(); |
445 if (compositor) | 445 if (compositor) |
446 compositor->ScheduleDraw(); | 446 compositor->ScheduleDraw(); |
447 } | 447 } |
448 | 448 |
449 void Layer::SendDamagedRects() { | 449 void Layer::SendDamagedRects() { |
450 if ((delegate_ || texture_) && !damaged_region_.isEmpty()) { | 450 if ((delegate_ || texture_.get()) && !damaged_region_.isEmpty()) { |
451 for (SkRegion::Iterator iter(damaged_region_); | 451 for (SkRegion::Iterator iter(damaged_region_); |
452 !iter.done(); iter.next()) { | 452 !iter.done(); iter.next()) { |
453 const SkIRect& sk_damaged = iter.rect(); | 453 const SkIRect& sk_damaged = iter.rect(); |
454 gfx::Rect damaged( | 454 gfx::Rect damaged( |
455 sk_damaged.x(), | 455 sk_damaged.x(), |
456 sk_damaged.y(), | 456 sk_damaged.y(), |
457 sk_damaged.width(), | 457 sk_damaged.width(), |
458 sk_damaged.height()); | 458 sk_damaged.height()); |
459 | 459 |
460 gfx::Rect damaged_in_pixel = ConvertRectToPixel(this, damaged); | 460 gfx::Rect damaged_in_pixel = ConvertRectToPixel(this, damaged); |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 return; | 788 return; |
789 unsigned int color = 0xFF000000; | 789 unsigned int color = 0xFF000000; |
790 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; | 790 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; |
791 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); | 791 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); |
792 if (!opaque) | 792 if (!opaque) |
793 color |= 0xFF; | 793 color |= 0xFF; |
794 web_layer_->setDebugBorderColor(color); | 794 web_layer_->setDebugBorderColor(color); |
795 } | 795 } |
796 | 796 |
797 } // namespace ui | 797 } // namespace ui |
OLD | NEW |