| 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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 } else { | 496 } else { |
| 497 scoped_refptr<cc::ContentLayer> new_layer = | 497 scoped_refptr<cc::ContentLayer> new_layer = |
| 498 cc::ContentLayer::Create(this); | 498 cc::ContentLayer::Create(this); |
| 499 SwitchToLayer(new_layer); | 499 SwitchToLayer(new_layer); |
| 500 content_layer_ = new_layer; | 500 content_layer_ = new_layer; |
| 501 } | 501 } |
| 502 } | 502 } |
| 503 RecomputeDrawsContentAndUVRect(); | 503 RecomputeDrawsContentAndUVRect(); |
| 504 } | 504 } |
| 505 | 505 |
| 506 void Layer::SetTextureMailbox(const cc::TextureMailbox& mailbox, | 506 void Layer::SetTextureMailbox( |
| 507 float scale_factor) { | 507 const cc::TextureMailbox& mailbox, |
| 508 scoped_ptr<cc::ScopedReleaseCallback> release_callback, |
| 509 float scale_factor) { |
| 508 DCHECK_EQ(type_, LAYER_TEXTURED); | 510 DCHECK_EQ(type_, LAYER_TEXTURED); |
| 509 DCHECK(!solid_color_layer_.get()); | 511 DCHECK(!solid_color_layer_.get()); |
| 510 layer_updated_externally_ = true; | 512 layer_updated_externally_ = true; |
| 511 texture_ = NULL; | 513 texture_ = NULL; |
| 512 if (!texture_layer_.get() || !texture_layer_->uses_mailbox()) { | 514 if (!texture_layer_.get() || !texture_layer_->uses_mailbox()) { |
| 513 scoped_refptr<cc::TextureLayer> new_layer = | 515 scoped_refptr<cc::TextureLayer> new_layer = |
| 514 cc::TextureLayer::CreateForMailbox(this); | 516 cc::TextureLayer::CreateForMailbox(this); |
| 515 new_layer->SetFlipped(false); | 517 new_layer->SetFlipped(false); |
| 516 SwitchToLayer(new_layer); | 518 SwitchToLayer(new_layer); |
| 517 texture_layer_ = new_layer; | 519 texture_layer_ = new_layer; |
| 518 } | 520 } |
| 519 texture_layer_->SetTextureMailbox(mailbox); | 521 texture_layer_->SetTextureMailbox(mailbox, release_callback.Pass()); |
| 520 mailbox_ = mailbox; | 522 mailbox_ = mailbox; |
| 521 mailbox_scale_factor_ = scale_factor; | 523 mailbox_scale_factor_ = scale_factor; |
| 522 RecomputeDrawsContentAndUVRect(); | 524 RecomputeDrawsContentAndUVRect(); |
| 523 } | 525 } |
| 524 | 526 |
| 525 cc::TextureMailbox Layer::GetTextureMailbox(float* scale_factor) { | 527 cc::TextureMailbox Layer::GetTextureMailbox(float* scale_factor) { |
| 526 if (scale_factor) | 528 if (scale_factor) |
| 527 *scale_factor = mailbox_scale_factor_; | 529 *scale_factor = mailbox_scale_factor_; |
| 528 cc::TextureMailbox::ReleaseCallback callback; | 530 return mailbox_; |
| 529 return mailbox_.CopyWithNewCallback(callback); | |
| 530 } | 531 } |
| 531 | 532 |
| 532 void Layer::SetDelegatedFrame(scoped_ptr<cc::DelegatedFrameData> frame, | 533 void Layer::SetDelegatedFrame(scoped_ptr<cc::DelegatedFrameData> frame, |
| 533 gfx::Size frame_size_in_dip) { | 534 gfx::Size frame_size_in_dip) { |
| 534 DCHECK_EQ(type_, LAYER_TEXTURED); | 535 DCHECK_EQ(type_, LAYER_TEXTURED); |
| 535 bool has_frame = frame.get() && !frame->render_pass_list.empty(); | 536 bool has_frame = frame.get() && !frame->render_pass_list.empty(); |
| 536 layer_updated_externally_ = has_frame; | 537 layer_updated_externally_ = has_frame; |
| 537 delegated_frame_size_in_dip_ = frame_size_in_dip; | 538 delegated_frame_size_in_dip_ = frame_size_in_dip; |
| 538 if (!!delegated_renderer_layer_.get() != has_frame) { | 539 if (!!delegated_renderer_layer_.get() != has_frame) { |
| 539 if (has_frame) { | 540 if (has_frame) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 return texture_->PrepareTexture(); | 658 return texture_->PrepareTexture(); |
| 658 } | 659 } |
| 659 | 660 |
| 660 WebKit::WebGraphicsContext3D* Layer::Context3d() { | 661 WebKit::WebGraphicsContext3D* Layer::Context3d() { |
| 661 DCHECK(texture_layer_.get()); | 662 DCHECK(texture_layer_.get()); |
| 662 if (texture_.get()) | 663 if (texture_.get()) |
| 663 return texture_->HostContext3D(); | 664 return texture_->HostContext3D(); |
| 664 return NULL; | 665 return NULL; |
| 665 } | 666 } |
| 666 | 667 |
| 667 bool Layer::PrepareTextureMailbox(cc::TextureMailbox* mailbox, | 668 bool Layer::PrepareTextureMailbox( |
| 668 bool use_shared_memory) { | 669 cc::TextureMailbox* mailbox, |
| 670 scoped_ptr<cc::ScopedReleaseCallback>* release_callback, |
| 671 bool use_shared_memory) { |
| 669 return false; | 672 return false; |
| 670 } | 673 } |
| 671 | 674 |
| 672 void Layer::SetForceRenderSurface(bool force) { | 675 void Layer::SetForceRenderSurface(bool force) { |
| 673 if (force_render_surface_ == force) | 676 if (force_render_surface_ == force) |
| 674 return; | 677 return; |
| 675 | 678 |
| 676 force_render_surface_ = force; | 679 force_render_surface_ = force; |
| 677 cc_layer_->SetForceRenderSurface(force_render_surface_); | 680 cc_layer_->SetForceRenderSurface(force_render_surface_); |
| 678 } | 681 } |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); | 974 cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); |
| 972 } | 975 } |
| 973 | 976 |
| 974 void Layer::RecomputePosition() { | 977 void Layer::RecomputePosition() { |
| 975 cc_layer_->SetPosition(gfx::ScalePoint( | 978 cc_layer_->SetPosition(gfx::ScalePoint( |
| 976 gfx::PointF(bounds_.x(), bounds_.y()), | 979 gfx::PointF(bounds_.x(), bounds_.y()), |
| 977 device_scale_factor_)); | 980 device_scale_factor_)); |
| 978 } | 981 } |
| 979 | 982 |
| 980 } // namespace ui | 983 } // namespace ui |
| OLD | NEW |