Chromium Code Reviews| 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 DCHECK_EQ(type_, LAYER_SOLID_COLOR); | 302 DCHECK_EQ(type_, LAYER_SOLID_COLOR); |
| 303 // WebColor is equivalent to SkColor, per WebColor.h. | 303 // WebColor is equivalent to SkColor, per WebColor.h. |
| 304 web_layer_.to<WebKit::WebSolidColorLayer>().setBackgroundColor( | 304 web_layer_.to<WebKit::WebSolidColorLayer>().setBackgroundColor( |
| 305 static_cast<WebKit::WebColor>(color)); | 305 static_cast<WebKit::WebColor>(color)); |
| 306 SetFillsBoundsOpaquely(SkColorGetA(color) == 0xFF); | 306 SetFillsBoundsOpaquely(SkColorGetA(color) == 0xFF); |
| 307 } | 307 } |
| 308 | 308 |
| 309 bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) { | 309 bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) { |
| 310 if (type_ == LAYER_SOLID_COLOR || !delegate_) | 310 if (type_ == LAYER_SOLID_COLOR || !delegate_) |
| 311 return false; | 311 return false; |
| 312 gfx::Rect invalid_rect_in_pixel = ConvertRectToPixel(this, invalid_rect); | 312 if (web_layer_is_accelerated_) { |
|
oshima
2012/05/09 21:11:58
DCHECK(texture_);
Please add comment + TODO
| |
| 313 damaged_region_.op(invalid_rect_in_pixel.x(), | 313 damaged_region_.op(invalid_rect.x(), |
| 314 invalid_rect_in_pixel.y(), | 314 invalid_rect.y(), |
| 315 invalid_rect_in_pixel.right(), | 315 invalid_rect.right(), |
| 316 invalid_rect_in_pixel.bottom(), | 316 invalid_rect.bottom(), |
| 317 SkRegion::kUnion_Op); | 317 SkRegion::kUnion_Op); |
| 318 } else { | |
| 319 gfx::Rect invalid_rect_in_pixel = ConvertRectToPixel(this, invalid_rect); | |
| 320 damaged_region_.op(invalid_rect_in_pixel.x(), | |
| 321 invalid_rect_in_pixel.y(), | |
| 322 invalid_rect_in_pixel.right(), | |
| 323 invalid_rect_in_pixel.bottom(), | |
| 324 SkRegion::kUnion_Op); | |
| 325 } | |
| 318 ScheduleDraw(); | 326 ScheduleDraw(); |
| 319 return true; | 327 return true; |
| 320 } | 328 } |
| 321 | 329 |
| 322 void Layer::ScheduleDraw() { | 330 void Layer::ScheduleDraw() { |
| 323 Compositor* compositor = GetCompositor(); | 331 Compositor* compositor = GetCompositor(); |
| 324 if (compositor) | 332 if (compositor) |
| 325 compositor->ScheduleDraw(); | 333 compositor->ScheduleDraw(); |
| 326 } | 334 } |
| 327 | 335 |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 549 scale_translate.matrix().set3x3(device_scale_factor_, 0, 0, | 557 scale_translate.matrix().set3x3(device_scale_factor_, 0, 0, |
| 550 0, device_scale_factor_, 0, | 558 0, device_scale_factor_, 0, |
| 551 0, 0, 1); | 559 0, 0, 1); |
| 552 // Start with the inverse matrix of above. | 560 // Start with the inverse matrix of above. |
| 553 Transform transform; | 561 Transform transform; |
| 554 transform.matrix().set3x3(1.0f / device_scale_factor_, 0, 0, | 562 transform.matrix().set3x3(1.0f / device_scale_factor_, 0, 0, |
| 555 0, 1.0f / device_scale_factor_, 0, | 563 0, 1.0f / device_scale_factor_, 0, |
| 556 0, 0, 1); | 564 0, 0, 1); |
| 557 transform.ConcatTransform(transform_); | 565 transform.ConcatTransform(transform_); |
| 558 transform.ConcatTranslate(bounds_.x(), bounds_.y()); | 566 transform.ConcatTranslate(bounds_.x(), bounds_.y()); |
| 567 | |
| 568 if (texture_) | |
| 569 transform.ConcatScale(device_scale_factor_, device_scale_factor_); | |
| 570 | |
| 559 transform.ConcatTransform(scale_translate); | 571 transform.ConcatTransform(scale_translate); |
| 560 web_layer_.setTransform(transform.matrix()); | 572 web_layer_.setTransform(transform.matrix()); |
| 561 } else { | 573 } else { |
| 562 Transform t = transform_; | 574 Transform t = transform_; |
| 563 t.ConcatTranslate(bounds_.x(), bounds_.y()); | 575 t.ConcatTranslate(bounds_.x(), bounds_.y()); |
| 564 web_layer_.setTransform(t.matrix()); | 576 web_layer_.setTransform(t.matrix()); |
| 565 } | 577 } |
| 566 } | 578 } |
| 567 | 579 |
| 568 void Layer::RecomputeDrawsContentAndUVRect() { | 580 void Layer::RecomputeDrawsContentAndUVRect() { |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 597 return; | 609 return; |
| 598 unsigned int color = 0xFF000000; | 610 unsigned int color = 0xFF000000; |
| 599 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; | 611 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; |
| 600 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); | 612 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); |
| 601 if (!opaque) | 613 if (!opaque) |
| 602 color |= 0xFF; | 614 color |= 0xFF; |
| 603 web_layer_.setDebugBorderColor(color); | 615 web_layer_.setDebugBorderColor(color); |
| 604 } | 616 } |
| 605 | 617 |
| 606 } // namespace ui | 618 } // namespace ui |
| OLD | NEW |