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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 SwitchToLayer(new_layer); | 511 SwitchToLayer(new_layer); |
512 content_layer_ = new_layer; | 512 content_layer_ = new_layer; |
513 } | 513 } |
514 } | 514 } |
515 RecomputeDrawsContentAndUVRect(); | 515 RecomputeDrawsContentAndUVRect(); |
516 } | 516 } |
517 | 517 |
518 void Layer::SetTextureMailbox(const cc::TextureMailbox& mailbox, | 518 void Layer::SetTextureMailbox(const cc::TextureMailbox& mailbox, |
519 float scale_factor) { | 519 float scale_factor) { |
520 DCHECK_EQ(type_, LAYER_TEXTURED); | 520 DCHECK_EQ(type_, LAYER_TEXTURED); |
521 DCHECK(!solid_color_layer_); | 521 DCHECK(!solid_color_layer_.get()); |
522 layer_updated_externally_ = true; | 522 layer_updated_externally_ = true; |
523 texture_ = NULL; | 523 texture_ = NULL; |
524 if (!texture_layer_ || !texture_layer_->uses_mailbox()) { | 524 if (!texture_layer_.get() || !texture_layer_->uses_mailbox()) { |
525 scoped_refptr<cc::TextureLayer> new_layer = | 525 scoped_refptr<cc::TextureLayer> new_layer = |
526 cc::TextureLayer::CreateForMailbox(this); | 526 cc::TextureLayer::CreateForMailbox(this); |
527 new_layer->SetFlipped(false); | 527 new_layer->SetFlipped(false); |
528 SwitchToLayer(new_layer); | 528 SwitchToLayer(new_layer); |
529 texture_layer_ = new_layer; | 529 texture_layer_ = new_layer; |
530 } | 530 } |
531 texture_layer_->SetTextureMailbox(mailbox); | 531 texture_layer_->SetTextureMailbox(mailbox); |
532 mailbox_ = mailbox; | 532 mailbox_ = mailbox; |
533 mailbox_scale_factor_ = scale_factor; | 533 mailbox_scale_factor_ = scale_factor; |
534 RecomputeDrawsContentAndUVRect(); | 534 RecomputeDrawsContentAndUVRect(); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 canvas->Restore(); | 660 canvas->Restore(); |
661 } | 661 } |
662 | 662 |
663 unsigned Layer::PrepareTexture(cc::ResourceUpdateQueue* queue) { | 663 unsigned Layer::PrepareTexture(cc::ResourceUpdateQueue* queue) { |
664 DCHECK(texture_layer_.get()); | 664 DCHECK(texture_layer_.get()); |
665 return texture_->PrepareTexture(); | 665 return texture_->PrepareTexture(); |
666 } | 666 } |
667 | 667 |
668 WebKit::WebGraphicsContext3D* Layer::Context3d() { | 668 WebKit::WebGraphicsContext3D* Layer::Context3d() { |
669 DCHECK(texture_layer_.get()); | 669 DCHECK(texture_layer_.get()); |
670 if (texture_) | 670 if (texture_.get()) |
671 return texture_->HostContext3D(); | 671 return texture_->HostContext3D(); |
672 return NULL; | 672 return NULL; |
673 } | 673 } |
674 | 674 |
675 bool Layer::PrepareTextureMailbox(cc::TextureMailbox* mailbox) { | 675 bool Layer::PrepareTextureMailbox(cc::TextureMailbox* mailbox) { |
676 return false; | 676 return false; |
677 } | 677 } |
678 | 678 |
679 void Layer::SetForceRenderSurface(bool force) { | 679 void Layer::SetForceRenderSurface(bool force) { |
680 if (force_render_surface_ == force) | 680 if (force_render_surface_ == force) |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 transform.Scale(device_scale_factor_, device_scale_factor_); | 942 transform.Scale(device_scale_factor_, device_scale_factor_); |
943 return transform; | 943 return transform; |
944 } | 944 } |
945 | 945 |
946 void Layer::RecomputeDrawsContentAndUVRect() { | 946 void Layer::RecomputeDrawsContentAndUVRect() { |
947 DCHECK(cc_layer_); | 947 DCHECK(cc_layer_); |
948 gfx::Size size(bounds_.size()); | 948 gfx::Size size(bounds_.size()); |
949 if (texture_layer_.get()) { | 949 if (texture_layer_.get()) { |
950 gfx::Size texture_size; | 950 gfx::Size texture_size; |
951 if (!texture_layer_->uses_mailbox()) { | 951 if (!texture_layer_->uses_mailbox()) { |
952 DCHECK(texture_); | 952 DCHECK(texture_.get()); |
953 float texture_scale_factor = 1.0f / texture_->device_scale_factor(); | 953 float texture_scale_factor = 1.0f / texture_->device_scale_factor(); |
954 texture_size = gfx::ToFlooredSize( | 954 texture_size = gfx::ToFlooredSize( |
955 gfx::ScaleSize(texture_->size(), texture_scale_factor)); | 955 gfx::ScaleSize(texture_->size(), texture_scale_factor)); |
956 } else { | 956 } else { |
957 DCHECK(mailbox_.IsSharedMemory()); | 957 DCHECK(mailbox_.IsSharedMemory()); |
958 float texture_scale_factor = 1.0f / mailbox_scale_factor_; | 958 float texture_scale_factor = 1.0f / mailbox_scale_factor_; |
959 texture_size = gfx::ToFlooredSize( | 959 texture_size = gfx::ToFlooredSize( |
960 gfx::ScaleSize(mailbox_.shared_memory_size(), texture_scale_factor)); | 960 gfx::ScaleSize(mailbox_.shared_memory_size(), texture_scale_factor)); |
961 } | 961 } |
962 size.SetToMin(texture_size); | 962 size.SetToMin(texture_size); |
(...skipping 11 matching lines...) Expand all Loading... |
974 cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); | 974 cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); |
975 } | 975 } |
976 | 976 |
977 void Layer::RecomputePosition() { | 977 void Layer::RecomputePosition() { |
978 cc_layer_->SetPosition(gfx::ScalePoint( | 978 cc_layer_->SetPosition(gfx::ScalePoint( |
979 gfx::PointF(bounds_.x(), bounds_.y()), | 979 gfx::PointF(bounds_.x(), bounds_.y()), |
980 device_scale_factor_)); | 980 device_scale_factor_)); |
981 } | 981 } |
982 | 982 |
983 } // namespace ui | 983 } // namespace ui |
OLD | NEW |