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 "webkit/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 "third_party/WebKit/public/platform/WebExternalTextureLayerClient.h" | 11 #include "third_party/WebKit/public/platform/WebExternalTextureLayerClient.h" |
12 #include "third_party/WebKit/public/platform/WebExternalTextureMailbox.h" | 12 #include "third_party/WebKit/public/platform/WebExternalTextureMailbox.h" |
13 #include "third_party/WebKit/public/platform/WebFloatRect.h" | 13 #include "third_party/WebKit/public/platform/WebFloatRect.h" |
14 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 14 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
15 #include "third_party/WebKit/public/platform/WebSize.h" | 15 #include "third_party/WebKit/public/platform/WebSize.h" |
16 #include "webkit/renderer/compositor_bindings/web_external_bitmap_impl.h" | 16 #include "webkit/renderer/compositor_bindings/web_external_bitmap_impl.h" |
17 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" | 17 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" |
18 | 18 |
19 using cc::TextureLayer; | 19 using cc::TextureLayer; |
20 using cc::ResourceUpdateQueue; | 20 using cc::ResourceUpdateQueue; |
21 | 21 |
22 namespace webkit { | 22 namespace webkit { |
23 | 23 |
24 WebExternalTextureLayerImpl::WebExternalTextureLayerImpl( | 24 WebExternalTextureLayerImpl::WebExternalTextureLayerImpl( |
25 WebKit::WebExternalTextureLayerClient* client) | 25 blink::WebExternalTextureLayerClient* client) |
26 : client_(client) { | 26 : client_(client) { |
27 cc::TextureLayerClient* cc_client = client_ ? this : NULL; | 27 cc::TextureLayerClient* cc_client = client_ ? this : NULL; |
28 scoped_refptr<TextureLayer> layer = TextureLayer::CreateForMailbox(cc_client); | 28 scoped_refptr<TextureLayer> layer = TextureLayer::CreateForMailbox(cc_client); |
29 layer->SetIsDrawable(true); | 29 layer->SetIsDrawable(true); |
30 layer_.reset(new WebLayerImpl(layer)); | 30 layer_.reset(new WebLayerImpl(layer)); |
31 } | 31 } |
32 | 32 |
33 WebExternalTextureLayerImpl::~WebExternalTextureLayerImpl() { | 33 WebExternalTextureLayerImpl::~WebExternalTextureLayerImpl() { |
34 static_cast<TextureLayer*>(layer_->layer())->ClearClient(); | 34 static_cast<TextureLayer*>(layer_->layer())->ClearClient(); |
35 } | 35 } |
36 | 36 |
37 WebKit::WebLayer* WebExternalTextureLayerImpl::layer() { return layer_.get(); } | 37 blink::WebLayer* WebExternalTextureLayerImpl::layer() { return layer_.get(); } |
38 | 38 |
39 void WebExternalTextureLayerImpl::clearTexture() { | 39 void WebExternalTextureLayerImpl::clearTexture() { |
40 TextureLayer *layer = static_cast<TextureLayer*>(layer_->layer()); | 40 TextureLayer *layer = static_cast<TextureLayer*>(layer_->layer()); |
41 layer->WillModifyTexture(); | 41 layer->WillModifyTexture(); |
42 layer->SetTextureMailbox(cc::TextureMailbox(), | 42 layer->SetTextureMailbox(cc::TextureMailbox(), |
43 scoped_ptr<cc::SingleReleaseCallback>()); | 43 scoped_ptr<cc::SingleReleaseCallback>()); |
44 } | 44 } |
45 | 45 |
46 void WebExternalTextureLayerImpl::setOpaque(bool opaque) { | 46 void WebExternalTextureLayerImpl::setOpaque(bool opaque) { |
47 static_cast<TextureLayer*>(layer_->layer())->SetContentsOpaque(opaque); | 47 static_cast<TextureLayer*>(layer_->layer())->SetContentsOpaque(opaque); |
(...skipping 15 matching lines...) Expand all Loading... |
63 | 63 |
64 unsigned WebExternalTextureLayerImpl::PrepareTexture() { | 64 unsigned WebExternalTextureLayerImpl::PrepareTexture() { |
65 NOTREACHED(); | 65 NOTREACHED(); |
66 return 0; | 66 return 0; |
67 } | 67 } |
68 | 68 |
69 bool WebExternalTextureLayerImpl::PrepareTextureMailbox( | 69 bool WebExternalTextureLayerImpl::PrepareTextureMailbox( |
70 cc::TextureMailbox* mailbox, | 70 cc::TextureMailbox* mailbox, |
71 scoped_ptr<cc::SingleReleaseCallback>* release_callback, | 71 scoped_ptr<cc::SingleReleaseCallback>* release_callback, |
72 bool use_shared_memory) { | 72 bool use_shared_memory) { |
73 WebKit::WebExternalTextureMailbox client_mailbox; | 73 blink::WebExternalTextureMailbox client_mailbox; |
74 WebExternalBitmapImpl* bitmap = NULL; | 74 WebExternalBitmapImpl* bitmap = NULL; |
75 | 75 |
76 if (use_shared_memory) | 76 if (use_shared_memory) |
77 bitmap = AllocateBitmap(); | 77 bitmap = AllocateBitmap(); |
78 if (!client_->prepareMailbox(&client_mailbox, bitmap)) { | 78 if (!client_->prepareMailbox(&client_mailbox, bitmap)) { |
79 if (bitmap) | 79 if (bitmap) |
80 free_bitmaps_.push_back(bitmap); | 80 free_bitmaps_.push_back(bitmap); |
81 return false; | 81 return false; |
82 } | 82 } |
83 gpu::Mailbox name; | 83 gpu::Mailbox name; |
(...skipping 19 matching lines...) Expand all Loading... |
103 WebExternalBitmapImpl* result = free_bitmaps_.back(); | 103 WebExternalBitmapImpl* result = free_bitmaps_.back(); |
104 free_bitmaps_.weak_erase(free_bitmaps_.end() - 1); | 104 free_bitmaps_.weak_erase(free_bitmaps_.end() - 1); |
105 return result; | 105 return result; |
106 } | 106 } |
107 return new WebExternalBitmapImpl; | 107 return new WebExternalBitmapImpl; |
108 } | 108 } |
109 | 109 |
110 // static | 110 // static |
111 void WebExternalTextureLayerImpl::DidReleaseMailbox( | 111 void WebExternalTextureLayerImpl::DidReleaseMailbox( |
112 base::WeakPtr<WebExternalTextureLayerImpl> layer, | 112 base::WeakPtr<WebExternalTextureLayerImpl> layer, |
113 const WebKit::WebExternalTextureMailbox& mailbox, | 113 const blink::WebExternalTextureMailbox& mailbox, |
114 WebExternalBitmapImpl* bitmap, | 114 WebExternalBitmapImpl* bitmap, |
115 unsigned sync_point, | 115 unsigned sync_point, |
116 bool lost_resource) { | 116 bool lost_resource) { |
117 if (lost_resource || !layer) { | 117 if (lost_resource || !layer) { |
118 delete bitmap; | 118 delete bitmap; |
119 return; | 119 return; |
120 } | 120 } |
121 | 121 |
122 WebKit::WebExternalTextureMailbox available_mailbox; | 122 blink::WebExternalTextureMailbox available_mailbox; |
123 memcpy(available_mailbox.name, mailbox.name, sizeof(available_mailbox.name)); | 123 memcpy(available_mailbox.name, mailbox.name, sizeof(available_mailbox.name)); |
124 available_mailbox.syncPoint = sync_point; | 124 available_mailbox.syncPoint = sync_point; |
125 if (bitmap) | 125 if (bitmap) |
126 layer->free_bitmaps_.push_back(bitmap); | 126 layer->free_bitmaps_.push_back(bitmap); |
127 layer->client_->mailboxReleased(available_mailbox); | 127 layer->client_->mailboxReleased(available_mailbox); |
128 } | 128 } |
129 | 129 |
130 } // namespace webkit | 130 } // namespace webkit |
OLD | NEW |