Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(516)

Side by Side Diff: webkit/renderer/compositor_bindings/web_external_texture_layer_impl.cc

Issue 17859002: Allow WebExternalTextureLayers to receive a bitmap along with a mailbox (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "third_party/WebKit/public/platform/WebExternalTextureLayerClient.h" 9 #include "third_party/WebKit/public/platform/WebExternalTextureLayerClient.h"
10 #include "third_party/WebKit/public/platform/WebExternalTextureMailbox.h" 10 #include "third_party/WebKit/public/platform/WebExternalTextureMailbox.h"
11 #include "third_party/WebKit/public/platform/WebFloatRect.h" 11 #include "third_party/WebKit/public/platform/WebFloatRect.h"
12 #include "third_party/WebKit/public/platform/WebSize.h" 12 #include "third_party/WebKit/public/platform/WebSize.h"
13 #include "webkit/renderer/compositor_bindings/web_external_bitmap_impl.h"
13 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" 14 #include "webkit/renderer/compositor_bindings/web_layer_impl.h"
14 15
15 using cc::TextureLayer; 16 using cc::TextureLayer;
16 using cc::ResourceUpdateQueue; 17 using cc::ResourceUpdateQueue;
17 18
18 namespace webkit { 19 namespace webkit {
19 20
20 WebExternalTextureLayerImpl::WebExternalTextureLayerImpl( 21 WebExternalTextureLayerImpl::WebExternalTextureLayerImpl(
21 WebKit::WebExternalTextureLayerClient* client, 22 WebKit::WebExternalTextureLayerClient* client,
22 bool mailbox) 23 bool mailbox)
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 WebTextureUpdaterImpl updater_impl(queue); 103 WebTextureUpdaterImpl updater_impl(queue);
103 return client_->prepareTexture(updater_impl); 104 return client_->prepareTexture(updater_impl);
104 } 105 }
105 106
106 WebKit::WebGraphicsContext3D* WebExternalTextureLayerImpl::Context3d() { 107 WebKit::WebGraphicsContext3D* WebExternalTextureLayerImpl::Context3d() {
107 DCHECK(client_); 108 DCHECK(client_);
108 return client_->context(); 109 return client_->context();
109 } 110 }
110 111
111 bool WebExternalTextureLayerImpl::PrepareTextureMailbox( 112 bool WebExternalTextureLayerImpl::PrepareTextureMailbox(
112 cc::TextureMailbox* mailbox) { 113 cc::TextureMailbox* mailbox,
114 bool use_shared_memory) {
113 WebKit::WebExternalTextureMailbox client_mailbox; 115 WebKit::WebExternalTextureMailbox client_mailbox;
114 if (!client_->prepareMailbox(&client_mailbox)) { 116 WebExternalBitmapImpl* bitmap = NULL;
117
118 if (use_shared_memory)
119 bitmap = AllocateBitmap();
120 if (!client_->prepareMailbox(&client_mailbox, bitmap)) {
115 return false; 121 return false;
116 } 122 }
117 gpu::Mailbox name; 123 gpu::Mailbox name;
118 name.SetName(client_mailbox.name); 124 name.SetName(client_mailbox.name);
119 cc::TextureMailbox::ReleaseCallback callback = 125 cc::TextureMailbox::ReleaseCallback callback =
120 base::Bind(&WebExternalTextureLayerImpl::DidReleaseMailbox, 126 base::Bind(&WebExternalTextureLayerImpl::DidReleaseMailbox,
121 this->AsWeakPtr(), 127 this->AsWeakPtr(),
122 client_mailbox); 128 client_mailbox,
123 *mailbox = cc::TextureMailbox(name, callback, client_mailbox.syncPoint); 129 bitmap);
130 if (bitmap) {
131 *mailbox = cc::TextureMailbox(
132 bitmap->getSharedMemory(), bitmap->getSize(), callback);
133 } else {
134 *mailbox = cc::TextureMailbox(name, callback, client_mailbox.syncPoint);
135 }
124 return true; 136 return true;
125 } 137 }
126 138
139 WebExternalBitmapImpl* WebExternalTextureLayerImpl::AllocateBitmap() {
140 if (!free_bitmaps_.empty()) {
141 WebExternalBitmapImpl* result = free_bitmaps_.back();
142 free_bitmaps_.weak_erase(free_bitmaps_.end() - 1);
143 return result;
144 }
145 return new WebExternalBitmapImpl;
146 }
147
148 // static
127 void WebExternalTextureLayerImpl::DidReleaseMailbox( 149 void WebExternalTextureLayerImpl::DidReleaseMailbox(
150 base::WeakPtr<WebExternalTextureLayerImpl> layer,
128 const WebKit::WebExternalTextureMailbox& mailbox, 151 const WebKit::WebExternalTextureMailbox& mailbox,
152 WebExternalBitmapImpl* bitmap,
129 unsigned sync_point, 153 unsigned sync_point,
130 bool lost_resource) { 154 bool lost_resource) {
131 if (lost_resource) 155 if (lost_resource || !layer) {
156 delete bitmap;
132 return; 157 return;
158 }
133 159
134 WebKit::WebExternalTextureMailbox available_mailbox; 160 WebKit::WebExternalTextureMailbox available_mailbox;
135 memcpy(available_mailbox.name, mailbox.name, sizeof(available_mailbox.name)); 161 memcpy(available_mailbox.name, mailbox.name, sizeof(available_mailbox.name));
136 available_mailbox.syncPoint = sync_point; 162 available_mailbox.syncPoint = sync_point;
137 client_->mailboxReleased(available_mailbox); 163 if (bitmap)
164 layer->free_bitmaps_.push_back(bitmap);
165 layer->client_->mailboxReleased(available_mailbox);
138 } 166 }
139 167
140 } // namespace webkit 168 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698