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

Side by Side Diff: cc/resources/resource_provider.cc

Issue 23023005: cc: refcount resources as we send them to the parent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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/resources/resource_provider.h" 5 #include "cc/resources/resource_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 } // namespace 67 } // namespace
68 68
69 ResourceProvider::Resource::Resource() 69 ResourceProvider::Resource::Resource()
70 : gl_id(0), 70 : gl_id(0),
71 gl_pixel_buffer_id(0), 71 gl_pixel_buffer_id(0),
72 gl_upload_query_id(0), 72 gl_upload_query_id(0),
73 pixels(NULL), 73 pixels(NULL),
74 pixel_buffer(NULL), 74 pixel_buffer(NULL),
75 lock_for_read_count(0), 75 lock_for_read_count(0),
76 imported_count(0),
77 exported_count(0),
76 locked_for_write(false), 78 locked_for_write(false),
77 external(false), 79 external(false),
78 exported(false),
79 marked_for_deletion(false), 80 marked_for_deletion(false),
80 pending_set_pixels(false), 81 pending_set_pixels(false),
81 set_pixels_completion_forced(false), 82 set_pixels_completion_forced(false),
82 allocated(false), 83 allocated(false),
83 enable_read_lock_fences(false), 84 enable_read_lock_fences(false),
84 read_lock_fence(NULL), 85 read_lock_fence(NULL),
85 size(), 86 size(),
86 format(0), 87 format(0),
87 filter(0), 88 filter(0),
88 image_id(0), 89 image_id(0),
89 texture_pool(0), 90 texture_pool(0),
90 hint(TextureUsageAny), 91 hint(TextureUsageAny),
91 type(static_cast<ResourceType>(0)) {} 92 type(static_cast<ResourceType>(0)) {}
92 93
93 ResourceProvider::Resource::~Resource() {} 94 ResourceProvider::Resource::~Resource() {}
94 95
95 ResourceProvider::Resource::Resource( 96 ResourceProvider::Resource::Resource(
96 unsigned texture_id, 97 unsigned texture_id,
97 gfx::Size size, 98 gfx::Size size,
98 GLenum format, 99 GLenum format,
99 GLenum filter, 100 GLenum filter,
100 GLenum texture_pool, 101 GLenum texture_pool,
101 TextureUsageHint hint) 102 TextureUsageHint hint)
102 : gl_id(texture_id), 103 : gl_id(texture_id),
103 gl_pixel_buffer_id(0), 104 gl_pixel_buffer_id(0),
104 gl_upload_query_id(0), 105 gl_upload_query_id(0),
105 pixels(NULL), 106 pixels(NULL),
106 pixel_buffer(NULL), 107 pixel_buffer(NULL),
107 lock_for_read_count(0), 108 lock_for_read_count(0),
109 imported_count(0),
110 exported_count(0),
108 locked_for_write(false), 111 locked_for_write(false),
109 external(false), 112 external(false),
110 exported(false),
111 marked_for_deletion(false), 113 marked_for_deletion(false),
112 pending_set_pixels(false), 114 pending_set_pixels(false),
113 set_pixels_completion_forced(false), 115 set_pixels_completion_forced(false),
114 allocated(false), 116 allocated(false),
115 enable_read_lock_fences(false), 117 enable_read_lock_fences(false),
116 read_lock_fence(NULL), 118 read_lock_fence(NULL),
117 size(size), 119 size(size),
118 format(format), 120 format(format),
119 filter(filter), 121 filter(filter),
120 image_id(0), 122 image_id(0),
121 texture_pool(texture_pool), 123 texture_pool(texture_pool),
122 hint(hint), 124 hint(hint),
123 type(GLTexture) {} 125 type(GLTexture) {}
124 126
125 ResourceProvider::Resource::Resource( 127 ResourceProvider::Resource::Resource(
126 uint8_t* pixels, gfx::Size size, GLenum format, GLenum filter) 128 uint8_t* pixels, gfx::Size size, GLenum format, GLenum filter)
127 : gl_id(0), 129 : gl_id(0),
128 gl_pixel_buffer_id(0), 130 gl_pixel_buffer_id(0),
129 gl_upload_query_id(0), 131 gl_upload_query_id(0),
130 pixels(pixels), 132 pixels(pixels),
131 pixel_buffer(NULL), 133 pixel_buffer(NULL),
132 lock_for_read_count(0), 134 lock_for_read_count(0),
135 imported_count(0),
136 exported_count(0),
133 locked_for_write(false), 137 locked_for_write(false),
134 external(false), 138 external(false),
135 exported(false),
136 marked_for_deletion(false), 139 marked_for_deletion(false),
137 pending_set_pixels(false), 140 pending_set_pixels(false),
138 set_pixels_completion_forced(false), 141 set_pixels_completion_forced(false),
139 allocated(false), 142 allocated(false),
140 enable_read_lock_fences(false), 143 enable_read_lock_fences(false),
141 read_lock_fence(NULL), 144 read_lock_fence(NULL),
142 size(size), 145 size(size),
143 format(format), 146 format(format),
144 filter(filter), 147 filter(filter),
145 image_id(0), 148 image_id(0),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 WebGraphicsContext3D* ResourceProvider::GraphicsContext3D() { 185 WebGraphicsContext3D* ResourceProvider::GraphicsContext3D() {
183 DCHECK(thread_checker_.CalledOnValidThread()); 186 DCHECK(thread_checker_.CalledOnValidThread());
184 return output_surface_->context3d(); 187 return output_surface_->context3d();
185 } 188 }
186 189
187 bool ResourceProvider::InUseByConsumer(ResourceId id) { 190 bool ResourceProvider::InUseByConsumer(ResourceId id) {
188 DCHECK(thread_checker_.CalledOnValidThread()); 191 DCHECK(thread_checker_.CalledOnValidThread());
189 ResourceMap::iterator it = resources_.find(id); 192 ResourceMap::iterator it = resources_.find(id);
190 CHECK(it != resources_.end()); 193 CHECK(it != resources_.end());
191 Resource* resource = &it->second; 194 Resource* resource = &it->second;
192 return !!resource->lock_for_read_count || resource->exported; 195 return !!resource->lock_for_read_count || !!resource->exported_count;
danakj 2013/08/15 21:30:53 nit: i like x>0 a lot more than !!x for integers
piman 2013/08/16 04:29:55 Done.
193 } 196 }
194 197
195 ResourceProvider::ResourceId ResourceProvider::CreateResource( 198 ResourceProvider::ResourceId ResourceProvider::CreateResource(
196 gfx::Size size, GLenum format, TextureUsageHint hint) { 199 gfx::Size size, GLenum format, TextureUsageHint hint) {
197 DCHECK(!size.IsEmpty()); 200 DCHECK(!size.IsEmpty());
198 switch (default_resource_type_) { 201 switch (default_resource_type_) {
199 case GLTexture: 202 case GLTexture:
200 return CreateGLTexture( 203 return CreateGLTexture(
201 size, format, GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, hint); 204 size, format, GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, hint);
202 case Bitmap: 205 case Bitmap:
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 resource.mailbox = mailbox; 304 resource.mailbox = mailbox;
302 return id; 305 return id;
303 } 306 }
304 307
305 void ResourceProvider::DeleteResource(ResourceId id) { 308 void ResourceProvider::DeleteResource(ResourceId id) {
306 DCHECK(thread_checker_.CalledOnValidThread()); 309 DCHECK(thread_checker_.CalledOnValidThread());
307 ResourceMap::iterator it = resources_.find(id); 310 ResourceMap::iterator it = resources_.find(id);
308 CHECK(it != resources_.end()); 311 CHECK(it != resources_.end());
309 Resource* resource = &it->second; 312 Resource* resource = &it->second;
310 DCHECK(!resource->lock_for_read_count); 313 DCHECK(!resource->lock_for_read_count);
311 DCHECK(!resource->marked_for_deletion); 314 DCHECK(!resource->marked_for_deletion);
danakj 2013/08/15 21:30:53 Can we DCHECK(!imported_count)? Is it okay to dele
danakj 2013/08/15 21:32:01 Oops, bad reviewer. I mean DCHECK_EQ(0, imported_c
piman 2013/08/16 04:29:55 DCHECK_EQ(imported_count, 0). DCHECK doesn't diffe
312 DCHECK(resource->pending_set_pixels || !resource->locked_for_write); 315 DCHECK(resource->pending_set_pixels || !resource->locked_for_write);
313 316
314 if (resource->exported) { 317 if (!!resource->exported_count) {
315 resource->marked_for_deletion = true; 318 resource->marked_for_deletion = true;
316 return; 319 return;
317 } else { 320 } else {
318 DeleteResourceInternal(it, Normal); 321 DeleteResourceInternal(it, Normal);
319 } 322 }
320 } 323 }
321 324
322 void ResourceProvider::DeleteResourceInternal(ResourceMap::iterator it, 325 void ResourceProvider::DeleteResourceInternal(ResourceMap::iterator it,
323 DeleteStyle style) { 326 DeleteStyle style) {
324 Resource* resource = &it->second; 327 Resource* resource = &it->second;
325 bool lost_resource = lost_output_surface_; 328 bool lost_resource = lost_output_surface_;
326 329
327 DCHECK(!resource->exported || style != Normal); 330 DCHECK(!resource->exported_count || style != Normal);
328 if (style == ForShutdown && resource->exported) 331 if (style == ForShutdown && !!resource->exported_count)
329 lost_resource = true; 332 lost_resource = true;
330 333
331 if (resource->image_id) { 334 if (resource->image_id) {
332 WebGraphicsContext3D* context3d = output_surface_->context3d(); 335 WebGraphicsContext3D* context3d = output_surface_->context3d();
333 DCHECK(context3d); 336 DCHECK(context3d);
334 GLC(context3d, context3d->destroyImageCHROMIUM(resource->image_id)); 337 GLC(context3d, context3d->destroyImageCHROMIUM(resource->image_id));
335 } 338 }
336 339
337 if (resource->gl_id && !resource->external) { 340 if (resource->gl_id && !resource->external) {
338 WebGraphicsContext3D* context3d = output_surface_->context3d(); 341 WebGraphicsContext3D* context3d = output_surface_->context3d();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 gfx::Rect image_rect, 392 gfx::Rect image_rect,
390 gfx::Rect source_rect, 393 gfx::Rect source_rect,
391 gfx::Vector2d dest_offset) { 394 gfx::Vector2d dest_offset) {
392 DCHECK(thread_checker_.CalledOnValidThread()); 395 DCHECK(thread_checker_.CalledOnValidThread());
393 ResourceMap::iterator it = resources_.find(id); 396 ResourceMap::iterator it = resources_.find(id);
394 CHECK(it != resources_.end()); 397 CHECK(it != resources_.end());
395 Resource* resource = &it->second; 398 Resource* resource = &it->second;
396 DCHECK(!resource->locked_for_write); 399 DCHECK(!resource->locked_for_write);
397 DCHECK(!resource->lock_for_read_count); 400 DCHECK(!resource->lock_for_read_count);
398 DCHECK(!resource->external); 401 DCHECK(!resource->external);
399 DCHECK(!resource->exported); 402 DCHECK(!resource->exported_count);
400 DCHECK(ReadLockFenceHasPassed(resource)); 403 DCHECK(ReadLockFenceHasPassed(resource));
401 LazyAllocate(resource); 404 LazyAllocate(resource);
402 405
403 if (resource->gl_id) { 406 if (resource->gl_id) {
404 DCHECK(!resource->pending_set_pixels); 407 DCHECK(!resource->pending_set_pixels);
405 WebGraphicsContext3D* context3d = output_surface_->context3d(); 408 WebGraphicsContext3D* context3d = output_surface_->context3d();
406 DCHECK(context3d); 409 DCHECK(context3d);
407 DCHECK(texture_uploader_.get()); 410 DCHECK(texture_uploader_.get());
408 context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id); 411 context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id);
409 texture_uploader_->Upload(image, 412 texture_uploader_->Upload(image,
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 499
497 const ResourceProvider::Resource* ResourceProvider::LockForRead(ResourceId id) { 500 const ResourceProvider::Resource* ResourceProvider::LockForRead(ResourceId id) {
498 DCHECK(thread_checker_.CalledOnValidThread()); 501 DCHECK(thread_checker_.CalledOnValidThread());
499 ResourceMap::iterator it = resources_.find(id); 502 ResourceMap::iterator it = resources_.find(id);
500 CHECK(it != resources_.end()); 503 CHECK(it != resources_.end());
501 Resource* resource = &it->second; 504 Resource* resource = &it->second;
502 DCHECK(!resource->locked_for_write || 505 DCHECK(!resource->locked_for_write ||
503 resource->set_pixels_completion_forced) << 506 resource->set_pixels_completion_forced) <<
504 "locked for write: " << resource->locked_for_write << 507 "locked for write: " << resource->locked_for_write <<
505 " pixels completion forced: " << resource->set_pixels_completion_forced; 508 " pixels completion forced: " << resource->set_pixels_completion_forced;
506 DCHECK(!resource->exported); 509 DCHECK(!resource->exported_count);
507 // Uninitialized! Call SetPixels or LockForWrite first. 510 // Uninitialized! Call SetPixels or LockForWrite first.
508 DCHECK(resource->allocated); 511 DCHECK(resource->allocated);
509 512
510 LazyCreate(resource); 513 LazyCreate(resource);
511 514
512 if (resource->external) { 515 if (resource->external) {
513 if (!resource->gl_id && resource->mailbox.IsTexture()) { 516 if (!resource->gl_id && resource->mailbox.IsTexture()) {
514 WebGraphicsContext3D* context3d = output_surface_->context3d(); 517 WebGraphicsContext3D* context3d = output_surface_->context3d();
515 DCHECK(context3d); 518 DCHECK(context3d);
516 if (resource->mailbox.sync_point()) { 519 if (resource->mailbox.sync_point()) {
(...skipping 15 matching lines...) Expand all
532 535
533 return resource; 536 return resource;
534 } 537 }
535 538
536 void ResourceProvider::UnlockForRead(ResourceId id) { 539 void ResourceProvider::UnlockForRead(ResourceId id) {
537 DCHECK(thread_checker_.CalledOnValidThread()); 540 DCHECK(thread_checker_.CalledOnValidThread());
538 ResourceMap::iterator it = resources_.find(id); 541 ResourceMap::iterator it = resources_.find(id);
539 CHECK(it != resources_.end()); 542 CHECK(it != resources_.end());
540 Resource* resource = &it->second; 543 Resource* resource = &it->second;
541 DCHECK_GT(resource->lock_for_read_count, 0); 544 DCHECK_GT(resource->lock_for_read_count, 0);
542 DCHECK(!resource->exported); 545 DCHECK(!resource->exported_count);
543 resource->lock_for_read_count--; 546 resource->lock_for_read_count--;
544 } 547 }
545 548
546 const ResourceProvider::Resource* ResourceProvider::LockForWrite( 549 const ResourceProvider::Resource* ResourceProvider::LockForWrite(
547 ResourceId id) { 550 ResourceId id) {
548 DCHECK(thread_checker_.CalledOnValidThread()); 551 DCHECK(thread_checker_.CalledOnValidThread());
549 ResourceMap::iterator it = resources_.find(id); 552 ResourceMap::iterator it = resources_.find(id);
550 CHECK(it != resources_.end()); 553 CHECK(it != resources_.end());
551 Resource* resource = &it->second; 554 Resource* resource = &it->second;
552 DCHECK(!resource->locked_for_write); 555 DCHECK(!resource->locked_for_write);
553 DCHECK(!resource->lock_for_read_count); 556 DCHECK(!resource->lock_for_read_count);
554 DCHECK(!resource->exported); 557 DCHECK(!resource->exported_count);
555 DCHECK(!resource->external); 558 DCHECK(!resource->external);
556 DCHECK(ReadLockFenceHasPassed(resource)); 559 DCHECK(ReadLockFenceHasPassed(resource));
557 LazyAllocate(resource); 560 LazyAllocate(resource);
558 561
559 resource->locked_for_write = true; 562 resource->locked_for_write = true;
560 return resource; 563 return resource;
561 } 564 }
562 565
563 bool ResourceProvider::CanLockForWrite(ResourceId id) { 566 bool ResourceProvider::CanLockForWrite(ResourceId id) {
564 DCHECK(thread_checker_.CalledOnValidThread()); 567 DCHECK(thread_checker_.CalledOnValidThread());
565 ResourceMap::iterator it = resources_.find(id); 568 ResourceMap::iterator it = resources_.find(id);
566 CHECK(it != resources_.end()); 569 CHECK(it != resources_.end());
567 Resource* resource = &it->second; 570 Resource* resource = &it->second;
568 return !resource->locked_for_write && 571 return !resource->locked_for_write &&
569 !resource->lock_for_read_count && 572 !resource->lock_for_read_count &&
570 !resource->exported && 573 !resource->exported_count &&
571 !resource->external && 574 !resource->external &&
572 ReadLockFenceHasPassed(resource); 575 ReadLockFenceHasPassed(resource);
573 } 576 }
574 577
575 void ResourceProvider::UnlockForWrite(ResourceId id) { 578 void ResourceProvider::UnlockForWrite(ResourceId id) {
576 DCHECK(thread_checker_.CalledOnValidThread()); 579 DCHECK(thread_checker_.CalledOnValidThread());
577 ResourceMap::iterator it = resources_.find(id); 580 ResourceMap::iterator it = resources_.find(id);
578 CHECK(it != resources_.end()); 581 CHECK(it != resources_.end());
579 Resource* resource = &it->second; 582 Resource* resource = &it->second;
580 DCHECK(resource->locked_for_write); 583 DCHECK(resource->locked_for_write);
581 DCHECK(!resource->exported); 584 DCHECK(!resource->exported_count);
582 DCHECK(!resource->external); 585 DCHECK(!resource->external);
583 resource->locked_for_write = false; 586 resource->locked_for_write = false;
584 } 587 }
585 588
586 ResourceProvider::ScopedReadLockGL::ScopedReadLockGL( 589 ResourceProvider::ScopedReadLockGL::ScopedReadLockGL(
587 ResourceProvider* resource_provider, 590 ResourceProvider* resource_provider,
588 ResourceProvider::ResourceId resource_id) 591 ResourceProvider::ResourceId resource_id)
589 : resource_provider_(resource_provider), 592 : resource_provider_(resource_provider),
590 resource_id_(resource_id), 593 resource_id_(resource_id),
591 texture_id_(resource_provider->LockForRead(resource_id)->gl_id) { 594 texture_id_(resource_provider->LockForRead(resource_id)->gl_id) {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 WebGraphicsContext3D* context3d = output_surface_->context3d(); 791 WebGraphicsContext3D* context3d = output_surface_->context3d();
789 if (!context3d || !context3d->makeContextCurrent()) { 792 if (!context3d || !context3d->makeContextCurrent()) {
790 // TODO(skaslev): Implement this path for software compositing. 793 // TODO(skaslev): Implement this path for software compositing.
791 return; 794 return;
792 } 795 }
793 bool need_sync_point = false; 796 bool need_sync_point = false;
794 for (ResourceIdArray::const_iterator it = resources.begin(); 797 for (ResourceIdArray::const_iterator it = resources.begin();
795 it != resources.end(); 798 it != resources.end();
796 ++it) { 799 ++it) {
797 TransferableResource resource; 800 TransferableResource resource;
798 if (TransferResource(context3d, *it, &resource)) { 801 TransferResource(context3d, *it, &resource);
799 if (!resource.sync_point) 802 if (!resource.sync_point)
800 need_sync_point = true; 803 need_sync_point = true;
801 resources_.find(*it)->second.exported = true; 804 ++resources_.find(*it)->second.exported_count;
802 list->push_back(resource); 805 list->push_back(resource);
803 }
804 } 806 }
805 if (need_sync_point) { 807 if (need_sync_point) {
806 unsigned int sync_point = context3d->insertSyncPoint(); 808 unsigned int sync_point = context3d->insertSyncPoint();
807 for (TransferableResourceArray::iterator it = list->begin(); 809 for (TransferableResourceArray::iterator it = list->begin();
808 it != list->end(); 810 it != list->end();
809 ++it) { 811 ++it) {
810 if (!it->sync_point) 812 if (!it->sync_point)
811 it->sync_point = sync_point; 813 it->sync_point = sync_point;
812 } 814 }
813 } 815 }
814 } 816 }
815 817
816 void ResourceProvider::PrepareSendToChild(int child, 818 void ResourceProvider::PrepareSendToChild(int child,
817 const ResourceIdArray& resources, 819 const ResourceIdArray& resources,
818 TransferableResourceArray* list) { 820 TransferableResourceArray* list) {
819 DCHECK(thread_checker_.CalledOnValidThread()); 821 DCHECK(thread_checker_.CalledOnValidThread());
820 WebGraphicsContext3D* context3d = output_surface_->context3d(); 822 WebGraphicsContext3D* context3d = output_surface_->context3d();
821 if (!context3d || !context3d->makeContextCurrent()) { 823 if (!context3d || !context3d->makeContextCurrent()) {
822 // TODO(skaslev): Implement this path for software compositing. 824 // TODO(skaslev): Implement this path for software compositing.
823 return; 825 return;
824 } 826 }
825 Child& child_info = children_.find(child)->second; 827 Child& child_info = children_.find(child)->second;
826 bool need_sync_point = false; 828 bool need_sync_point = false;
827 for (ResourceIdArray::const_iterator it = resources.begin(); 829 for (ResourceIdArray::const_iterator it = resources.begin();
828 it != resources.end(); 830 it != resources.end();
829 ++it) { 831 ++it) {
830 TransferableResource resource; 832 TransferableResource resource;
831 if (!TransferResource(context3d, *it, &resource)) 833 TransferResource(context3d, *it, &resource);
832 NOTREACHED();
833 if (!resource.sync_point) 834 if (!resource.sync_point)
834 need_sync_point = true; 835 need_sync_point = true;
835 DCHECK(child_info.parent_to_child_map.find(*it) != 836 DCHECK(child_info.parent_to_child_map.find(*it) !=
836 child_info.parent_to_child_map.end()); 837 child_info.parent_to_child_map.end());
837 resource.id = child_info.parent_to_child_map[*it]; 838 resource.id = child_info.parent_to_child_map[*it];
838 child_info.parent_to_child_map.erase(*it); 839 child_info.parent_to_child_map.erase(*it);
839 child_info.child_to_parent_map.erase(resource.id); 840 child_info.child_to_parent_map.erase(resource.id);
840 list->push_back(resource); 841 for (unsigned i = 0; i < resources_[*it].imported_count; ++i)
danakj 2013/08/15 21:30:53 int
piman 2013/08/16 04:29:55 Done.
842 list->push_back(resource);
danakj 2013/08/15 21:30:53 You'd need to --imported_count to DCHECK in the De
piman 2013/08/16 04:29:55 Done.
841 DeleteResource(*it); 843 DeleteResource(*it);
842 } 844 }
843 if (need_sync_point) { 845 if (need_sync_point) {
844 unsigned int sync_point = context3d->insertSyncPoint(); 846 unsigned int sync_point = context3d->insertSyncPoint();
845 for (TransferableResourceArray::iterator it = list->begin(); 847 for (TransferableResourceArray::iterator it = list->begin();
846 it != list->end(); 848 it != list->end();
847 ++it) { 849 ++it) {
848 if (!it->sync_point) 850 if (!it->sync_point)
849 it->sync_point = sync_point; 851 it->sync_point = sync_point;
850 } 852 }
851 } 853 }
852 } 854 }
853 855
854 void ResourceProvider::ReceiveFromChild( 856 void ResourceProvider::ReceiveFromChild(
855 int child, const TransferableResourceArray& resources) { 857 int child, const TransferableResourceArray& resources) {
856 DCHECK(thread_checker_.CalledOnValidThread()); 858 DCHECK(thread_checker_.CalledOnValidThread());
857 WebGraphicsContext3D* context3d = output_surface_->context3d(); 859 WebGraphicsContext3D* context3d = output_surface_->context3d();
858 if (!context3d || !context3d->makeContextCurrent()) { 860 if (!context3d || !context3d->makeContextCurrent()) {
859 // TODO(skaslev): Implement this path for software compositing. 861 // TODO(skaslev): Implement this path for software compositing.
860 return; 862 return;
861 } 863 }
862 Child& child_info = children_.find(child)->second; 864 Child& child_info = children_.find(child)->second;
863 for (TransferableResourceArray::const_iterator it = resources.begin(); 865 for (TransferableResourceArray::const_iterator it = resources.begin();
864 it != resources.end(); 866 it != resources.end();
865 ++it) { 867 ++it) {
868 if (child_info.child_to_parent_map.find(it->id) !=
869 child_info.child_to_parent_map.end()) {
870 resources_[child_info.child_to_parent_map[it->id]].imported_count++;
danakj 2013/08/15 21:30:53 We just did a find() on line 868. Save the iterato
piman 2013/08/16 04:29:55 Done.
871 continue;
872 }
866 unsigned texture_id; 873 unsigned texture_id;
867 // NOTE: If the parent is a browser and the child a renderer, the parent 874 // NOTE: If the parent is a browser and the child a renderer, the parent
868 // is not supposed to have its context wait, because that could induce 875 // is not supposed to have its context wait, because that could induce
869 // deadlocks and/or security issues. The caller is responsible for 876 // deadlocks and/or security issues. The caller is responsible for
870 // waiting asynchronously, and resetting sync_point before calling this. 877 // waiting asynchronously, and resetting sync_point before calling this.
871 // However if the parent is a renderer (e.g. browser tag), it may be ok 878 // However if the parent is a renderer (e.g. browser tag), it may be ok
872 // (and is simpler) to wait. 879 // (and is simpler) to wait.
873 if (it->sync_point) 880 if (it->sync_point)
874 GLC(context3d, context3d->waitSyncPoint(it->sync_point)); 881 GLC(context3d, context3d->waitSyncPoint(it->sync_point));
875 GLC(context3d, texture_id = context3d->createTexture()); 882 GLC(context3d, texture_id = context3d->createTexture());
876 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, texture_id)); 883 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, texture_id));
877 GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, 884 GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D,
878 it->mailbox.name)); 885 it->mailbox.name));
879 ResourceId id = next_id_++; 886 ResourceId id = next_id_++;
880 Resource resource( 887 Resource resource(
881 texture_id, it->size, it->format, it->filter, 0, TextureUsageAny); 888 texture_id, it->size, it->format, it->filter, 0, TextureUsageAny);
882 resource.mailbox.SetName(it->mailbox); 889 resource.mailbox.SetName(it->mailbox);
883 // Don't allocate a texture for a child. 890 // Don't allocate a texture for a child.
884 resource.allocated = true; 891 resource.allocated = true;
892 resource.imported_count = 1;
885 resources_[id] = resource; 893 resources_[id] = resource;
886 child_info.parent_to_child_map[id] = it->id; 894 child_info.parent_to_child_map[id] = it->id;
887 child_info.child_to_parent_map[it->id] = id; 895 child_info.child_to_parent_map[it->id] = id;
888 } 896 }
889 } 897 }
890 898
891 void ResourceProvider::ReceiveFromParent( 899 void ResourceProvider::ReceiveFromParent(
892 const TransferableResourceArray& resources) { 900 const TransferableResourceArray& resources) {
893 DCHECK(thread_checker_.CalledOnValidThread()); 901 DCHECK(thread_checker_.CalledOnValidThread());
894 WebGraphicsContext3D* context3d = output_surface_->context3d(); 902 WebGraphicsContext3D* context3d = output_surface_->context3d();
895 if (!context3d || !context3d->makeContextCurrent()) { 903 if (!context3d || !context3d->makeContextCurrent()) {
896 // TODO(skaslev): Implement this path for software compositing. 904 // TODO(skaslev): Implement this path for software compositing.
897 return; 905 return;
898 } 906 }
899 for (TransferableResourceArray::const_iterator it = resources.begin(); 907 for (TransferableResourceArray::const_iterator it = resources.begin();
900 it != resources.end(); 908 it != resources.end();
901 ++it) { 909 ++it) {
902 ResourceMap::iterator map_iterator = resources_.find(it->id); 910 ResourceMap::iterator map_iterator = resources_.find(it->id);
903 DCHECK(map_iterator != resources_.end()); 911 DCHECK(map_iterator != resources_.end());
904 Resource* resource = &map_iterator->second; 912 Resource* resource = &map_iterator->second;
905 DCHECK(resource->exported); 913 DCHECK(!!resource->exported_count);
danakj 2013/08/15 21:30:53 DCHECK_GT?
piman 2013/08/16 04:29:55 Done.
906 resource->exported = false; 914 --resource->exported_count;
915 if (resource->exported_count)
916 continue;
907 resource->filter = it->filter; 917 resource->filter = it->filter;
908 DCHECK(resource->mailbox.ContainsMailbox(it->mailbox)); 918 DCHECK(resource->mailbox.ContainsMailbox(it->mailbox));
909 if (resource->gl_id) { 919 if (resource->gl_id) {
910 if (it->sync_point) 920 if (it->sync_point)
911 GLC(context3d, context3d->waitSyncPoint(it->sync_point)); 921 GLC(context3d, context3d->waitSyncPoint(it->sync_point));
912 } else { 922 } else {
913 resource->mailbox = TextureMailbox(resource->mailbox.name(), 923 resource->mailbox = TextureMailbox(resource->mailbox.name(),
914 resource->mailbox.callback(), 924 resource->mailbox.callback(),
915 it->sync_point); 925 it->sync_point);
916 } 926 }
917 if (resource->marked_for_deletion) 927 if (resource->marked_for_deletion)
918 DeleteResourceInternal(map_iterator, Normal); 928 DeleteResourceInternal(map_iterator, Normal);
919 } 929 }
920 } 930 }
921 931
922 bool ResourceProvider::TransferResource(WebGraphicsContext3D* context, 932 void ResourceProvider::TransferResource(WebGraphicsContext3D* context,
923 ResourceId id, 933 ResourceId id,
924 TransferableResource* resource) { 934 TransferableResource* resource) {
925 DCHECK(thread_checker_.CalledOnValidThread()); 935 DCHECK(thread_checker_.CalledOnValidThread());
926 ResourceMap::iterator it = resources_.find(id); 936 ResourceMap::iterator it = resources_.find(id);
927 CHECK(it != resources_.end()); 937 CHECK(it != resources_.end());
928 Resource* source = &it->second; 938 Resource* source = &it->second;
929 DCHECK(!source->locked_for_write); 939 DCHECK(!source->locked_for_write);
930 DCHECK(!source->lock_for_read_count); 940 DCHECK(!source->lock_for_read_count);
931 DCHECK(!source->external || (source->external && source->mailbox.IsValid())); 941 DCHECK(!source->external || (source->external && source->mailbox.IsValid()));
932 DCHECK(source->allocated); 942 DCHECK(source->allocated);
933 if (source->exported)
934 return false;
935 resource->id = id; 943 resource->id = id;
936 resource->format = source->format; 944 resource->format = source->format;
937 resource->filter = source->filter; 945 resource->filter = source->filter;
938 resource->size = source->size; 946 resource->size = source->size;
939 947
940 // TODO(skaslev) Implement this path for shared memory resources. 948 // TODO(skaslev) Implement this path for shared memory resources.
941 DCHECK(!source->mailbox.IsSharedMemory()); 949 DCHECK(!source->mailbox.IsSharedMemory());
942 950
943 if (!source->mailbox.IsTexture()) { 951 if (!source->mailbox.IsTexture()) {
944 // This is a resource allocated by the compositor, we need to produce it. 952 // This is a resource allocated by the compositor, we need to produce it.
945 // Don't set a sync point, the caller will do it. 953 // Don't set a sync point, the caller will do it.
946 DCHECK(source->gl_id); 954 DCHECK(source->gl_id);
947 GLC(context, context->bindTexture(GL_TEXTURE_2D, source->gl_id)); 955 GLC(context, context->bindTexture(GL_TEXTURE_2D, source->gl_id));
948 GLC(context, context->genMailboxCHROMIUM(resource->mailbox.name)); 956 GLC(context, context->genMailboxCHROMIUM(resource->mailbox.name));
949 GLC(context, context->produceTextureCHROMIUM(GL_TEXTURE_2D, 957 GLC(context, context->produceTextureCHROMIUM(GL_TEXTURE_2D,
950 resource->mailbox.name)); 958 resource->mailbox.name));
951 source->mailbox.SetName(resource->mailbox); 959 source->mailbox.SetName(resource->mailbox);
952 } else { 960 } else {
953 // This is either an external resource, or a compositor resource that we 961 // This is either an external resource, or a compositor resource that we
954 // already exported. Make sure to forward the sync point that we were given. 962 // already exported. Make sure to forward the sync point that we were given.
955 resource->mailbox = source->mailbox.name(); 963 resource->mailbox = source->mailbox.name();
956 resource->sync_point = source->mailbox.sync_point(); 964 resource->sync_point = source->mailbox.sync_point();
957 source->mailbox.ResetSyncPoint(); 965 source->mailbox.ResetSyncPoint();
958 } 966 }
959
960 return true;
961 } 967 }
962 968
963 void ResourceProvider::AcquirePixelBuffer(ResourceId id) { 969 void ResourceProvider::AcquirePixelBuffer(ResourceId id) {
964 DCHECK(thread_checker_.CalledOnValidThread()); 970 DCHECK(thread_checker_.CalledOnValidThread());
965 ResourceMap::iterator it = resources_.find(id); 971 ResourceMap::iterator it = resources_.find(id);
966 CHECK(it != resources_.end()); 972 CHECK(it != resources_.end());
967 Resource* resource = &it->second; 973 Resource* resource = &it->second;
968 DCHECK(!resource->external); 974 DCHECK(!resource->external);
969 DCHECK(!resource->exported); 975 DCHECK(!resource->exported_count);
970 DCHECK(!resource->image_id); 976 DCHECK(!resource->image_id);
971 977
972 if (resource->type == GLTexture) { 978 if (resource->type == GLTexture) {
973 WebGraphicsContext3D* context3d = output_surface_->context3d(); 979 WebGraphicsContext3D* context3d = output_surface_->context3d();
974 DCHECK(context3d); 980 DCHECK(context3d);
975 if (!resource->gl_pixel_buffer_id) 981 if (!resource->gl_pixel_buffer_id)
976 resource->gl_pixel_buffer_id = context3d->createBuffer(); 982 resource->gl_pixel_buffer_id = context3d->createBuffer();
977 context3d->bindBuffer( 983 context3d->bindBuffer(
978 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 984 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
979 resource->gl_pixel_buffer_id); 985 resource->gl_pixel_buffer_id);
(...skipping 12 matching lines...) Expand all
992 resource->pixel_buffer = new uint8_t[4 * resource->size.GetArea()]; 998 resource->pixel_buffer = new uint8_t[4 * resource->size.GetArea()];
993 } 999 }
994 } 1000 }
995 1001
996 void ResourceProvider::ReleasePixelBuffer(ResourceId id) { 1002 void ResourceProvider::ReleasePixelBuffer(ResourceId id) {
997 DCHECK(thread_checker_.CalledOnValidThread()); 1003 DCHECK(thread_checker_.CalledOnValidThread());
998 ResourceMap::iterator it = resources_.find(id); 1004 ResourceMap::iterator it = resources_.find(id);
999 CHECK(it != resources_.end()); 1005 CHECK(it != resources_.end());
1000 Resource* resource = &it->second; 1006 Resource* resource = &it->second;
1001 DCHECK(!resource->external); 1007 DCHECK(!resource->external);
1002 DCHECK(!resource->exported); 1008 DCHECK(!resource->exported_count);
1003 DCHECK(!resource->image_id); 1009 DCHECK(!resource->image_id);
1004 1010
1005 // The pixel buffer can be released while there is a pending "set pixels" 1011 // The pixel buffer can be released while there is a pending "set pixels"
1006 // if completion has been forced. Any shared memory associated with this 1012 // if completion has been forced. Any shared memory associated with this
1007 // pixel buffer will not be freed until the waitAsyncTexImage2DCHROMIUM 1013 // pixel buffer will not be freed until the waitAsyncTexImage2DCHROMIUM
1008 // command has been processed on the service side. It is also safe to 1014 // command has been processed on the service side. It is also safe to
1009 // reuse any query id associated with this resource before they complete 1015 // reuse any query id associated with this resource before they complete
1010 // as each new query has a unique submit count. 1016 // as each new query has a unique submit count.
1011 if (resource->pending_set_pixels) { 1017 if (resource->pending_set_pixels) {
1012 DCHECK(resource->set_pixels_completion_forced); 1018 DCHECK(resource->set_pixels_completion_forced);
(...skipping 24 matching lines...) Expand all
1037 resource->pixel_buffer = NULL; 1043 resource->pixel_buffer = NULL;
1038 } 1044 }
1039 } 1045 }
1040 1046
1041 uint8_t* ResourceProvider::MapPixelBuffer(ResourceId id) { 1047 uint8_t* ResourceProvider::MapPixelBuffer(ResourceId id) {
1042 DCHECK(thread_checker_.CalledOnValidThread()); 1048 DCHECK(thread_checker_.CalledOnValidThread());
1043 ResourceMap::iterator it = resources_.find(id); 1049 ResourceMap::iterator it = resources_.find(id);
1044 CHECK(it != resources_.end()); 1050 CHECK(it != resources_.end());
1045 Resource* resource = &it->second; 1051 Resource* resource = &it->second;
1046 DCHECK(!resource->external); 1052 DCHECK(!resource->external);
1047 DCHECK(!resource->exported); 1053 DCHECK(!resource->exported_count);
1048 DCHECK(!resource->image_id); 1054 DCHECK(!resource->image_id);
1049 1055
1050 if (resource->type == GLTexture) { 1056 if (resource->type == GLTexture) {
1051 WebGraphicsContext3D* context3d = output_surface_->context3d(); 1057 WebGraphicsContext3D* context3d = output_surface_->context3d();
1052 DCHECK(context3d); 1058 DCHECK(context3d);
1053 DCHECK(resource->gl_pixel_buffer_id); 1059 DCHECK(resource->gl_pixel_buffer_id);
1054 context3d->bindBuffer( 1060 context3d->bindBuffer(
1055 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 1061 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
1056 resource->gl_pixel_buffer_id); 1062 resource->gl_pixel_buffer_id);
1057 uint8_t* image = static_cast<uint8_t*>( 1063 uint8_t* image = static_cast<uint8_t*>(
(...skipping 10 matching lines...) Expand all
1068 1074
1069 return NULL; 1075 return NULL;
1070 } 1076 }
1071 1077
1072 void ResourceProvider::UnmapPixelBuffer(ResourceId id) { 1078 void ResourceProvider::UnmapPixelBuffer(ResourceId id) {
1073 DCHECK(thread_checker_.CalledOnValidThread()); 1079 DCHECK(thread_checker_.CalledOnValidThread());
1074 ResourceMap::iterator it = resources_.find(id); 1080 ResourceMap::iterator it = resources_.find(id);
1075 CHECK(it != resources_.end()); 1081 CHECK(it != resources_.end());
1076 Resource* resource = &it->second; 1082 Resource* resource = &it->second;
1077 DCHECK(!resource->external); 1083 DCHECK(!resource->external);
1078 DCHECK(!resource->exported); 1084 DCHECK(!resource->exported_count);
1079 DCHECK(!resource->image_id); 1085 DCHECK(!resource->image_id);
1080 1086
1081 if (resource->type == GLTexture) { 1087 if (resource->type == GLTexture) {
1082 WebGraphicsContext3D* context3d = output_surface_->context3d(); 1088 WebGraphicsContext3D* context3d = output_surface_->context3d();
1083 DCHECK(context3d); 1089 DCHECK(context3d);
1084 DCHECK(resource->gl_pixel_buffer_id); 1090 DCHECK(resource->gl_pixel_buffer_id);
1085 context3d->bindBuffer( 1091 context3d->bindBuffer(
1086 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 1092 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
1087 resource->gl_pixel_buffer_id); 1093 resource->gl_pixel_buffer_id);
1088 context3d->unmapBufferCHROMIUM(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM); 1094 context3d->unmapBufferCHROMIUM(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM);
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 resource->enable_read_lock_fences = enable; 1341 resource->enable_read_lock_fences = enable;
1336 } 1342 }
1337 1343
1338 void ResourceProvider::AcquireImage(ResourceId id) { 1344 void ResourceProvider::AcquireImage(ResourceId id) {
1339 DCHECK(thread_checker_.CalledOnValidThread()); 1345 DCHECK(thread_checker_.CalledOnValidThread());
1340 ResourceMap::iterator it = resources_.find(id); 1346 ResourceMap::iterator it = resources_.find(id);
1341 CHECK(it != resources_.end()); 1347 CHECK(it != resources_.end());
1342 Resource* resource = &it->second; 1348 Resource* resource = &it->second;
1343 1349
1344 DCHECK(!resource->external); 1350 DCHECK(!resource->external);
1345 DCHECK(!resource->exported); 1351 DCHECK(!resource->exported_count);
1346 1352
1347 if (resource->type != GLTexture) 1353 if (resource->type != GLTexture)
1348 return; 1354 return;
1349 1355
1350 if (resource->image_id) 1356 if (resource->image_id)
1351 return; 1357 return;
1352 1358
1353 resource->allocated = true; 1359 resource->allocated = true;
1354 WebGraphicsContext3D* context3d = output_surface_->context3d(); 1360 WebGraphicsContext3D* context3d = output_surface_->context3d();
1355 DCHECK(context3d); 1361 DCHECK(context3d);
1356 resource->image_id = context3d->createImageCHROMIUM( 1362 resource->image_id = context3d->createImageCHROMIUM(
1357 resource->size.width(), resource->size.height(), GL_RGBA8_OES); 1363 resource->size.width(), resource->size.height(), GL_RGBA8_OES);
1358 DCHECK(resource->image_id); 1364 DCHECK(resource->image_id);
1359 } 1365 }
1360 1366
1361 void ResourceProvider::ReleaseImage(ResourceId id) { 1367 void ResourceProvider::ReleaseImage(ResourceId id) {
1362 DCHECK(thread_checker_.CalledOnValidThread()); 1368 DCHECK(thread_checker_.CalledOnValidThread());
1363 ResourceMap::iterator it = resources_.find(id); 1369 ResourceMap::iterator it = resources_.find(id);
1364 CHECK(it != resources_.end()); 1370 CHECK(it != resources_.end());
1365 Resource* resource = &it->second; 1371 Resource* resource = &it->second;
1366 1372
1367 DCHECK(!resource->external); 1373 DCHECK(!resource->external);
1368 DCHECK(!resource->exported); 1374 DCHECK(!resource->exported_count);
1369 1375
1370 if (!resource->image_id) 1376 if (!resource->image_id)
1371 return; 1377 return;
1372 1378
1373 WebGraphicsContext3D* context3d = output_surface_->context3d(); 1379 WebGraphicsContext3D* context3d = output_surface_->context3d();
1374 DCHECK(context3d); 1380 DCHECK(context3d);
1375 context3d->destroyImageCHROMIUM(resource->image_id); 1381 context3d->destroyImageCHROMIUM(resource->image_id);
1376 resource->image_id = 0; 1382 resource->image_id = 0;
1377 resource->allocated = false; 1383 resource->allocated = false;
1378 } 1384 }
1379 1385
1380 uint8_t* ResourceProvider::MapImage(ResourceId id) { 1386 uint8_t* ResourceProvider::MapImage(ResourceId id) {
1381 DCHECK(thread_checker_.CalledOnValidThread()); 1387 DCHECK(thread_checker_.CalledOnValidThread());
1382 ResourceMap::iterator it = resources_.find(id); 1388 ResourceMap::iterator it = resources_.find(id);
1383 CHECK(it != resources_.end()); 1389 CHECK(it != resources_.end());
1384 Resource* resource = &it->second; 1390 Resource* resource = &it->second;
1385 1391
1386 DCHECK(ReadLockFenceHasPassed(resource)); 1392 DCHECK(ReadLockFenceHasPassed(resource));
1387 DCHECK(!resource->external); 1393 DCHECK(!resource->external);
1388 DCHECK(!resource->exported); 1394 DCHECK(!resource->exported_count);
1389 1395
1390 if (resource->image_id) { 1396 if (resource->image_id) {
1391 WebGraphicsContext3D* context3d = output_surface_->context3d(); 1397 WebGraphicsContext3D* context3d = output_surface_->context3d();
1392 DCHECK(context3d); 1398 DCHECK(context3d);
1393 return static_cast<uint8_t*>( 1399 return static_cast<uint8_t*>(
1394 context3d->mapImageCHROMIUM(resource->image_id, GL_READ_WRITE)); 1400 context3d->mapImageCHROMIUM(resource->image_id, GL_READ_WRITE));
1395 } 1401 }
1396 1402
1397 if (resource->pixels) 1403 if (resource->pixels)
1398 return resource->pixels; 1404 return resource->pixels;
1399 1405
1400 return NULL; 1406 return NULL;
1401 } 1407 }
1402 1408
1403 void ResourceProvider::UnmapImage(ResourceId id) { 1409 void ResourceProvider::UnmapImage(ResourceId id) {
1404 DCHECK(thread_checker_.CalledOnValidThread()); 1410 DCHECK(thread_checker_.CalledOnValidThread());
1405 ResourceMap::iterator it = resources_.find(id); 1411 ResourceMap::iterator it = resources_.find(id);
1406 CHECK(it != resources_.end()); 1412 CHECK(it != resources_.end());
1407 Resource* resource = &it->second; 1413 Resource* resource = &it->second;
1408 1414
1409 DCHECK(!resource->external); 1415 DCHECK(!resource->external);
1410 DCHECK(!resource->exported); 1416 DCHECK(!resource->exported_count);
1411 1417
1412 if (resource->image_id) { 1418 if (resource->image_id) {
1413 WebGraphicsContext3D* context3d = output_surface_->context3d(); 1419 WebGraphicsContext3D* context3d = output_surface_->context3d();
1414 DCHECK(context3d); 1420 DCHECK(context3d);
1415 context3d->unmapImageCHROMIUM(resource->image_id); 1421 context3d->unmapImageCHROMIUM(resource->image_id);
1416 } 1422 }
1417 } 1423 }
1418 1424
1419 int ResourceProvider::GetImageStride(ResourceId id) { 1425 int ResourceProvider::GetImageStride(ResourceId id) {
1420 DCHECK(thread_checker_.CalledOnValidThread()); 1426 DCHECK(thread_checker_.CalledOnValidThread());
1421 ResourceMap::iterator it = resources_.find(id); 1427 ResourceMap::iterator it = resources_.find(id);
1422 CHECK(it != resources_.end()); 1428 CHECK(it != resources_.end());
1423 Resource* resource = &it->second; 1429 Resource* resource = &it->second;
1424 1430
1425 DCHECK(!resource->external); 1431 DCHECK(!resource->external);
1426 DCHECK(!resource->exported); 1432 DCHECK(!resource->exported_count);
1427 1433
1428 int stride = 0; 1434 int stride = 0;
1429 1435
1430 if (resource->image_id) { 1436 if (resource->image_id) {
1431 WebGraphicsContext3D* context3d = output_surface_->context3d(); 1437 WebGraphicsContext3D* context3d = output_surface_->context3d();
1432 DCHECK(context3d); 1438 DCHECK(context3d);
1433 context3d->getImageParameterivCHROMIUM( 1439 context3d->getImageParameterivCHROMIUM(
1434 resource->image_id, GL_IMAGE_ROWBYTES_CHROMIUM, &stride); 1440 resource->image_id, GL_IMAGE_ROWBYTES_CHROMIUM, &stride);
1435 } 1441 }
1436 1442
1437 return stride; 1443 return stride;
1438 } 1444 }
1439 1445
1440 GLint ResourceProvider::GetActiveTextureUnit(WebGraphicsContext3D* context) { 1446 GLint ResourceProvider::GetActiveTextureUnit(WebGraphicsContext3D* context) {
1441 GLint active_unit = 0; 1447 GLint active_unit = 0;
1442 context->getIntegerv(GL_ACTIVE_TEXTURE, &active_unit); 1448 context->getIntegerv(GL_ACTIVE_TEXTURE, &active_unit);
1443 return active_unit; 1449 return active_unit;
1444 } 1450 }
1445 1451
1446 } // namespace cc 1452 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698