| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "webkit/renderer/compositor_bindings/web_external_texture_layer_impl.h" | 5 #include "content/renderer/compositor_bindings/web_external_texture_layer_impl.h
" |
| 6 | 6 |
| 7 #include "cc/layers/texture_layer.h" | 7 #include "cc/layers/texture_layer.h" |
| 8 #include "cc/resources/resource_update_queue.h" | 8 #include "cc/resources/resource_update_queue.h" |
| 9 #include "cc/resources/single_release_callback.h" | 9 #include "cc/resources/single_release_callback.h" |
| 10 #include "cc/resources/texture_mailbox.h" | 10 #include "cc/resources/texture_mailbox.h" |
| 11 #include "content/renderer/compositor_bindings/web_external_bitmap_impl.h" |
| 12 #include "content/renderer/compositor_bindings/web_layer_impl.h" |
| 11 #include "third_party/WebKit/public/platform/WebExternalTextureLayerClient.h" | 13 #include "third_party/WebKit/public/platform/WebExternalTextureLayerClient.h" |
| 12 #include "third_party/WebKit/public/platform/WebExternalTextureMailbox.h" | 14 #include "third_party/WebKit/public/platform/WebExternalTextureMailbox.h" |
| 13 #include "third_party/WebKit/public/platform/WebFloatRect.h" | 15 #include "third_party/WebKit/public/platform/WebFloatRect.h" |
| 14 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 16 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
| 15 #include "third_party/WebKit/public/platform/WebSize.h" | 17 #include "third_party/WebKit/public/platform/WebSize.h" |
| 16 #include "third_party/khronos/GLES2/gl2.h" | 18 #include "third_party/khronos/GLES2/gl2.h" |
| 17 #include "webkit/renderer/compositor_bindings/web_external_bitmap_impl.h" | |
| 18 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" | |
| 19 | 19 |
| 20 using cc::TextureLayer; | 20 using cc::TextureLayer; |
| 21 using cc::ResourceUpdateQueue; | 21 using cc::ResourceUpdateQueue; |
| 22 | 22 |
| 23 namespace webkit { | 23 namespace content { |
| 24 | 24 |
| 25 WebExternalTextureLayerImpl::WebExternalTextureLayerImpl( | 25 WebExternalTextureLayerImpl::WebExternalTextureLayerImpl( |
| 26 blink::WebExternalTextureLayerClient* client) | 26 blink::WebExternalTextureLayerClient* client) |
| 27 : client_(client) { | 27 : client_(client) { |
| 28 cc::TextureLayerClient* cc_client = client_ ? this : NULL; | 28 cc::TextureLayerClient* cc_client = client_ ? this : NULL; |
| 29 scoped_refptr<TextureLayer> layer = TextureLayer::CreateForMailbox(cc_client); | 29 scoped_refptr<TextureLayer> layer = TextureLayer::CreateForMailbox(cc_client); |
| 30 layer->SetIsDrawable(true); | 30 layer->SetIsDrawable(true); |
| 31 layer_.reset(new WebLayerImpl(layer)); | 31 layer_.reset(new WebLayerImpl(layer)); |
| 32 } | 32 } |
| 33 | 33 |
| 34 WebExternalTextureLayerImpl::~WebExternalTextureLayerImpl() { | 34 WebExternalTextureLayerImpl::~WebExternalTextureLayerImpl() { |
| 35 static_cast<TextureLayer*>(layer_->layer())->ClearClient(); | 35 static_cast<TextureLayer*>(layer_->layer())->ClearClient(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 blink::WebLayer* WebExternalTextureLayerImpl::layer() { return layer_.get(); } | 38 blink::WebLayer* WebExternalTextureLayerImpl::layer() { |
| 39 return layer_.get(); |
| 40 } |
| 39 | 41 |
| 40 void WebExternalTextureLayerImpl::clearTexture() { | 42 void WebExternalTextureLayerImpl::clearTexture() { |
| 41 TextureLayer *layer = static_cast<TextureLayer*>(layer_->layer()); | 43 TextureLayer* layer = static_cast<TextureLayer*>(layer_->layer()); |
| 42 layer->ClearTexture(); | 44 layer->ClearTexture(); |
| 43 } | 45 } |
| 44 | 46 |
| 45 void WebExternalTextureLayerImpl::setOpaque(bool opaque) { | 47 void WebExternalTextureLayerImpl::setOpaque(bool opaque) { |
| 46 static_cast<TextureLayer*>(layer_->layer())->SetContentsOpaque(opaque); | 48 static_cast<TextureLayer*>(layer_->layer())->SetContentsOpaque(opaque); |
| 47 } | 49 } |
| 48 | 50 |
| 49 void WebExternalTextureLayerImpl::setPremultipliedAlpha( | 51 void WebExternalTextureLayerImpl::setPremultipliedAlpha( |
| 50 bool premultiplied_alpha) { | 52 bool premultiplied_alpha) { |
| 51 static_cast<TextureLayer*>(layer_->layer())->SetPremultipliedAlpha( | 53 static_cast<TextureLayer*>(layer_->layer())->SetPremultipliedAlpha( |
| (...skipping 26 matching lines...) Expand all Loading... |
| 78 name.SetName(client_mailbox.name); | 80 name.SetName(client_mailbox.name); |
| 79 if (bitmap) { | 81 if (bitmap) { |
| 80 *mailbox = cc::TextureMailbox(bitmap->shared_memory(), bitmap->size()); | 82 *mailbox = cc::TextureMailbox(bitmap->shared_memory(), bitmap->size()); |
| 81 } else { | 83 } else { |
| 82 *mailbox = | 84 *mailbox = |
| 83 cc::TextureMailbox(name, GL_TEXTURE_2D, client_mailbox.syncPoint); | 85 cc::TextureMailbox(name, GL_TEXTURE_2D, client_mailbox.syncPoint); |
| 84 } | 86 } |
| 85 mailbox->set_allow_overlay(client_mailbox.allowOverlay); | 87 mailbox->set_allow_overlay(client_mailbox.allowOverlay); |
| 86 | 88 |
| 87 if (mailbox->IsValid()) { | 89 if (mailbox->IsValid()) { |
| 88 *release_callback = cc::SingleReleaseCallback::Create(base::Bind( | 90 *release_callback = cc::SingleReleaseCallback::Create( |
| 89 &WebExternalTextureLayerImpl::DidReleaseMailbox, | 91 base::Bind(&WebExternalTextureLayerImpl::DidReleaseMailbox, |
| 90 this->AsWeakPtr(), | 92 this->AsWeakPtr(), |
| 91 client_mailbox, | 93 client_mailbox, |
| 92 bitmap)); | 94 bitmap)); |
| 93 } | 95 } |
| 94 | 96 |
| 95 return true; | 97 return true; |
| 96 } | 98 } |
| 97 | 99 |
| 98 WebExternalBitmapImpl* WebExternalTextureLayerImpl::AllocateBitmap() { | 100 WebExternalBitmapImpl* WebExternalTextureLayerImpl::AllocateBitmap() { |
| 99 if (!free_bitmaps_.empty()) { | 101 if (!free_bitmaps_.empty()) { |
| 100 WebExternalBitmapImpl* result = free_bitmaps_.back(); | 102 WebExternalBitmapImpl* result = free_bitmaps_.back(); |
| 101 free_bitmaps_.weak_erase(free_bitmaps_.end() - 1); | 103 free_bitmaps_.weak_erase(free_bitmaps_.end() - 1); |
| 102 return result; | 104 return result; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 117 } | 119 } |
| 118 | 120 |
| 119 blink::WebExternalTextureMailbox available_mailbox; | 121 blink::WebExternalTextureMailbox available_mailbox; |
| 120 memcpy(available_mailbox.name, mailbox.name, sizeof(available_mailbox.name)); | 122 memcpy(available_mailbox.name, mailbox.name, sizeof(available_mailbox.name)); |
| 121 available_mailbox.syncPoint = sync_point; | 123 available_mailbox.syncPoint = sync_point; |
| 122 if (bitmap) | 124 if (bitmap) |
| 123 layer->free_bitmaps_.push_back(bitmap); | 125 layer->free_bitmaps_.push_back(bitmap); |
| 124 layer->client_->mailboxReleased(available_mailbox); | 126 layer->client_->mailboxReleased(available_mailbox); |
| 125 } | 127 } |
| 126 | 128 |
| 127 } // namespace webkit | 129 } // namespace content |
| 130 |
| OLD | NEW |