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

Side by Side Diff: cc/resource_provider.cc

Issue 12041062: Have a common implementation of cc::OutputSurface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 10 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 | « cc/output_surface.cc ('k') | cc/resource_provider_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 scoped_ptr<ResourceProvider> ResourceProvider::create(OutputSurface* context) 141 scoped_ptr<ResourceProvider> ResourceProvider::create(OutputSurface* context)
142 { 142 {
143 scoped_ptr<ResourceProvider> resourceProvider(new ResourceProvider(context)) ; 143 scoped_ptr<ResourceProvider> resourceProvider(new ResourceProvider(context)) ;
144 if (!resourceProvider->initialize()) 144 if (!resourceProvider->initialize())
145 return scoped_ptr<ResourceProvider>(); 145 return scoped_ptr<ResourceProvider>();
146 return resourceProvider.Pass(); 146 return resourceProvider.Pass();
147 } 147 }
148 148
149 ResourceProvider::~ResourceProvider() 149 ResourceProvider::~ResourceProvider()
150 { 150 {
151 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 151 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
152 if (!context3d || !context3d->makeContextCurrent()) 152 if (!context3d || !context3d->makeContextCurrent())
153 return; 153 return;
154 m_textureUploader.reset(); 154 m_textureUploader.reset();
155 m_textureCopier.reset(); 155 m_textureCopier.reset();
156 } 156 }
157 157
158 WebGraphicsContext3D* ResourceProvider::graphicsContext3D() 158 WebGraphicsContext3D* ResourceProvider::graphicsContext3D()
159 { 159 {
160 DCHECK(m_threadChecker.CalledOnValidThread()); 160 DCHECK(m_threadChecker.CalledOnValidThread());
161 return m_outputSurface->Context3D(); 161 return m_outputSurface->context3d();
162 } 162 }
163 163
164 bool ResourceProvider::inUseByConsumer(ResourceId id) 164 bool ResourceProvider::inUseByConsumer(ResourceId id)
165 { 165 {
166 DCHECK(m_threadChecker.CalledOnValidThread()); 166 DCHECK(m_threadChecker.CalledOnValidThread());
167 ResourceMap::iterator it = m_resources.find(id); 167 ResourceMap::iterator it = m_resources.find(id);
168 CHECK(it != m_resources.end()); 168 CHECK(it != m_resources.end());
169 Resource* resource = &it->second; 169 Resource* resource = &it->second;
170 return !!resource->lockForReadCount || resource->exported; 170 return !!resource->lockForReadCount || resource->exported;
171 } 171 }
(...skipping 25 matching lines...) Expand all
197 LOG(FATAL) << "Invalid default resource type."; 197 LOG(FATAL) << "Invalid default resource type.";
198 return 0; 198 return 0;
199 } 199 }
200 200
201 ResourceProvider::ResourceId ResourceProvider::createGLTexture(const gfx::Size& size, GLenum format, GLenum texturePool, TextureUsageHint hint) 201 ResourceProvider::ResourceId ResourceProvider::createGLTexture(const gfx::Size& size, GLenum format, GLenum texturePool, TextureUsageHint hint)
202 { 202 {
203 DCHECK_LE(size.width(), m_maxTextureSize); 203 DCHECK_LE(size.width(), m_maxTextureSize);
204 DCHECK_LE(size.height(), m_maxTextureSize); 204 DCHECK_LE(size.height(), m_maxTextureSize);
205 205
206 DCHECK(m_threadChecker.CalledOnValidThread()); 206 DCHECK(m_threadChecker.CalledOnValidThread());
207 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 207 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
208 DCHECK(context3d); 208 DCHECK(context3d);
209 209
210 // Create and set texture properties. Allocation is delayed until needed. 210 // Create and set texture properties. Allocation is delayed until needed.
211 unsigned textureId = createTextureId(context3d); 211 unsigned textureId = createTextureId(context3d);
212 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_POOL_CHROM IUM, texturePool)); 212 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_POOL_CHROM IUM, texturePool));
213 if (m_useTextureUsageHint && hint == TextureUsageFramebuffer) 213 if (m_useTextureUsageHint && hint == TextureUsageFramebuffer)
214 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_USAGE_ ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE)); 214 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_USAGE_ ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE));
215 215
216 ResourceId id = m_nextId++; 216 ResourceId id = m_nextId++;
217 Resource resource(textureId, size, format, GL_LINEAR); 217 Resource resource(textureId, size, format, GL_LINEAR);
(...skipping 12 matching lines...) Expand all
230 Resource resource(pixels, size, GL_RGBA, GL_LINEAR); 230 Resource resource(pixels, size, GL_RGBA, GL_LINEAR);
231 resource.allocated = true; 231 resource.allocated = true;
232 m_resources[id] = resource; 232 m_resources[id] = resource;
233 return id; 233 return id;
234 } 234 }
235 235
236 ResourceProvider::ResourceId ResourceProvider::createResourceFromExternalTexture (unsigned textureId) 236 ResourceProvider::ResourceId ResourceProvider::createResourceFromExternalTexture (unsigned textureId)
237 { 237 {
238 DCHECK(m_threadChecker.CalledOnValidThread()); 238 DCHECK(m_threadChecker.CalledOnValidThread());
239 239
240 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 240 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
241 DCHECK(context3d); 241 DCHECK(context3d);
242 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId)); 242 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId));
243 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER , GL_LINEAR)); 243 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER , GL_LINEAR));
244 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER , GL_LINEAR)); 244 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER , GL_LINEAR));
245 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL _CLAMP_TO_EDGE)); 245 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL _CLAMP_TO_EDGE));
246 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL _CLAMP_TO_EDGE)); 246 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL _CLAMP_TO_EDGE));
247 247
248 ResourceId id = m_nextId++; 248 ResourceId id = m_nextId++;
249 Resource resource(textureId, gfx::Size(), 0, GL_LINEAR); 249 Resource resource(textureId, gfx::Size(), 0, GL_LINEAR);
250 resource.external = true; 250 resource.external = true;
(...skipping 30 matching lines...) Expand all
281 resource->markedForDeletion = true; 281 resource->markedForDeletion = true;
282 return; 282 return;
283 } else 283 } else
284 deleteResourceInternal(it); 284 deleteResourceInternal(it);
285 } 285 }
286 286
287 void ResourceProvider::deleteResourceInternal(ResourceMap::iterator it) 287 void ResourceProvider::deleteResourceInternal(ResourceMap::iterator it)
288 { 288 {
289 Resource* resource = &it->second; 289 Resource* resource = &it->second;
290 if (resource->glId && !resource->external) { 290 if (resource->glId && !resource->external) {
291 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 291 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
292 DCHECK(context3d); 292 DCHECK(context3d);
293 GLC(context3d, context3d->deleteTexture(resource->glId)); 293 GLC(context3d, context3d->deleteTexture(resource->glId));
294 } 294 }
295 if (resource->glUploadQueryId) { 295 if (resource->glUploadQueryId) {
296 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 296 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
297 DCHECK(context3d); 297 DCHECK(context3d);
298 GLC(context3d, context3d->deleteQueryEXT(resource->glUploadQueryId)); 298 GLC(context3d, context3d->deleteQueryEXT(resource->glUploadQueryId));
299 } 299 }
300 if (resource->glPixelBufferId) { 300 if (resource->glPixelBufferId) {
301 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 301 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
302 DCHECK(context3d); 302 DCHECK(context3d);
303 GLC(context3d, context3d->deleteBuffer(resource->glPixelBufferId)); 303 GLC(context3d, context3d->deleteBuffer(resource->glPixelBufferId));
304 } 304 }
305 if (!resource->mailbox.IsEmpty() && resource->external) { 305 if (!resource->mailbox.IsEmpty() && resource->external) {
306 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 306 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
307 DCHECK(context3d); 307 DCHECK(context3d);
308 unsigned syncPoint = resource->mailbox.sync_point(); 308 unsigned syncPoint = resource->mailbox.sync_point();
309 if (resource->glId) { 309 if (resource->glId) {
310 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId) ); 310 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId) );
311 GLC(context3d, context3d->produceTextureCHROMIUM(GL_TEXTURE_2D, reso urce->mailbox.data())); 311 GLC(context3d, context3d->produceTextureCHROMIUM(GL_TEXTURE_2D, reso urce->mailbox.data()));
312 GLC(context3d, context3d->deleteTexture(resource->glId)); 312 GLC(context3d, context3d->deleteTexture(resource->glId));
313 syncPoint = context3d->insertSyncPoint(); 313 syncPoint = context3d->insertSyncPoint();
314 } 314 }
315 resource->mailbox.RunReleaseCallback(syncPoint); 315 resource->mailbox.RunReleaseCallback(syncPoint);
316 } 316 }
(...skipping 21 matching lines...) Expand all
338 Resource* resource = &it->second; 338 Resource* resource = &it->second;
339 DCHECK(!resource->lockedForWrite); 339 DCHECK(!resource->lockedForWrite);
340 DCHECK(!resource->lockForReadCount); 340 DCHECK(!resource->lockForReadCount);
341 DCHECK(!resource->external); 341 DCHECK(!resource->external);
342 DCHECK(!resource->exported); 342 DCHECK(!resource->exported);
343 DCHECK(readLockFenceHasPassed(resource)); 343 DCHECK(readLockFenceHasPassed(resource));
344 lazyAllocate(resource); 344 lazyAllocate(resource);
345 345
346 if (resource->glId) { 346 if (resource->glId) {
347 DCHECK(!resource->pendingSetPixels); 347 DCHECK(!resource->pendingSetPixels);
348 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 348 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
349 DCHECK(context3d); 349 DCHECK(context3d);
350 DCHECK(m_textureUploader.get()); 350 DCHECK(m_textureUploader.get());
351 context3d->bindTexture(GL_TEXTURE_2D, resource->glId); 351 context3d->bindTexture(GL_TEXTURE_2D, resource->glId);
352 m_textureUploader->upload(image, 352 m_textureUploader->upload(image,
353 imageRect, 353 imageRect,
354 sourceRect, 354 sourceRect,
355 destOffset, 355 destOffset,
356 resource->format, 356 resource->format,
357 resource->size); 357 resource->size);
358 } 358 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 { 402 {
403 if (!m_textureUploader) 403 if (!m_textureUploader)
404 return; 404 return;
405 405
406 m_textureUploader->flush(); 406 m_textureUploader->flush();
407 } 407 }
408 408
409 void ResourceProvider::flush() 409 void ResourceProvider::flush()
410 { 410 {
411 DCHECK(m_threadChecker.CalledOnValidThread()); 411 DCHECK(m_threadChecker.CalledOnValidThread());
412 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 412 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
413 if (context3d) 413 if (context3d)
414 context3d->flush(); 414 context3d->flush();
415 } 415 }
416 416
417 bool ResourceProvider::shallowFlushIfSupported() 417 bool ResourceProvider::shallowFlushIfSupported()
418 { 418 {
419 DCHECK(m_threadChecker.CalledOnValidThread()); 419 DCHECK(m_threadChecker.CalledOnValidThread());
420 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 420 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
421 if (!context3d || !m_useShallowFlush) 421 if (!context3d || !m_useShallowFlush)
422 return false; 422 return false;
423 423
424 context3d->shallowFlushCHROMIUM(); 424 context3d->shallowFlushCHROMIUM();
425 return true; 425 return true;
426 } 426 }
427 427
428 const ResourceProvider::Resource* ResourceProvider::lockForRead(ResourceId id) 428 const ResourceProvider::Resource* ResourceProvider::lockForRead(ResourceId id)
429 { 429 {
430 DCHECK(m_threadChecker.CalledOnValidThread()); 430 DCHECK(m_threadChecker.CalledOnValidThread());
431 ResourceMap::iterator it = m_resources.find(id); 431 ResourceMap::iterator it = m_resources.find(id);
432 CHECK(it != m_resources.end()); 432 CHECK(it != m_resources.end());
433 Resource* resource = &it->second; 433 Resource* resource = &it->second;
434 DCHECK(!resource->lockedForWrite); 434 DCHECK(!resource->lockedForWrite);
435 DCHECK(!resource->exported); 435 DCHECK(!resource->exported);
436 DCHECK(resource->allocated); // Uninitialized! Call setPixels or lockForWrit e first. 436 DCHECK(resource->allocated); // Uninitialized! Call setPixels or lockForWrit e first.
437 437
438 if (!resource->glId && resource->external && !resource->mailbox.IsEmpty()) { 438 if (!resource->glId && resource->external && !resource->mailbox.IsEmpty()) {
439 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 439 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
440 DCHECK(context3d); 440 DCHECK(context3d);
441 if (resource->mailbox.sync_point()) { 441 if (resource->mailbox.sync_point()) {
442 GLC(context3d, context3d->waitSyncPoint(resource->mailbox.sync_point ())); 442 GLC(context3d, context3d->waitSyncPoint(resource->mailbox.sync_point ()));
443 resource->mailbox.ResetSyncPoint(); 443 resource->mailbox.ResetSyncPoint();
444 } 444 }
445 resource->glId = context3d->createTexture(); 445 resource->glId = context3d->createTexture();
446 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId)); 446 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId));
447 GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, resource ->mailbox.data())); 447 GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, resource ->mailbox.data()));
448 } 448 }
449 449
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 , m_useTextureUsageHint(false) 581 , m_useTextureUsageHint(false)
582 , m_useShallowFlush(false) 582 , m_useShallowFlush(false)
583 , m_maxTextureSize(0) 583 , m_maxTextureSize(0)
584 , m_bestTextureFormat(0) 584 , m_bestTextureFormat(0)
585 { 585 {
586 } 586 }
587 587
588 bool ResourceProvider::initialize() 588 bool ResourceProvider::initialize()
589 { 589 {
590 DCHECK(m_threadChecker.CalledOnValidThread()); 590 DCHECK(m_threadChecker.CalledOnValidThread());
591 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 591 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
592 if (!context3d) { 592 if (!context3d) {
593 m_maxTextureSize = INT_MAX / 2; 593 m_maxTextureSize = INT_MAX / 2;
594 m_bestTextureFormat = GL_RGBA; 594 m_bestTextureFormat = GL_RGBA;
595 return true; 595 return true;
596 } 596 }
597 if (!context3d->makeContextCurrent()) 597 if (!context3d->makeContextCurrent())
598 return false; 598 return false;
599 599
600 std::string extensionsString = UTF16ToASCII(context3d->getString(GL_EXTENSIO NS)); 600 std::string extensionsString = UTF16ToASCII(context3d->getString(GL_EXTENSIO NS));
601 std::vector<std::string> extensions; 601 std::vector<std::string> extensions;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 ChildMap::const_iterator it = m_children.find(child); 652 ChildMap::const_iterator it = m_children.find(child);
653 DCHECK(it != m_children.end()); 653 DCHECK(it != m_children.end());
654 return it->second.childToParentMap; 654 return it->second.childToParentMap;
655 } 655 }
656 656
657 void ResourceProvider::prepareSendToParent(const ResourceIdArray& resources, Tra nsferableResourceList* list) 657 void ResourceProvider::prepareSendToParent(const ResourceIdArray& resources, Tra nsferableResourceList* list)
658 { 658 {
659 DCHECK(m_threadChecker.CalledOnValidThread()); 659 DCHECK(m_threadChecker.CalledOnValidThread());
660 list->sync_point = 0; 660 list->sync_point = 0;
661 list->resources.clear(); 661 list->resources.clear();
662 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 662 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
663 if (!context3d || !context3d->makeContextCurrent()) { 663 if (!context3d || !context3d->makeContextCurrent()) {
664 // FIXME: Implement this path for software compositing. 664 // FIXME: Implement this path for software compositing.
665 return; 665 return;
666 } 666 }
667 for (ResourceIdArray::const_iterator it = resources.begin(); it != resources .end(); ++it) { 667 for (ResourceIdArray::const_iterator it = resources.begin(); it != resources .end(); ++it) {
668 TransferableResource resource; 668 TransferableResource resource;
669 if (transferResource(context3d, *it, &resource)) { 669 if (transferResource(context3d, *it, &resource)) {
670 m_resources.find(*it)->second.exported = true; 670 m_resources.find(*it)->second.exported = true;
671 list->resources.push_back(resource); 671 list->resources.push_back(resource);
672 } 672 }
673 } 673 }
674 if (list->resources.size()) 674 if (list->resources.size())
675 list->sync_point = context3d->insertSyncPoint(); 675 list->sync_point = context3d->insertSyncPoint();
676 } 676 }
677 677
678 void ResourceProvider::prepareSendToChild(int child, const ResourceIdArray& reso urces, TransferableResourceList* list) 678 void ResourceProvider::prepareSendToChild(int child, const ResourceIdArray& reso urces, TransferableResourceList* list)
679 { 679 {
680 DCHECK(m_threadChecker.CalledOnValidThread()); 680 DCHECK(m_threadChecker.CalledOnValidThread());
681 list->sync_point = 0; 681 list->sync_point = 0;
682 list->resources.clear(); 682 list->resources.clear();
683 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 683 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
684 if (!context3d || !context3d->makeContextCurrent()) { 684 if (!context3d || !context3d->makeContextCurrent()) {
685 // FIXME: Implement this path for software compositing. 685 // FIXME: Implement this path for software compositing.
686 return; 686 return;
687 } 687 }
688 Child& childInfo = m_children.find(child)->second; 688 Child& childInfo = m_children.find(child)->second;
689 for (ResourceIdArray::const_iterator it = resources.begin(); it != resources .end(); ++it) { 689 for (ResourceIdArray::const_iterator it = resources.begin(); it != resources .end(); ++it) {
690 TransferableResource resource; 690 TransferableResource resource;
691 if (!transferResource(context3d, *it, &resource)) 691 if (!transferResource(context3d, *it, &resource))
692 NOTREACHED(); 692 NOTREACHED();
693 DCHECK(childInfo.parentToChildMap.find(*it) != childInfo.parentToChildMa p.end()); 693 DCHECK(childInfo.parentToChildMap.find(*it) != childInfo.parentToChildMa p.end());
694 resource.id = childInfo.parentToChildMap[*it]; 694 resource.id = childInfo.parentToChildMap[*it];
695 childInfo.parentToChildMap.erase(*it); 695 childInfo.parentToChildMap.erase(*it);
696 childInfo.childToParentMap.erase(resource.id); 696 childInfo.childToParentMap.erase(resource.id);
697 list->resources.push_back(resource); 697 list->resources.push_back(resource);
698 deleteResource(*it); 698 deleteResource(*it);
699 } 699 }
700 if (list->resources.size()) 700 if (list->resources.size())
701 list->sync_point = context3d->insertSyncPoint(); 701 list->sync_point = context3d->insertSyncPoint();
702 } 702 }
703 703
704 void ResourceProvider::receiveFromChild(int child, const TransferableResourceLis t& resources) 704 void ResourceProvider::receiveFromChild(int child, const TransferableResourceLis t& resources)
705 { 705 {
706 DCHECK(m_threadChecker.CalledOnValidThread()); 706 DCHECK(m_threadChecker.CalledOnValidThread());
707 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 707 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
708 if (!context3d || !context3d->makeContextCurrent()) { 708 if (!context3d || !context3d->makeContextCurrent()) {
709 // FIXME: Implement this path for software compositing. 709 // FIXME: Implement this path for software compositing.
710 return; 710 return;
711 } 711 }
712 if (resources.sync_point) { 712 if (resources.sync_point) {
713 // NOTE: If the parent is a browser and the child a renderer, the parent 713 // NOTE: If the parent is a browser and the child a renderer, the parent
714 // is not supposed to have its context wait, because that could induce 714 // is not supposed to have its context wait, because that could induce
715 // deadlocks and/or security issues. The caller is responsible for 715 // deadlocks and/or security issues. The caller is responsible for
716 // waiting asynchronously, and resetting sync_point before calling this. 716 // waiting asynchronously, and resetting sync_point before calling this.
717 // However if the parent is a renderer (e.g. browser tag), it may be ok 717 // However if the parent is a renderer (e.g. browser tag), it may be ok
(...skipping 13 matching lines...) Expand all
731 resource.allocated = true; 731 resource.allocated = true;
732 m_resources[id] = resource; 732 m_resources[id] = resource;
733 childInfo.parentToChildMap[id] = it->id; 733 childInfo.parentToChildMap[id] = it->id;
734 childInfo.childToParentMap[it->id] = id; 734 childInfo.childToParentMap[it->id] = id;
735 } 735 }
736 } 736 }
737 737
738 void ResourceProvider::receiveFromParent(const TransferableResourceList& resourc es) 738 void ResourceProvider::receiveFromParent(const TransferableResourceList& resourc es)
739 { 739 {
740 DCHECK(m_threadChecker.CalledOnValidThread()); 740 DCHECK(m_threadChecker.CalledOnValidThread());
741 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 741 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
742 if (!context3d || !context3d->makeContextCurrent()) { 742 if (!context3d || !context3d->makeContextCurrent()) {
743 // FIXME: Implement this path for software compositing. 743 // FIXME: Implement this path for software compositing.
744 return; 744 return;
745 } 745 }
746 if (resources.sync_point) 746 if (resources.sync_point)
747 GLC(context3d, context3d->waitSyncPoint(resources.sync_point)); 747 GLC(context3d, context3d->waitSyncPoint(resources.sync_point));
748 for (TransferableResourceArray::const_iterator it = resources.resources.begi n(); it != resources.resources.end(); ++it) { 748 for (TransferableResourceArray::const_iterator it = resources.resources.begi n(); it != resources.resources.end(); ++it) {
749 ResourceMap::iterator mapIterator = m_resources.find(it->id); 749 ResourceMap::iterator mapIterator = m_resources.find(it->id);
750 DCHECK(mapIterator != m_resources.end()); 750 DCHECK(mapIterator != m_resources.end());
751 Resource* resource = &mapIterator->second; 751 Resource* resource = &mapIterator->second;
752 DCHECK(resource->exported); 752 DCHECK(resource->exported);
753 resource->exported = false; 753 resource->exported = false;
754 DCHECK(resource->mailbox.Equals(it->mailbox)); 754 DCHECK(resource->mailbox.Equals(it->mailbox));
755 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId)); 755 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId));
756 GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, it->mail box.name)); 756 GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, it->mail box.name));
757 if (resource->markedForDeletion) 757 if (resource->markedForDeletion)
758 deleteResourceInternal(mapIterator); 758 deleteResourceInternal(mapIterator);
759 } 759 }
760 } 760 }
761 761
762 bool ResourceProvider::transferResource(WebGraphicsContext3D* context, ResourceI d id, TransferableResource* resource) 762 bool ResourceProvider::transferResource(WebGraphicsContext3D* context, ResourceI d id, TransferableResource* resource)
763 { 763 {
764 DCHECK(m_threadChecker.CalledOnValidThread()); 764 DCHECK(m_threadChecker.CalledOnValidThread());
765 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 765 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
766 ResourceMap::iterator it = m_resources.find(id); 766 ResourceMap::iterator it = m_resources.find(id);
767 CHECK(it != m_resources.end()); 767 CHECK(it != m_resources.end());
768 Resource* source = &it->second; 768 Resource* source = &it->second;
769 DCHECK(!source->lockedForWrite); 769 DCHECK(!source->lockedForWrite);
770 DCHECK(!source->lockForReadCount); 770 DCHECK(!source->lockForReadCount);
771 DCHECK(!source->external || (source->external && !source->mailbox.IsEmpty()) ); 771 DCHECK(!source->external || (source->external && !source->mailbox.IsEmpty()) );
772 DCHECK(source->allocated); 772 DCHECK(source->allocated);
773 if (source->exported) 773 if (source->exported)
774 return false; 774 return false;
775 resource->id = id; 775 resource->id = id;
(...skipping 15 matching lines...) Expand all
791 void ResourceProvider::acquirePixelBuffer(ResourceId id) 791 void ResourceProvider::acquirePixelBuffer(ResourceId id)
792 { 792 {
793 DCHECK(m_threadChecker.CalledOnValidThread()); 793 DCHECK(m_threadChecker.CalledOnValidThread());
794 ResourceMap::iterator it = m_resources.find(id); 794 ResourceMap::iterator it = m_resources.find(id);
795 CHECK(it != m_resources.end()); 795 CHECK(it != m_resources.end());
796 Resource* resource = &it->second; 796 Resource* resource = &it->second;
797 DCHECK(!resource->external); 797 DCHECK(!resource->external);
798 DCHECK(!resource->exported); 798 DCHECK(!resource->exported);
799 799
800 if (resource->glId) { 800 if (resource->glId) {
801 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 801 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
802 DCHECK(context3d); 802 DCHECK(context3d);
803 if (!resource->glPixelBufferId) 803 if (!resource->glPixelBufferId)
804 resource->glPixelBufferId = context3d->createBuffer(); 804 resource->glPixelBufferId = context3d->createBuffer();
805 context3d->bindBuffer( 805 context3d->bindBuffer(
806 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 806 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
807 resource->glPixelBufferId); 807 resource->glPixelBufferId);
808 context3d->bufferData( 808 context3d->bufferData(
809 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 809 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
810 resource->size.width() * resource->size.height() * 4, 810 resource->size.width() * resource->size.height() * 4,
811 NULL, 811 NULL,
(...skipping 14 matching lines...) Expand all
826 { 826 {
827 DCHECK(m_threadChecker.CalledOnValidThread()); 827 DCHECK(m_threadChecker.CalledOnValidThread());
828 ResourceMap::iterator it = m_resources.find(id); 828 ResourceMap::iterator it = m_resources.find(id);
829 CHECK(it != m_resources.end()); 829 CHECK(it != m_resources.end());
830 Resource* resource = &it->second; 830 Resource* resource = &it->second;
831 DCHECK(!resource->external); 831 DCHECK(!resource->external);
832 DCHECK(!resource->exported); 832 DCHECK(!resource->exported);
833 833
834 if (resource->glId) { 834 if (resource->glId) {
835 DCHECK(resource->glPixelBufferId); 835 DCHECK(resource->glPixelBufferId);
836 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 836 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
837 DCHECK(context3d); 837 DCHECK(context3d);
838 context3d->bindBuffer( 838 context3d->bindBuffer(
839 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 839 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
840 resource->glPixelBufferId); 840 resource->glPixelBufferId);
841 context3d->bufferData( 841 context3d->bufferData(
842 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 842 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
843 0, 843 0,
844 NULL, 844 NULL,
845 GL_DYNAMIC_DRAW); 845 GL_DYNAMIC_DRAW);
846 context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); 846 context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
(...skipping 10 matching lines...) Expand all
857 uint8_t* ResourceProvider::mapPixelBuffer(ResourceId id) 857 uint8_t* ResourceProvider::mapPixelBuffer(ResourceId id)
858 { 858 {
859 DCHECK(m_threadChecker.CalledOnValidThread()); 859 DCHECK(m_threadChecker.CalledOnValidThread());
860 ResourceMap::iterator it = m_resources.find(id); 860 ResourceMap::iterator it = m_resources.find(id);
861 CHECK(it != m_resources.end()); 861 CHECK(it != m_resources.end());
862 Resource* resource = &it->second; 862 Resource* resource = &it->second;
863 DCHECK(!resource->external); 863 DCHECK(!resource->external);
864 DCHECK(!resource->exported); 864 DCHECK(!resource->exported);
865 865
866 if (resource->glId) { 866 if (resource->glId) {
867 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 867 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
868 DCHECK(context3d); 868 DCHECK(context3d);
869 DCHECK(resource->glPixelBufferId); 869 DCHECK(resource->glPixelBufferId);
870 context3d->bindBuffer( 870 context3d->bindBuffer(
871 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 871 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
872 resource->glPixelBufferId); 872 resource->glPixelBufferId);
873 uint8_t* image = static_cast<uint8_t*>( 873 uint8_t* image = static_cast<uint8_t*>(
874 context3d->mapBufferCHROMIUM( 874 context3d->mapBufferCHROMIUM(
875 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, GL_WRITE_ONLY)); 875 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, GL_WRITE_ONLY));
876 context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); 876 context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
877 DCHECK(image); 877 DCHECK(image);
878 return image; 878 return image;
879 } 879 }
880 880
881 if (resource->pixels) 881 if (resource->pixels)
882 return resource->pixelBuffer; 882 return resource->pixelBuffer;
883 883
884 return NULL; 884 return NULL;
885 } 885 }
886 886
887 void ResourceProvider::unmapPixelBuffer(ResourceId id) 887 void ResourceProvider::unmapPixelBuffer(ResourceId id)
888 { 888 {
889 DCHECK(m_threadChecker.CalledOnValidThread()); 889 DCHECK(m_threadChecker.CalledOnValidThread());
890 ResourceMap::iterator it = m_resources.find(id); 890 ResourceMap::iterator it = m_resources.find(id);
891 CHECK(it != m_resources.end()); 891 CHECK(it != m_resources.end());
892 Resource* resource = &it->second; 892 Resource* resource = &it->second;
893 DCHECK(!resource->external); 893 DCHECK(!resource->external);
894 DCHECK(!resource->exported); 894 DCHECK(!resource->exported);
895 895
896 if (resource->glId) { 896 if (resource->glId) {
897 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 897 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
898 DCHECK(context3d); 898 DCHECK(context3d);
899 DCHECK(resource->glPixelBufferId); 899 DCHECK(resource->glPixelBufferId);
900 context3d->bindBuffer( 900 context3d->bindBuffer(
901 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 901 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
902 resource->glPixelBufferId); 902 resource->glPixelBufferId);
903 context3d->unmapBufferCHROMIUM( 903 context3d->unmapBufferCHROMIUM(
904 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM); 904 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM);
905 context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); 905 context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
906 } 906 }
907 } 907 }
908 908
909 void ResourceProvider::setPixelsFromBuffer(ResourceId id) 909 void ResourceProvider::setPixelsFromBuffer(ResourceId id)
910 { 910 {
911 DCHECK(m_threadChecker.CalledOnValidThread()); 911 DCHECK(m_threadChecker.CalledOnValidThread());
912 ResourceMap::iterator it = m_resources.find(id); 912 ResourceMap::iterator it = m_resources.find(id);
913 CHECK(it != m_resources.end()); 913 CHECK(it != m_resources.end());
914 Resource* resource = &it->second; 914 Resource* resource = &it->second;
915 DCHECK(!resource->lockedForWrite); 915 DCHECK(!resource->lockedForWrite);
916 DCHECK(!resource->lockForReadCount); 916 DCHECK(!resource->lockForReadCount);
917 DCHECK(!resource->external); 917 DCHECK(!resource->external);
918 DCHECK(!resource->exported); 918 DCHECK(!resource->exported);
919 DCHECK(readLockFenceHasPassed(resource)); 919 DCHECK(readLockFenceHasPassed(resource));
920 lazyAllocate(resource); 920 lazyAllocate(resource);
921 921
922 if (resource->glId) { 922 if (resource->glId) {
923 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 923 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
924 DCHECK(context3d); 924 DCHECK(context3d);
925 DCHECK(resource->glPixelBufferId); 925 DCHECK(resource->glPixelBufferId);
926 context3d->bindTexture(GL_TEXTURE_2D, resource->glId); 926 context3d->bindTexture(GL_TEXTURE_2D, resource->glId);
927 context3d->bindBuffer( 927 context3d->bindBuffer(
928 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 928 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
929 resource->glPixelBufferId); 929 resource->glPixelBufferId);
930 context3d->texSubImage2D(GL_TEXTURE_2D, 930 context3d->texSubImage2D(GL_TEXTURE_2D,
931 0, /* level */ 931 0, /* level */
932 0, /* x */ 932 0, /* x */
933 0, /* y */ 933 0, /* y */
(...skipping 16 matching lines...) Expand all
950 950
951 ScopedWriteLockSoftware lock(this, id); 951 ScopedWriteLockSoftware lock(this, id);
952 SkCanvas* dest = lock.skCanvas(); 952 SkCanvas* dest = lock.skCanvas();
953 dest->writePixels(src, 0, 0); 953 dest->writePixels(src, 0, 0);
954 } 954 }
955 } 955 }
956 956
957 void ResourceProvider::bindForSampling(ResourceProvider::ResourceId resourceId, GLenum target, GLenum filter) 957 void ResourceProvider::bindForSampling(ResourceProvider::ResourceId resourceId, GLenum target, GLenum filter)
958 { 958 {
959 DCHECK(m_threadChecker.CalledOnValidThread()); 959 DCHECK(m_threadChecker.CalledOnValidThread());
960 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 960 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
961 ResourceMap::iterator it = m_resources.find(resourceId); 961 ResourceMap::iterator it = m_resources.find(resourceId);
962 DCHECK(it != m_resources.end()); 962 DCHECK(it != m_resources.end());
963 Resource* resource = &it->second; 963 Resource* resource = &it->second;
964 DCHECK(resource->lockForReadCount); 964 DCHECK(resource->lockForReadCount);
965 DCHECK(!resource->lockedForWrite); 965 DCHECK(!resource->lockedForWrite);
966 966
967 GLC(context3d, context3d->bindTexture(target, resource->glId)); 967 GLC(context3d, context3d->bindTexture(target, resource->glId));
968 if (filter != resource->filter) { 968 if (filter != resource->filter) {
969 GLC(context3d, context3d->texParameteri(target, GL_TEXTURE_MIN_FILTER, f ilter)); 969 GLC(context3d, context3d->texParameteri(target, GL_TEXTURE_MIN_FILTER, f ilter));
970 GLC(context3d, context3d->texParameteri(target, GL_TEXTURE_MAG_FILTER, f ilter)); 970 GLC(context3d, context3d->texParameteri(target, GL_TEXTURE_MAG_FILTER, f ilter));
971 resource->filter = filter; 971 resource->filter = filter;
972 } 972 }
973 } 973 }
974 974
975 void ResourceProvider::beginSetPixels(ResourceId id) 975 void ResourceProvider::beginSetPixels(ResourceId id)
976 { 976 {
977 DCHECK(m_threadChecker.CalledOnValidThread()); 977 DCHECK(m_threadChecker.CalledOnValidThread());
978 ResourceMap::iterator it = m_resources.find(id); 978 ResourceMap::iterator it = m_resources.find(id);
979 CHECK(it != m_resources.end()); 979 CHECK(it != m_resources.end());
980 Resource* resource = &it->second; 980 Resource* resource = &it->second;
981 DCHECK(!resource->pendingSetPixels); 981 DCHECK(!resource->pendingSetPixels);
982 DCHECK(resource->glId || resource->allocated); 982 DCHECK(resource->glId || resource->allocated);
983 DCHECK(readLockFenceHasPassed(resource)); 983 DCHECK(readLockFenceHasPassed(resource));
984 984
985 bool allocate = !resource->allocated; 985 bool allocate = !resource->allocated;
986 resource->allocated = true; 986 resource->allocated = true;
987 lockForWrite(id); 987 lockForWrite(id);
988 988
989 if (resource->glId) { 989 if (resource->glId) {
990 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 990 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
991 DCHECK(context3d); 991 DCHECK(context3d);
992 DCHECK(resource->glPixelBufferId); 992 DCHECK(resource->glPixelBufferId);
993 context3d->bindTexture(GL_TEXTURE_2D, resource->glId); 993 context3d->bindTexture(GL_TEXTURE_2D, resource->glId);
994 context3d->bindBuffer( 994 context3d->bindBuffer(
995 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 995 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
996 resource->glPixelBufferId); 996 resource->glPixelBufferId);
997 if (!resource->glUploadQueryId) 997 if (!resource->glUploadQueryId)
998 resource->glUploadQueryId = context3d->createQueryEXT(); 998 resource->glUploadQueryId = context3d->createQueryEXT();
999 context3d->beginQueryEXT( 999 context3d->beginQueryEXT(
1000 GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM, 1000 GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 1032
1033 bool ResourceProvider::didSetPixelsComplete(ResourceId id) { 1033 bool ResourceProvider::didSetPixelsComplete(ResourceId id) {
1034 DCHECK(m_threadChecker.CalledOnValidThread()); 1034 DCHECK(m_threadChecker.CalledOnValidThread());
1035 ResourceMap::iterator it = m_resources.find(id); 1035 ResourceMap::iterator it = m_resources.find(id);
1036 CHECK(it != m_resources.end()); 1036 CHECK(it != m_resources.end());
1037 Resource* resource = &it->second; 1037 Resource* resource = &it->second;
1038 DCHECK(resource->lockedForWrite); 1038 DCHECK(resource->lockedForWrite);
1039 DCHECK(resource->pendingSetPixels); 1039 DCHECK(resource->pendingSetPixels);
1040 1040
1041 if (resource->glId) { 1041 if (resource->glId) {
1042 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 1042 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
1043 DCHECK(context3d); 1043 DCHECK(context3d);
1044 DCHECK(resource->glUploadQueryId); 1044 DCHECK(resource->glUploadQueryId);
1045 unsigned complete = 1; 1045 unsigned complete = 1;
1046 context3d->getQueryObjectuivEXT( 1046 context3d->getQueryObjectuivEXT(
1047 resource->glUploadQueryId, 1047 resource->glUploadQueryId,
1048 GL_QUERY_RESULT_AVAILABLE_EXT, 1048 GL_QUERY_RESULT_AVAILABLE_EXT,
1049 &complete); 1049 &complete);
1050 if (!complete) 1050 if (!complete)
1051 return false; 1051 return false;
1052 } 1052 }
1053 1053
1054 resource->pendingSetPixels = false; 1054 resource->pendingSetPixels = false;
1055 unlockForWrite(id); 1055 unlockForWrite(id);
1056 1056
1057 return true; 1057 return true;
1058 } 1058 }
1059 1059
1060 void ResourceProvider::abortSetPixels(ResourceId id) { 1060 void ResourceProvider::abortSetPixels(ResourceId id) {
1061 DCHECK(m_threadChecker.CalledOnValidThread()); 1061 DCHECK(m_threadChecker.CalledOnValidThread());
1062 ResourceMap::iterator it = m_resources.find(id); 1062 ResourceMap::iterator it = m_resources.find(id);
1063 CHECK(it != m_resources.end()); 1063 CHECK(it != m_resources.end());
1064 Resource* resource = &it->second; 1064 Resource* resource = &it->second;
1065 DCHECK(resource->lockedForWrite); 1065 DCHECK(resource->lockedForWrite);
1066 DCHECK(resource->pendingSetPixels); 1066 DCHECK(resource->pendingSetPixels);
1067 1067
1068 if (resource->glId) { 1068 if (resource->glId) {
1069 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 1069 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
1070 DCHECK(context3d); 1070 DCHECK(context3d);
1071 DCHECK(resource->glUploadQueryId); 1071 DCHECK(resource->glUploadQueryId);
1072 // CHROMIUM_async_pixel_transfers currently doesn't have a way to 1072 // CHROMIUM_async_pixel_transfers currently doesn't have a way to
1073 // abort an upload. The best we can do is delete the query and 1073 // abort an upload. The best we can do is delete the query and
1074 // the texture. 1074 // the texture.
1075 context3d->deleteQueryEXT(resource->glUploadQueryId); 1075 context3d->deleteQueryEXT(resource->glUploadQueryId);
1076 resource->glUploadQueryId = 0; 1076 resource->glUploadQueryId = 0;
1077 context3d->deleteTexture(resource->glId); 1077 context3d->deleteTexture(resource->glId);
1078 resource->glId = createTextureId(context3d); 1078 resource->glId = createTextureId(context3d);
1079 resource->allocated = false; 1079 resource->allocated = false;
(...skipping 10 matching lines...) Expand all
1090 lazyAllocate(resource); 1090 lazyAllocate(resource);
1091 } 1091 }
1092 1092
1093 void ResourceProvider::lazyAllocate(Resource* resource) { 1093 void ResourceProvider::lazyAllocate(Resource* resource) {
1094 DCHECK(resource); 1094 DCHECK(resource);
1095 DCHECK(resource->glId || resource->allocated); 1095 DCHECK(resource->glId || resource->allocated);
1096 1096
1097 if (resource->allocated || !resource->glId) 1097 if (resource->allocated || !resource->glId)
1098 return; 1098 return;
1099 resource->allocated = true; 1099 resource->allocated = true;
1100 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 1100 WebGraphicsContext3D* context3d = m_outputSurface->context3d();
1101 gfx::Size& size = resource->size; 1101 gfx::Size& size = resource->size;
1102 GLenum format = resource->format; 1102 GLenum format = resource->format;
1103 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId)); 1103 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId));
1104 if (m_useTextureStorageExt && isTextureFormatSupportedForStorage(format)) { 1104 if (m_useTextureStorageExt && isTextureFormatSupportedForStorage(format)) {
1105 GLenum storageFormat = textureToStorageFormat(format); 1105 GLenum storageFormat = textureToStorageFormat(format);
1106 GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D, 1, storageForma t, size.width(), size.height())); 1106 GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D, 1, storageForma t, size.width(), size.height()));
1107 } else 1107 } else
1108 GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D, 0, format, size.widt h(), size.height(), 0, format, GL_UNSIGNED_BYTE, 0)); 1108 GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D, 0, format, size.widt h(), size.height(), 0, format, GL_UNSIGNED_BYTE, 0));
1109 } 1109 }
1110 1110
1111 void ResourceProvider::enableReadLockFences(ResourceProvider::ResourceId id, boo l enable) { 1111 void ResourceProvider::enableReadLockFences(ResourceProvider::ResourceId id, boo l enable) {
1112 DCHECK(m_threadChecker.CalledOnValidThread()); 1112 DCHECK(m_threadChecker.CalledOnValidThread());
1113 ResourceMap::iterator it = m_resources.find(id); 1113 ResourceMap::iterator it = m_resources.find(id);
1114 CHECK(it != m_resources.end()); 1114 CHECK(it != m_resources.end());
1115 Resource* resource = &it->second; 1115 Resource* resource = &it->second;
1116 resource->enableReadLockFences = enable; 1116 resource->enableReadLockFences = enable;
1117 } 1117 }
1118 1118
1119 } // namespace cc 1119 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output_surface.cc ('k') | cc/resource_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698