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

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
« no previous file with comments | « webkit/renderer/compositor_bindings/web_external_texture_layer_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)) {
121 if (bitmap)
122 free_bitmaps_.push_back(bitmap);
115 return false; 123 return false;
116 } 124 }
117 gpu::Mailbox name; 125 gpu::Mailbox name;
118 name.SetName(client_mailbox.name); 126 name.SetName(client_mailbox.name);
119 cc::TextureMailbox::ReleaseCallback callback = 127 cc::TextureMailbox::ReleaseCallback callback =
120 base::Bind(&WebExternalTextureLayerImpl::DidReleaseMailbox, 128 base::Bind(&WebExternalTextureLayerImpl::DidReleaseMailbox,
121 this->AsWeakPtr(), 129 this->AsWeakPtr(),
122 client_mailbox); 130 client_mailbox,
123 *mailbox = cc::TextureMailbox(name, callback, client_mailbox.syncPoint); 131 bitmap);
132 if (bitmap) {
133 *mailbox =
134 cc::TextureMailbox(bitmap->shared_memory(), bitmap->size(), callback);
135 } else {
136 *mailbox = cc::TextureMailbox(name, callback, client_mailbox.syncPoint);
137 }
124 return true; 138 return true;
125 } 139 }
126 140
141 WebExternalBitmapImpl* WebExternalTextureLayerImpl::AllocateBitmap() {
142 if (!free_bitmaps_.empty()) {
143 WebExternalBitmapImpl* result = free_bitmaps_.back();
144 free_bitmaps_.weak_erase(free_bitmaps_.end() - 1);
145 return result;
146 }
147 return new WebExternalBitmapImpl;
148 }
149
150 // static
127 void WebExternalTextureLayerImpl::DidReleaseMailbox( 151 void WebExternalTextureLayerImpl::DidReleaseMailbox(
152 base::WeakPtr<WebExternalTextureLayerImpl> layer,
128 const WebKit::WebExternalTextureMailbox& mailbox, 153 const WebKit::WebExternalTextureMailbox& mailbox,
154 WebExternalBitmapImpl* bitmap,
129 unsigned sync_point, 155 unsigned sync_point,
130 bool lost_resource) { 156 bool lost_resource) {
131 if (lost_resource) 157 if (lost_resource || !layer) {
158 delete bitmap;
132 return; 159 return;
160 }
133 161
134 WebKit::WebExternalTextureMailbox available_mailbox; 162 WebKit::WebExternalTextureMailbox available_mailbox;
135 memcpy(available_mailbox.name, mailbox.name, sizeof(available_mailbox.name)); 163 memcpy(available_mailbox.name, mailbox.name, sizeof(available_mailbox.name));
136 available_mailbox.syncPoint = sync_point; 164 available_mailbox.syncPoint = sync_point;
137 client_->mailboxReleased(available_mailbox); 165 if (bitmap)
166 layer->free_bitmaps_.push_back(bitmap);
167 layer->client_->mailboxReleased(available_mailbox);
138 } 168 }
139 169
140 } // namespace webkit 170 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/renderer/compositor_bindings/web_external_texture_layer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698