Chromium Code Reviews| Index: ui/compositor/layer.cc |
| diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc |
| index 6a3308e08305f5a1da6b0bd4302ba6b9bc4096ed..18ae24808f4a1ab709227c36bca0a50221aca13a 100644 |
| --- a/ui/compositor/layer.cc |
| +++ b/ui/compositor/layer.cc |
| @@ -86,6 +86,7 @@ Layer::Layer(LayerType type) |
| zoom_(1), |
| zoom_inset_(0), |
| delegate_(NULL), |
| + cc_layer_(NULL), |
| scale_content_(true), |
| device_scale_factor_(1.0f) { |
| CreateWebLayer(); |
| @@ -514,6 +515,25 @@ void Layer::SetExternalTexture(Texture* texture) { |
| RecomputeDrawsContentAndUVRect(); |
| } |
| +void Layer::SetTextureMailbox(const cc::TextureMailbox& mailbox, |
| + float device_scale_factor) { |
| + DCHECK_EQ(type_, LAYER_TEXTURED); |
| + DCHECK(!solid_color_layer_); |
| + layer_updated_externally_ = true; |
| + texture_ = NULL; |
| + if (!texture_layer_ || !texture_layer_->uses_mailbox()) { |
| + scoped_refptr<cc::TextureLayer> new_layer = |
| + cc::TextureLayer::CreateForMailbox(this); |
| + new_layer->SetFlipped(false); |
| + SwitchToLayer(new_layer); |
| + texture_layer_ = new_layer; |
| + } |
| + texture_layer_->SetTextureMailbox(mailbox); |
| + mailbox_ = mailbox; |
| + mailbox_scale_factor_ = device_scale_factor; |
| + RecomputeDrawsContentAndUVRect(); |
| +} |
|
piman
2013/05/28 20:58:57
So, one missing piece here is Window::RecreateLaye
slavi
2013/05/29 18:31:48
Done.
|
| + |
| void Layer::SetDelegatedFrame(scoped_ptr<cc::DelegatedFrameData> frame, |
| gfx::Size frame_size_in_dip) { |
| DCHECK_EQ(type_, LAYER_TEXTURED); |
| @@ -636,12 +656,16 @@ void Layer::PaintContents(SkCanvas* sk_canvas, |
| unsigned Layer::PrepareTexture(cc::ResourceUpdateQueue* queue) { |
| DCHECK(texture_layer_); |
| - return texture_->PrepareTexture(); |
| + if (texture_) |
| + return texture_->PrepareTexture(); |
| + return 0; |
| } |
| WebKit::WebGraphicsContext3D* Layer::Context3d() { |
| DCHECK(texture_layer_); |
| - return texture_->HostContext3D(); |
| + if (texture_) |
| + return texture_->HostContext3D(); |
| + return NULL; |
| } |
| bool Layer::PrepareTextureMailbox(cc::TextureMailbox* mailbox) { |
| @@ -919,11 +943,17 @@ void Layer::RecomputeDrawsContentAndUVRect() { |
| DCHECK(cc_layer_); |
| gfx::Size size(bounds_.size()); |
| if (texture_layer_.get()) { |
| - DCHECK(texture_); |
| - |
| - float texture_scale_factor = 1.0f / texture_->device_scale_factor(); |
| - gfx::Size texture_size = gfx::ToFlooredSize( |
| - gfx::ScaleSize(texture_->size(), texture_scale_factor)); |
| + gfx::Size texture_size; |
| + if (!texture_layer_->uses_mailbox()) { |
| + DCHECK(texture_); |
| + float texture_scale_factor = 1.0f / texture_->device_scale_factor(); |
| + texture_size = gfx::ToFlooredSize( |
| + gfx::ScaleSize(texture_->size(), texture_scale_factor)); |
| + } else { |
| + float texture_scale_factor = 1.0f / mailbox_scale_factor_; |
| + texture_size = gfx::ToFlooredSize( |
| + gfx::ScaleSize(mailbox_.size(), texture_scale_factor)); |
| + } |
| size.ClampToMax(texture_size); |
| gfx::PointF uv_top_left(0.f, 0.f); |