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

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: Tests 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;
245 GLC(context3d, textureId = context3d->createTexture());
jamesr 2013/01/03 23:40:14 just do the assignment textureID = context3D->crea
alexst (slow to review) 2013/01/04 16:20:48 Copy-pasted code from above, I'll clean up. On 20
246 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId));
247 GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, name));
248 GLC(context3d, context3d->flush());
jamesr 2013/01/03 23:40:14 similarly no reason to glGetError after a flush -
alexst (slow to review) 2013/01/04 16:20:48 Backing texture for the mailbox is in a different
249
250 ResourceId id = m_nextId++;
251 Resource resource(textureId, gfx::Size(), 0, GL_LINEAR);
252 resource.external = true;
253 resource.mailbox.setName(name);
254 resource.mailbox.releaseCallback = releaseCallback;
255 m_resources[id] = resource;
256 return id;
257 }
258
237 void ResourceProvider::deleteResource(ResourceId id) 259 void ResourceProvider::deleteResource(ResourceId id)
238 { 260 {
239 DCHECK(m_threadChecker.CalledOnValidThread()); 261 DCHECK(m_threadChecker.CalledOnValidThread());
240 ResourceMap::iterator it = m_resources.find(id); 262 ResourceMap::iterator it = m_resources.find(id);
241 CHECK(it != m_resources.end()); 263 CHECK(it != m_resources.end());
242 Resource* resource = &it->second; 264 Resource* resource = &it->second;
243 DCHECK(!resource->lockedForWrite); 265 DCHECK(!resource->lockedForWrite);
244 DCHECK(!resource->lockForReadCount); 266 DCHECK(!resource->lockForReadCount);
245 DCHECK(!resource->markedForDeletion); 267 DCHECK(!resource->markedForDeletion);
246 268
(...skipping 15 matching lines...) Expand all
262 if (resource->glUploadQueryId) { 284 if (resource->glUploadQueryId) {
263 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 285 WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
264 DCHECK(context3d); 286 DCHECK(context3d);
265 GLC(context3d, context3d->deleteQueryEXT(resource->glUploadQueryId)); 287 GLC(context3d, context3d->deleteQueryEXT(resource->glUploadQueryId));
266 } 288 }
267 if (resource->glPixelBufferId) { 289 if (resource->glPixelBufferId) {
268 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 290 WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
269 DCHECK(context3d); 291 DCHECK(context3d);
270 GLC(context3d, context3d->deleteBuffer(resource->glPixelBufferId)); 292 GLC(context3d, context3d->deleteBuffer(resource->glPixelBufferId));
271 } 293 }
294 if (!resource->mailbox.isZero() && resource->external) {
295 WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
296 DCHECK(context3d);
297 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId));
298 GLC(context3d, context3d->produceTextureCHROMIUM(GL_TEXTURE_2D, resource ->mailbox.name));
299 GLC(context3d, context3d->deleteTexture(resource->glId));
300 if (!resource->mailbox.releaseCallback.is_null()) {
301 unsigned syncPoint = 0;
302 GLC(context3d, syncPoint = context3d->insertSyncPoint());
303 resource->mailbox.releaseCallback.Run(syncPoint);
304 }
305 }
272 if (resource->pixels) 306 if (resource->pixels)
273 delete[] resource->pixels; 307 delete[] resource->pixels;
274 if (resource->pixelBuffer) 308 if (resource->pixelBuffer)
275 delete[] resource->pixelBuffer; 309 delete[] resource->pixelBuffer;
276 310
277 m_resources.erase(it); 311 m_resources.erase(it);
278 } 312 }
279 313
280 ResourceProvider::ResourceType ResourceProvider::resourceType(ResourceId id) 314 ResourceProvider::ResourceType ResourceProvider::resourceType(ResourceId id)
281 { 315 {
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 return false; 983 return false;
950 } 984 }
951 985
952 resource->pendingSetPixels = false; 986 resource->pendingSetPixels = false;
953 unlockForWrite(id); 987 unlockForWrite(id);
954 988
955 return true; 989 return true;
956 } 990 }
957 991
958 } // namespace cc 992 } // 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