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

Side by Side Diff: cc/resource_provider.cc

Issue 11638028: Mailbox support for texture layers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments Created 7 years, 11 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "cc/resource_provider.h" 5 #include "cc/resource_provider.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 8
9 #include "base/debug/alias.h" 9 #include "base/debug/alias.h"
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL _CLAMP_TO_EDGE)); 227 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL _CLAMP_TO_EDGE));
228 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL _CLAMP_TO_EDGE)); 228 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL _CLAMP_TO_EDGE));
229 229
230 ResourceId id = m_nextId++; 230 ResourceId id = m_nextId++;
231 Resource resource(textureId, gfx::Size(), 0, GL_LINEAR); 231 Resource resource(textureId, gfx::Size(), 0, GL_LINEAR);
232 resource.external = true; 232 resource.external = true;
233 m_resources[id] = resource; 233 m_resources[id] = resource;
234 return id; 234 return id;
235 } 235 }
236 236
237 ResourceProvider::ResourceId ResourceProvider::createResourceFromTextureMailbox( const std::string& mailbox, const base::Callback<void(unsigned)>& releaseCallbac k)
238 {
239 DCHECK(m_threadChecker.CalledOnValidThread());
240
241 const int8* name = reinterpret_cast<const int8*>(mailbox.data());
242 WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
243 DCHECK(context3d);
244 unsigned textureId = context3d->createTexture();
245 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId));
246 GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, name));
247 context3d->flush();
jamesr 2013/01/04 21:38:31 I'd still like to understand what the meaning of t
248
249 ResourceId id = m_nextId++;
250 Resource resource(textureId, gfx::Size(), 0, GL_LINEAR);
251 resource.external = true;
252 resource.mailbox.setName(name);
253 resource.mailbox.releaseCallback = releaseCallback;
254 m_resources[id] = resource;
255 return id;
256 }
257
237 void ResourceProvider::deleteResource(ResourceId id) 258 void ResourceProvider::deleteResource(ResourceId id)
238 { 259 {
239 DCHECK(m_threadChecker.CalledOnValidThread()); 260 DCHECK(m_threadChecker.CalledOnValidThread());
240 ResourceMap::iterator it = m_resources.find(id); 261 ResourceMap::iterator it = m_resources.find(id);
241 CHECK(it != m_resources.end()); 262 CHECK(it != m_resources.end());
242 Resource* resource = &it->second; 263 Resource* resource = &it->second;
243 DCHECK(!resource->lockedForWrite); 264 DCHECK(!resource->lockedForWrite);
244 DCHECK(!resource->lockForReadCount); 265 DCHECK(!resource->lockForReadCount);
245 DCHECK(!resource->markedForDeletion); 266 DCHECK(!resource->markedForDeletion);
246 267
(...skipping 15 matching lines...) Expand all
262 if (resource->glUploadQueryId) { 283 if (resource->glUploadQueryId) {
263 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 284 WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
264 DCHECK(context3d); 285 DCHECK(context3d);
265 GLC(context3d, context3d->deleteQueryEXT(resource->glUploadQueryId)); 286 GLC(context3d, context3d->deleteQueryEXT(resource->glUploadQueryId));
266 } 287 }
267 if (resource->glPixelBufferId) { 288 if (resource->glPixelBufferId) {
268 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 289 WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
269 DCHECK(context3d); 290 DCHECK(context3d);
270 GLC(context3d, context3d->deleteBuffer(resource->glPixelBufferId)); 291 GLC(context3d, context3d->deleteBuffer(resource->glPixelBufferId));
271 } 292 }
293 if (!resource->mailbox.isZero() && resource->external) {
294 WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
295 DCHECK(context3d);
296 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId));
297 GLC(context3d, context3d->produceTextureCHROMIUM(GL_TEXTURE_2D, resource ->mailbox.name));
298 GLC(context3d, context3d->deleteTexture(resource->glId));
299 if (!resource->mailbox.releaseCallback.is_null()) {
300 unsigned syncPoint = context3d->insertSyncPoint();
301 resource->mailbox.releaseCallback.Run(syncPoint);
302 }
303 }
272 if (resource->pixels) 304 if (resource->pixels)
273 delete[] resource->pixels; 305 delete[] resource->pixels;
274 if (resource->pixelBuffer) 306 if (resource->pixelBuffer)
275 delete[] resource->pixelBuffer; 307 delete[] resource->pixelBuffer;
276 308
277 m_resources.erase(it); 309 m_resources.erase(it);
278 } 310 }
279 311
280 ResourceProvider::ResourceType ResourceProvider::resourceType(ResourceId id) 312 ResourceProvider::ResourceType ResourceProvider::resourceType(ResourceId id)
281 { 313 {
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 return false; 981 return false;
950 } 982 }
951 983
952 resource->pendingSetPixels = false; 984 resource->pendingSetPixels = false;
953 unlockForWrite(id); 985 unlockForWrite(id);
954 986
955 return true; 987 return true;
956 } 988 }
957 989
958 } // namespace cc 990 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resource_provider.h ('k') | cc/texture_layer.h » ('j') | cc/texture_layer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698