OLD | NEW |
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" |
11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "cc/base/util.h" | 15 #include "cc/base/util.h" |
16 #include "cc/output/gl_renderer.h" // For the GLC() macro. | 16 #include "cc/output/gl_renderer.h" // For the GLC() macro. |
17 #include "cc/resources/platform_color.h" | 17 #include "cc/resources/platform_color.h" |
18 #include "cc/resources/returned_resource.h" | 18 #include "cc/resources/returned_resource.h" |
19 #include "cc/resources/shared_bitmap_manager.h" | 19 #include "cc/resources/shared_bitmap_manager.h" |
20 #include "cc/resources/transferable_resource.h" | 20 #include "cc/resources/transferable_resource.h" |
21 #include "cc/scheduler/texture_uploader.h" | 21 #include "cc/scheduler/texture_uploader.h" |
22 #include "gpu/GLES2/gl2extchromium.h" | 22 #include "gpu/GLES2/gl2extchromium.h" |
23 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 23 #include "gpu/command_buffer/client/gles2_interface.h" |
24 #include "third_party/khronos/GLES2/gl2.h" | 24 #include "third_party/khronos/GLES2/gl2.h" |
25 #include "third_party/khronos/GLES2/gl2ext.h" | 25 #include "third_party/khronos/GLES2/gl2ext.h" |
26 #include "ui/gfx/frame_time.h" | 26 #include "ui/gfx/frame_time.h" |
27 #include "ui/gfx/rect.h" | 27 #include "ui/gfx/rect.h" |
28 #include "ui/gfx/vector2d.h" | 28 #include "ui/gfx/vector2d.h" |
29 | 29 |
30 using blink::WebGraphicsContext3D; | 30 using gpu::gles2::GLES2Interface; |
31 | 31 |
32 namespace cc { | 32 namespace cc { |
33 | 33 |
34 class IdAllocator { | 34 class IdAllocator { |
35 public: | 35 public: |
36 virtual ~IdAllocator() {} | 36 virtual ~IdAllocator() {} |
37 | 37 |
38 virtual unsigned NextId() = 0; | 38 virtual GLuint NextId() = 0; |
39 | 39 |
40 protected: | 40 protected: |
41 IdAllocator(WebGraphicsContext3D* context3d, size_t id_allocation_chunk_size) | 41 IdAllocator(GLES2Interface* gl, size_t id_allocation_chunk_size) |
42 : context3d_(context3d), | 42 : gl_(gl), |
43 id_allocation_chunk_size_(id_allocation_chunk_size), | 43 id_allocation_chunk_size_(id_allocation_chunk_size), |
44 ids_(new blink::WebGLId[id_allocation_chunk_size]), | 44 ids_(new GLuint[id_allocation_chunk_size]), |
45 next_id_index_(id_allocation_chunk_size) { | 45 next_id_index_(id_allocation_chunk_size) { |
46 DCHECK(id_allocation_chunk_size_); | 46 DCHECK(id_allocation_chunk_size_); |
47 } | 47 } |
48 | 48 |
49 WebGraphicsContext3D* context3d_; | 49 GLES2Interface* gl_; |
50 const size_t id_allocation_chunk_size_; | 50 const size_t id_allocation_chunk_size_; |
51 scoped_ptr<blink::WebGLId[]> ids_; | 51 scoped_ptr<GLuint[]> ids_; |
52 size_t next_id_index_; | 52 size_t next_id_index_; |
53 }; | 53 }; |
54 | 54 |
55 namespace { | 55 namespace { |
56 | 56 |
57 // Measured in seconds. | 57 // Measured in seconds. |
58 const double kSoftwareUploadTickRate = 0.000250; | 58 const double kSoftwareUploadTickRate = 0.000250; |
59 const double kTextureUploadTickRate = 0.004; | 59 const double kTextureUploadTickRate = 0.004; |
60 | 60 |
61 GLenum TextureToStorageFormat(ResourceFormat format) { | 61 GLenum TextureToStorageFormat(ResourceFormat format) { |
(...skipping 24 matching lines...) Expand all Loading... |
86 case LUMINANCE_8: | 86 case LUMINANCE_8: |
87 case RGB_565: | 87 case RGB_565: |
88 case ETC1: | 88 case ETC1: |
89 return false; | 89 return false; |
90 } | 90 } |
91 return false; | 91 return false; |
92 } | 92 } |
93 | 93 |
94 class ScopedSetActiveTexture { | 94 class ScopedSetActiveTexture { |
95 public: | 95 public: |
96 ScopedSetActiveTexture(WebGraphicsContext3D* context3d, GLenum unit) | 96 ScopedSetActiveTexture(GLES2Interface* gl, GLenum unit) |
97 : context3d_(context3d), unit_(unit) { | 97 : gl_(gl), unit_(unit) { |
98 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(context3d_)); | 98 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(gl_)); |
99 | 99 |
100 if (unit_ != GL_TEXTURE0) | 100 if (unit_ != GL_TEXTURE0) |
101 GLC(context3d_, context3d_->activeTexture(unit_)); | 101 GLC(gl_, gl_->ActiveTexture(unit_)); |
102 } | 102 } |
103 | 103 |
104 ~ScopedSetActiveTexture() { | 104 ~ScopedSetActiveTexture() { |
105 // Active unit being GL_TEXTURE0 is effectively the ground state. | 105 // Active unit being GL_TEXTURE0 is effectively the ground state. |
106 if (unit_ != GL_TEXTURE0) | 106 if (unit_ != GL_TEXTURE0) |
107 GLC(context3d_, context3d_->activeTexture(GL_TEXTURE0)); | 107 GLC(gl_, gl_->ActiveTexture(GL_TEXTURE0)); |
108 } | 108 } |
109 | 109 |
110 private: | 110 private: |
111 WebGraphicsContext3D* context3d_; | 111 GLES2Interface* gl_; |
112 GLenum unit_; | 112 GLenum unit_; |
113 }; | 113 }; |
114 | 114 |
115 class TextureIdAllocator : public IdAllocator { | 115 class TextureIdAllocator : public IdAllocator { |
116 public: | 116 public: |
117 TextureIdAllocator(WebGraphicsContext3D* context3d, | 117 TextureIdAllocator(GLES2Interface* gl, |
118 size_t texture_id_allocation_chunk_size) | 118 size_t texture_id_allocation_chunk_size) |
119 : IdAllocator(context3d, texture_id_allocation_chunk_size) { | 119 : IdAllocator(gl, texture_id_allocation_chunk_size) {} |
120 } | |
121 virtual ~TextureIdAllocator() { | 120 virtual ~TextureIdAllocator() { |
122 context3d_->deleteTextures(id_allocation_chunk_size_ - next_id_index_, | 121 gl_->DeleteTextures(id_allocation_chunk_size_ - next_id_index_, |
123 ids_.get() + next_id_index_); | 122 ids_.get() + next_id_index_); |
124 } | 123 } |
125 | 124 |
126 // Overridden from IdAllocator: | 125 // Overridden from IdAllocator: |
127 virtual unsigned NextId() OVERRIDE { | 126 virtual GLuint NextId() OVERRIDE { |
128 if (next_id_index_ == id_allocation_chunk_size_) { | 127 if (next_id_index_ == id_allocation_chunk_size_) { |
129 context3d_->genTextures(id_allocation_chunk_size_, ids_.get()); | 128 gl_->GenTextures(id_allocation_chunk_size_, ids_.get()); |
130 next_id_index_ = 0; | 129 next_id_index_ = 0; |
131 } | 130 } |
132 | 131 |
133 return ids_[next_id_index_++]; | 132 return ids_[next_id_index_++]; |
134 } | 133 } |
135 | 134 |
136 private: | 135 private: |
137 DISALLOW_COPY_AND_ASSIGN(TextureIdAllocator); | 136 DISALLOW_COPY_AND_ASSIGN(TextureIdAllocator); |
138 }; | 137 }; |
139 | 138 |
140 class BufferIdAllocator : public IdAllocator { | 139 class BufferIdAllocator : public IdAllocator { |
141 public: | 140 public: |
142 BufferIdAllocator(WebGraphicsContext3D* context3d, | 141 BufferIdAllocator(GLES2Interface* gl, size_t buffer_id_allocation_chunk_size) |
143 size_t buffer_id_allocation_chunk_size) | 142 : IdAllocator(gl, buffer_id_allocation_chunk_size) {} |
144 : IdAllocator(context3d, buffer_id_allocation_chunk_size) { | |
145 } | |
146 virtual ~BufferIdAllocator() { | 143 virtual ~BufferIdAllocator() { |
147 context3d_->deleteBuffers(id_allocation_chunk_size_ - next_id_index_, | 144 gl_->DeleteBuffers(id_allocation_chunk_size_ - next_id_index_, |
148 ids_.get() + next_id_index_); | 145 ids_.get() + next_id_index_); |
149 } | 146 } |
150 | 147 |
151 // Overridden from IdAllocator: | 148 // Overridden from IdAllocator: |
152 virtual unsigned NextId() OVERRIDE { | 149 virtual GLuint NextId() OVERRIDE { |
153 if (next_id_index_ == id_allocation_chunk_size_) { | 150 if (next_id_index_ == id_allocation_chunk_size_) { |
154 context3d_->genBuffers(id_allocation_chunk_size_, ids_.get()); | 151 gl_->GenBuffers(id_allocation_chunk_size_, ids_.get()); |
155 next_id_index_ = 0; | 152 next_id_index_ = 0; |
156 } | 153 } |
157 | 154 |
158 return ids_[next_id_index_++]; | 155 return ids_[next_id_index_++]; |
159 } | 156 } |
160 | 157 |
161 private: | 158 private: |
162 DISALLOW_COPY_AND_ASSIGN(BufferIdAllocator); | 159 DISALLOW_COPY_AND_ASSIGN(BufferIdAllocator); |
163 }; | 160 }; |
164 | 161 |
(...skipping 27 matching lines...) Expand all Loading... |
192 texture_pool(0), | 189 texture_pool(0), |
193 wrap_mode(0), | 190 wrap_mode(0), |
194 lost(false), | 191 lost(false), |
195 hint(TextureUsageAny), | 192 hint(TextureUsageAny), |
196 type(static_cast<ResourceType>(0)), | 193 type(static_cast<ResourceType>(0)), |
197 format(RGBA_8888), | 194 format(RGBA_8888), |
198 shared_bitmap(NULL) {} | 195 shared_bitmap(NULL) {} |
199 | 196 |
200 ResourceProvider::Resource::~Resource() {} | 197 ResourceProvider::Resource::~Resource() {} |
201 | 198 |
202 ResourceProvider::Resource::Resource(unsigned texture_id, | 199 ResourceProvider::Resource::Resource(GLuint texture_id, |
203 gfx::Size size, | 200 gfx::Size size, |
204 GLenum target, | 201 GLenum target, |
205 GLenum filter, | 202 GLenum filter, |
206 GLenum texture_pool, | 203 GLenum texture_pool, |
207 GLint wrap_mode, | 204 GLint wrap_mode, |
208 TextureUsageHint hint, | 205 TextureUsageHint hint, |
209 ResourceFormat format) | 206 ResourceFormat format) |
210 : child_id(0), | 207 : child_id(0), |
211 gl_id(texture_id), | 208 gl_id(texture_id), |
212 gl_pixel_buffer_id(0), | 209 gl_pixel_buffer_id(0), |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 bool use_rgba_4444_texture_format, | 288 bool use_rgba_4444_texture_format, |
292 size_t id_allocation_chunk_size) { | 289 size_t id_allocation_chunk_size) { |
293 scoped_ptr<ResourceProvider> resource_provider( | 290 scoped_ptr<ResourceProvider> resource_provider( |
294 new ResourceProvider(output_surface, | 291 new ResourceProvider(output_surface, |
295 shared_bitmap_manager, | 292 shared_bitmap_manager, |
296 highp_threshold_min, | 293 highp_threshold_min, |
297 use_rgba_4444_texture_format, | 294 use_rgba_4444_texture_format, |
298 id_allocation_chunk_size)); | 295 id_allocation_chunk_size)); |
299 | 296 |
300 bool success = false; | 297 bool success = false; |
301 if (resource_provider->Context3d()) { | 298 if (resource_provider->ContextGL()) { |
302 success = resource_provider->InitializeGL(); | 299 success = resource_provider->InitializeGL(); |
303 } else { | 300 } else { |
304 resource_provider->InitializeSoftware(); | 301 resource_provider->InitializeSoftware(); |
305 success = true; | 302 success = true; |
306 } | 303 } |
307 | 304 |
308 if (!success) | 305 if (!success) |
309 return scoped_ptr<ResourceProvider>(); | 306 return scoped_ptr<ResourceProvider>(); |
310 | 307 |
311 DCHECK_NE(InvalidType, resource_provider->default_resource_type()); | 308 DCHECK_NE(InvalidType, resource_provider->default_resource_type()); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 ResourceId id = next_id_++; | 416 ResourceId id = next_id_++; |
420 Resource resource( | 417 Resource resource( |
421 pixels, bitmap.release(), size, GL_LINEAR, wrap_mode); | 418 pixels, bitmap.release(), size, GL_LINEAR, wrap_mode); |
422 resource.allocated = true; | 419 resource.allocated = true; |
423 resources_[id] = resource; | 420 resources_[id] = resource; |
424 return id; | 421 return id; |
425 } | 422 } |
426 | 423 |
427 ResourceProvider::ResourceId | 424 ResourceProvider::ResourceId |
428 ResourceProvider::CreateResourceFromExternalTexture( | 425 ResourceProvider::CreateResourceFromExternalTexture( |
429 unsigned texture_target, | 426 GLuint texture_target, |
430 unsigned texture_id) { | 427 GLuint texture_id) { |
431 DCHECK(thread_checker_.CalledOnValidThread()); | 428 DCHECK(thread_checker_.CalledOnValidThread()); |
432 | 429 |
433 WebGraphicsContext3D* context3d = Context3d(); | 430 GLES2Interface* gl = ContextGL(); |
434 DCHECK(context3d); | 431 DCHECK(gl); |
435 GLC(context3d, context3d->bindTexture(texture_target, texture_id)); | 432 GLC(gl, gl->BindTexture(texture_target, texture_id)); |
436 GLC(context3d, context3d->texParameteri( | 433 GLC(gl, gl->TexParameteri(texture_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); |
437 texture_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | 434 GLC(gl, gl->TexParameteri(texture_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); |
438 GLC(context3d, context3d->texParameteri( | 435 GLC(gl, |
439 texture_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | 436 gl->TexParameteri(texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); |
440 GLC(context3d, context3d->texParameteri( | 437 GLC(gl, |
441 texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); | 438 gl->TexParameteri(texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); |
442 GLC(context3d, context3d->texParameteri( | |
443 texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); | |
444 | 439 |
445 ResourceId id = next_id_++; | 440 ResourceId id = next_id_++; |
446 Resource resource(texture_id, | 441 Resource resource(texture_id, |
447 gfx::Size(), | 442 gfx::Size(), |
448 texture_target, | 443 texture_target, |
449 GL_LINEAR, | 444 GL_LINEAR, |
450 0, | 445 0, |
451 GL_CLAMP_TO_EDGE, | 446 GL_CLAMP_TO_EDGE, |
452 TextureUsageAny, | 447 TextureUsageAny, |
453 RGBA_8888); | 448 RGBA_8888); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 DeleteStyle style) { | 516 DeleteStyle style) { |
522 TRACE_EVENT0("cc", "ResourceProvider::DeleteResourceInternal"); | 517 TRACE_EVENT0("cc", "ResourceProvider::DeleteResourceInternal"); |
523 Resource* resource = &it->second; | 518 Resource* resource = &it->second; |
524 bool lost_resource = resource->lost; | 519 bool lost_resource = resource->lost; |
525 | 520 |
526 DCHECK(resource->exported_count == 0 || style != Normal); | 521 DCHECK(resource->exported_count == 0 || style != Normal); |
527 if (style == ForShutdown && resource->exported_count > 0) | 522 if (style == ForShutdown && resource->exported_count > 0) |
528 lost_resource = true; | 523 lost_resource = true; |
529 | 524 |
530 if (resource->image_id) { | 525 if (resource->image_id) { |
531 WebGraphicsContext3D* context3d = Context3d(); | 526 GLES2Interface* gl = ContextGL(); |
532 DCHECK(context3d); | 527 DCHECK(gl); |
533 GLC(context3d, context3d->destroyImageCHROMIUM(resource->image_id)); | 528 GLC(gl, gl->DestroyImageCHROMIUM(resource->image_id)); |
534 } | 529 } |
535 | 530 |
536 if (resource->gl_id && !resource->external) { | 531 if (resource->gl_id && !resource->external) { |
537 WebGraphicsContext3D* context3d = Context3d(); | 532 GLES2Interface* gl = ContextGL(); |
538 DCHECK(context3d); | 533 DCHECK(gl); |
539 GLC(context3d, context3d->deleteTexture(resource->gl_id)); | 534 GLC(gl, gl->DeleteTextures(1, &resource->gl_id)); |
540 } | 535 } |
541 if (resource->gl_upload_query_id) { | 536 if (resource->gl_upload_query_id) { |
542 WebGraphicsContext3D* context3d = Context3d(); | 537 GLES2Interface* gl = ContextGL(); |
543 DCHECK(context3d); | 538 DCHECK(gl); |
544 GLC(context3d, context3d->deleteQueryEXT(resource->gl_upload_query_id)); | 539 GLC(gl, gl->DeleteQueriesEXT(1, &resource->gl_upload_query_id)); |
545 } | 540 } |
546 if (resource->gl_pixel_buffer_id) { | 541 if (resource->gl_pixel_buffer_id) { |
547 WebGraphicsContext3D* context3d = Context3d(); | 542 GLES2Interface* gl = ContextGL(); |
548 DCHECK(context3d); | 543 DCHECK(gl); |
549 GLC(context3d, context3d->deleteBuffer(resource->gl_pixel_buffer_id)); | 544 GLC(gl, gl->DeleteBuffers(1, &resource->gl_pixel_buffer_id)); |
550 } | 545 } |
551 if (resource->mailbox.IsValid() && resource->external) { | 546 if (resource->mailbox.IsValid() && resource->external) { |
552 unsigned sync_point = resource->mailbox.sync_point(); | 547 GLuint sync_point = resource->mailbox.sync_point(); |
553 if (resource->mailbox.IsTexture()) { | 548 if (resource->mailbox.IsTexture()) { |
554 lost_resource |= lost_output_surface_; | 549 lost_resource |= lost_output_surface_; |
555 WebGraphicsContext3D* context3d = Context3d(); | 550 GLES2Interface* gl = ContextGL(); |
556 DCHECK(context3d); | 551 DCHECK(gl); |
557 if (resource->gl_id) | 552 if (resource->gl_id) |
558 GLC(context3d, context3d->deleteTexture(resource->gl_id)); | 553 GLC(gl, gl->DeleteTextures(1, &resource->gl_id)); |
559 if (!lost_resource && resource->gl_id) | 554 if (!lost_resource && resource->gl_id) |
560 sync_point = context3d->insertSyncPoint(); | 555 sync_point = gl->InsertSyncPointCHROMIUM(); |
561 } else { | 556 } else { |
562 DCHECK(resource->mailbox.IsSharedMemory()); | 557 DCHECK(resource->mailbox.IsSharedMemory()); |
563 base::SharedMemory* shared_memory = resource->mailbox.shared_memory(); | 558 base::SharedMemory* shared_memory = resource->mailbox.shared_memory(); |
564 if (resource->pixels && shared_memory) { | 559 if (resource->pixels && shared_memory) { |
565 DCHECK(shared_memory->memory() == resource->pixels); | 560 DCHECK(shared_memory->memory() == resource->pixels); |
566 resource->pixels = NULL; | 561 resource->pixels = NULL; |
567 delete resource->shared_bitmap; | 562 delete resource->shared_bitmap; |
568 resource->shared_bitmap = NULL; | 563 resource->shared_bitmap = NULL; |
569 } | 564 } |
570 } | 565 } |
(...skipping 25 matching lines...) Expand all Loading... |
596 DCHECK(!resource->locked_for_write); | 591 DCHECK(!resource->locked_for_write); |
597 DCHECK(!resource->lock_for_read_count); | 592 DCHECK(!resource->lock_for_read_count); |
598 DCHECK(!resource->external); | 593 DCHECK(!resource->external); |
599 DCHECK_EQ(resource->exported_count, 0); | 594 DCHECK_EQ(resource->exported_count, 0); |
600 DCHECK(ReadLockFenceHasPassed(resource)); | 595 DCHECK(ReadLockFenceHasPassed(resource)); |
601 LazyAllocate(resource); | 596 LazyAllocate(resource); |
602 | 597 |
603 if (resource->gl_id) { | 598 if (resource->gl_id) { |
604 DCHECK(!resource->pending_set_pixels); | 599 DCHECK(!resource->pending_set_pixels); |
605 DCHECK_EQ(resource->target, static_cast<GLenum>(GL_TEXTURE_2D)); | 600 DCHECK_EQ(resource->target, static_cast<GLenum>(GL_TEXTURE_2D)); |
606 WebGraphicsContext3D* context3d = Context3d(); | 601 GLES2Interface* gl = ContextGL(); |
607 DCHECK(context3d); | 602 DCHECK(gl); |
608 DCHECK(texture_uploader_.get()); | 603 DCHECK(texture_uploader_.get()); |
609 context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id); | 604 gl->BindTexture(GL_TEXTURE_2D, resource->gl_id); |
610 texture_uploader_->Upload(image, | 605 texture_uploader_->Upload(image, |
611 image_rect, | 606 image_rect, |
612 source_rect, | 607 source_rect, |
613 dest_offset, | 608 dest_offset, |
614 resource->format, | 609 resource->format, |
615 resource->size); | 610 resource->size); |
616 } | 611 } |
617 | 612 |
618 if (resource->pixels) { | 613 if (resource->pixels) { |
619 DCHECK(resource->allocated); | 614 DCHECK(resource->allocated); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 base::TimeDelta::FromMicroseconds( | 685 base::TimeDelta::FromMicroseconds( |
691 base::Time::kMicrosecondsPerSecond * kTextureUploadTickRate) / | 686 base::Time::kMicrosecondsPerSecond * kTextureUploadTickRate) / |
692 uploads_per_tick; | 687 uploads_per_tick; |
693 | 688 |
694 size_t total_uploads = NumBlockingUploads() + uploads_per_tick; | 689 size_t total_uploads = NumBlockingUploads() + uploads_per_tick; |
695 return gfx::FrameTime::Now() + upload_one_texture_time * total_uploads; | 690 return gfx::FrameTime::Now() + upload_one_texture_time * total_uploads; |
696 } | 691 } |
697 | 692 |
698 void ResourceProvider::Flush() { | 693 void ResourceProvider::Flush() { |
699 DCHECK(thread_checker_.CalledOnValidThread()); | 694 DCHECK(thread_checker_.CalledOnValidThread()); |
700 WebGraphicsContext3D* context3d = Context3d(); | 695 GLES2Interface* gl = ContextGL(); |
701 if (context3d) | 696 if (gl) |
702 context3d->flush(); | 697 gl->Flush(); |
703 } | 698 } |
704 | 699 |
705 void ResourceProvider::Finish() { | 700 void ResourceProvider::Finish() { |
706 DCHECK(thread_checker_.CalledOnValidThread()); | 701 DCHECK(thread_checker_.CalledOnValidThread()); |
707 WebGraphicsContext3D* context3d = Context3d(); | 702 GLES2Interface* gl = ContextGL(); |
708 if (context3d) | 703 if (gl) |
709 context3d->finish(); | 704 gl->Finish(); |
710 } | 705 } |
711 | 706 |
712 bool ResourceProvider::ShallowFlushIfSupported() { | 707 bool ResourceProvider::ShallowFlushIfSupported() { |
713 DCHECK(thread_checker_.CalledOnValidThread()); | 708 DCHECK(thread_checker_.CalledOnValidThread()); |
714 WebGraphicsContext3D* context3d = Context3d(); | 709 GLES2Interface* gl = ContextGL(); |
715 if (!context3d) | 710 if (!gl) |
716 return false; | 711 return false; |
717 | 712 |
718 context3d->shallowFlushCHROMIUM(); | 713 gl->ShallowFlushCHROMIUM(); |
719 return true; | 714 return true; |
720 } | 715 } |
721 | 716 |
722 ResourceProvider::Resource* ResourceProvider::GetResource(ResourceId id) { | 717 ResourceProvider::Resource* ResourceProvider::GetResource(ResourceId id) { |
723 DCHECK(thread_checker_.CalledOnValidThread()); | 718 DCHECK(thread_checker_.CalledOnValidThread()); |
724 ResourceMap::iterator it = resources_.find(id); | 719 ResourceMap::iterator it = resources_.find(id); |
725 CHECK(it != resources_.end()); | 720 CHECK(it != resources_.end()); |
726 return &it->second; | 721 return &it->second; |
727 } | 722 } |
728 | 723 |
729 const ResourceProvider::Resource* ResourceProvider::LockForRead(ResourceId id) { | 724 const ResourceProvider::Resource* ResourceProvider::LockForRead(ResourceId id) { |
730 Resource* resource = GetResource(id); | 725 Resource* resource = GetResource(id); |
731 DCHECK(!resource->locked_for_write || | 726 DCHECK(!resource->locked_for_write || |
732 resource->set_pixels_completion_forced) << | 727 resource->set_pixels_completion_forced) << |
733 "locked for write: " << resource->locked_for_write << | 728 "locked for write: " << resource->locked_for_write << |
734 " pixels completion forced: " << resource->set_pixels_completion_forced; | 729 " pixels completion forced: " << resource->set_pixels_completion_forced; |
735 DCHECK_EQ(resource->exported_count, 0); | 730 DCHECK_EQ(resource->exported_count, 0); |
736 // Uninitialized! Call SetPixels or LockForWrite first. | 731 // Uninitialized! Call SetPixels or LockForWrite first. |
737 DCHECK(resource->allocated); | 732 DCHECK(resource->allocated); |
738 | 733 |
739 LazyCreate(resource); | 734 LazyCreate(resource); |
740 | 735 |
741 if (resource->external) { | 736 if (resource->external) { |
742 if (!resource->gl_id && resource->mailbox.IsTexture()) { | 737 if (!resource->gl_id && resource->mailbox.IsTexture()) { |
743 WebGraphicsContext3D* context3d = Context3d(); | 738 GLES2Interface* gl = ContextGL(); |
744 DCHECK(context3d); | 739 DCHECK(gl); |
745 if (resource->mailbox.sync_point()) { | 740 if (resource->mailbox.sync_point()) { |
746 GLC(context3d, | 741 GLC(gl, gl->WaitSyncPointCHROMIUM(resource->mailbox.sync_point())); |
747 context3d->waitSyncPoint(resource->mailbox.sync_point())); | |
748 resource->mailbox.ResetSyncPoint(); | 742 resource->mailbox.ResetSyncPoint(); |
749 } | 743 } |
750 resource->gl_id = texture_id_allocator_->NextId(); | 744 resource->gl_id = texture_id_allocator_->NextId(); |
751 GLC(context3d, context3d->bindTexture(resource->target, resource->gl_id)); | 745 GLC(gl, gl->BindTexture(resource->target, resource->gl_id)); |
752 GLC(context3d, | 746 GLC(gl, |
753 context3d->consumeTextureCHROMIUM(resource->target, | 747 gl->ConsumeTextureCHROMIUM(resource->target, |
754 resource->mailbox.data())); | 748 resource->mailbox.data())); |
755 } | 749 } |
756 } | 750 } |
757 | 751 |
758 resource->lock_for_read_count++; | 752 resource->lock_for_read_count++; |
759 if (resource->enable_read_lock_fences) | 753 if (resource->enable_read_lock_fences) |
760 resource->read_lock_fence = current_read_lock_fence_; | 754 resource->read_lock_fence = current_read_lock_fence_; |
761 | 755 |
762 return resource; | 756 return resource; |
763 } | 757 } |
764 | 758 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
929 default_resource_type_ = GLTexture; | 923 default_resource_type_ = GLTexture; |
930 | 924 |
931 const ContextProvider::Capabilities& caps = | 925 const ContextProvider::Capabilities& caps = |
932 output_surface_->context_provider()->ContextCapabilities(); | 926 output_surface_->context_provider()->ContextCapabilities(); |
933 | 927 |
934 bool use_bgra = caps.texture_format_bgra8888; | 928 bool use_bgra = caps.texture_format_bgra8888; |
935 use_texture_storage_ext_ = caps.texture_storage; | 929 use_texture_storage_ext_ = caps.texture_storage; |
936 use_texture_usage_hint_ = caps.texture_usage; | 930 use_texture_usage_hint_ = caps.texture_usage; |
937 use_compressed_texture_etc1_ = caps.texture_format_etc1; | 931 use_compressed_texture_etc1_ = caps.texture_format_etc1; |
938 | 932 |
939 WebGraphicsContext3D* context3d = Context3d(); | 933 GLES2Interface* gl = ContextGL(); |
940 DCHECK(context3d); | 934 DCHECK(gl); |
941 | 935 |
942 texture_uploader_ = TextureUploader::Create(context3d); | 936 texture_uploader_ = TextureUploader::Create(gl); |
943 max_texture_size_ = 0; // Context expects cleared value. | 937 max_texture_size_ = 0; // Context expects cleared value. |
944 | 938 GLC(gl, gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_)); |
945 GLC(context3d, context3d->getIntegerv(GL_MAX_TEXTURE_SIZE, | |
946 &max_texture_size_)); | |
947 best_texture_format_ = PlatformColor::BestTextureFormat(use_bgra); | 939 best_texture_format_ = PlatformColor::BestTextureFormat(use_bgra); |
948 | 940 |
949 texture_id_allocator_.reset( | 941 texture_id_allocator_.reset( |
950 new TextureIdAllocator(context3d, id_allocation_chunk_size_)); | 942 new TextureIdAllocator(gl, id_allocation_chunk_size_)); |
951 buffer_id_allocator_.reset( | 943 buffer_id_allocator_.reset( |
952 new BufferIdAllocator(context3d, id_allocation_chunk_size_)); | 944 new BufferIdAllocator(gl, id_allocation_chunk_size_)); |
953 | 945 |
954 return true; | 946 return true; |
955 } | 947 } |
956 | 948 |
957 void ResourceProvider::CleanUpGLIfNeeded() { | 949 void ResourceProvider::CleanUpGLIfNeeded() { |
958 WebGraphicsContext3D* context3d = Context3d(); | 950 GLES2Interface* gl = ContextGL(); |
959 if (default_resource_type_ != GLTexture) { | 951 if (default_resource_type_ != GLTexture) { |
960 // We are not in GL mode, but double check before returning. | 952 // We are not in GL mode, but double check before returning. |
961 DCHECK(!context3d); | 953 DCHECK(!gl); |
962 DCHECK(!texture_uploader_); | 954 DCHECK(!texture_uploader_); |
963 return; | 955 return; |
964 } | 956 } |
965 | 957 |
966 DCHECK(context3d); | 958 DCHECK(gl); |
967 texture_uploader_.reset(); | 959 texture_uploader_.reset(); |
968 texture_id_allocator_.reset(); | 960 texture_id_allocator_.reset(); |
969 buffer_id_allocator_.reset(); | 961 buffer_id_allocator_.reset(); |
970 Finish(); | 962 Finish(); |
971 } | 963 } |
972 | 964 |
973 int ResourceProvider::CreateChild(const ReturnCallback& return_callback) { | 965 int ResourceProvider::CreateChild(const ReturnCallback& return_callback) { |
974 DCHECK(thread_checker_.CalledOnValidThread()); | 966 DCHECK(thread_checker_.CalledOnValidThread()); |
975 | 967 |
976 Child child_info; | 968 Child child_info; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 DCHECK(thread_checker_.CalledOnValidThread()); | 1007 DCHECK(thread_checker_.CalledOnValidThread()); |
1016 ChildMap::const_iterator it = children_.find(child); | 1008 ChildMap::const_iterator it = children_.find(child); |
1017 DCHECK(it != children_.end()); | 1009 DCHECK(it != children_.end()); |
1018 DCHECK(!it->second.marked_for_deletion); | 1010 DCHECK(!it->second.marked_for_deletion); |
1019 return it->second.child_to_parent_map; | 1011 return it->second.child_to_parent_map; |
1020 } | 1012 } |
1021 | 1013 |
1022 void ResourceProvider::PrepareSendToParent(const ResourceIdArray& resources, | 1014 void ResourceProvider::PrepareSendToParent(const ResourceIdArray& resources, |
1023 TransferableResourceArray* list) { | 1015 TransferableResourceArray* list) { |
1024 DCHECK(thread_checker_.CalledOnValidThread()); | 1016 DCHECK(thread_checker_.CalledOnValidThread()); |
1025 WebGraphicsContext3D* context3d = Context3d(); | 1017 GLES2Interface* gl = ContextGL(); |
1026 bool need_sync_point = false; | 1018 bool need_sync_point = false; |
1027 for (ResourceIdArray::const_iterator it = resources.begin(); | 1019 for (ResourceIdArray::const_iterator it = resources.begin(); |
1028 it != resources.end(); | 1020 it != resources.end(); |
1029 ++it) { | 1021 ++it) { |
1030 TransferableResource resource; | 1022 TransferableResource resource; |
1031 TransferResource(context3d, *it, &resource); | 1023 TransferResource(gl, *it, &resource); |
1032 if (!resource.sync_point && !resource.is_software) | 1024 if (!resource.sync_point && !resource.is_software) |
1033 need_sync_point = true; | 1025 need_sync_point = true; |
1034 ++resources_.find(*it)->second.exported_count; | 1026 ++resources_.find(*it)->second.exported_count; |
1035 list->push_back(resource); | 1027 list->push_back(resource); |
1036 } | 1028 } |
1037 if (need_sync_point) { | 1029 if (need_sync_point) { |
1038 unsigned int sync_point = context3d->insertSyncPoint(); | 1030 GLuint sync_point = gl->InsertSyncPointCHROMIUM(); |
1039 for (TransferableResourceArray::iterator it = list->begin(); | 1031 for (TransferableResourceArray::iterator it = list->begin(); |
1040 it != list->end(); | 1032 it != list->end(); |
1041 ++it) { | 1033 ++it) { |
1042 if (!it->sync_point) | 1034 if (!it->sync_point) |
1043 it->sync_point = sync_point; | 1035 it->sync_point = sync_point; |
1044 } | 1036 } |
1045 } | 1037 } |
1046 } | 1038 } |
1047 | 1039 |
1048 void ResourceProvider::ReceiveFromChild( | 1040 void ResourceProvider::ReceiveFromChild( |
1049 int child, const TransferableResourceArray& resources) { | 1041 int child, const TransferableResourceArray& resources) { |
1050 DCHECK(thread_checker_.CalledOnValidThread()); | 1042 DCHECK(thread_checker_.CalledOnValidThread()); |
1051 WebGraphicsContext3D* context3d = Context3d(); | 1043 GLES2Interface* gl = ContextGL(); |
1052 Child& child_info = children_.find(child)->second; | 1044 Child& child_info = children_.find(child)->second; |
1053 DCHECK(!child_info.marked_for_deletion); | 1045 DCHECK(!child_info.marked_for_deletion); |
1054 for (TransferableResourceArray::const_iterator it = resources.begin(); | 1046 for (TransferableResourceArray::const_iterator it = resources.begin(); |
1055 it != resources.end(); | 1047 it != resources.end(); |
1056 ++it) { | 1048 ++it) { |
1057 ResourceIdMap::iterator resource_in_map_it = | 1049 ResourceIdMap::iterator resource_in_map_it = |
1058 child_info.child_to_parent_map.find(it->id); | 1050 child_info.child_to_parent_map.find(it->id); |
1059 if (resource_in_map_it != child_info.child_to_parent_map.end()) { | 1051 if (resource_in_map_it != child_info.child_to_parent_map.end()) { |
1060 resources_[resource_in_map_it->second].imported_count++; | 1052 resources_[resource_in_map_it->second].imported_count++; |
1061 continue; | 1053 continue; |
1062 } | 1054 } |
1063 | 1055 |
1064 scoped_ptr<SharedBitmap> bitmap; | 1056 scoped_ptr<SharedBitmap> bitmap; |
1065 uint8_t* pixels = NULL; | 1057 uint8_t* pixels = NULL; |
1066 if (it->is_software) { | 1058 if (it->is_software) { |
1067 if (shared_bitmap_manager_) | 1059 if (shared_bitmap_manager_) |
1068 bitmap = shared_bitmap_manager_->GetSharedBitmapFromId(it->size, | 1060 bitmap = shared_bitmap_manager_->GetSharedBitmapFromId(it->size, |
1069 it->mailbox); | 1061 it->mailbox); |
1070 if (bitmap) | 1062 if (bitmap) |
1071 pixels = bitmap->pixels(); | 1063 pixels = bitmap->pixels(); |
1072 } | 1064 } |
1073 | 1065 |
1074 if ((!it->is_software && !context3d) || (it->is_software && !pixels)) { | 1066 if ((!it->is_software && !gl) || (it->is_software && !pixels)) { |
1075 TRACE_EVENT0("cc", "ResourceProvider::ReceiveFromChild dropping invalid"); | 1067 TRACE_EVENT0("cc", "ResourceProvider::ReceiveFromChild dropping invalid"); |
1076 ReturnedResourceArray to_return; | 1068 ReturnedResourceArray to_return; |
1077 to_return.push_back(it->ToReturnedResource()); | 1069 to_return.push_back(it->ToReturnedResource()); |
1078 child_info.return_callback.Run(to_return); | 1070 child_info.return_callback.Run(to_return); |
1079 continue; | 1071 continue; |
1080 } | 1072 } |
1081 | 1073 |
1082 ResourceId local_id = next_id_++; | 1074 ResourceId local_id = next_id_++; |
1083 Resource& resource = resources_[local_id]; | 1075 Resource& resource = resources_[local_id]; |
1084 if (it->is_software) { | 1076 if (it->is_software) { |
1085 resource = Resource( | 1077 resource = Resource( |
1086 pixels, bitmap.release(), it->size, GL_LINEAR, GL_CLAMP_TO_EDGE); | 1078 pixels, bitmap.release(), it->size, GL_LINEAR, GL_CLAMP_TO_EDGE); |
1087 } else { | 1079 } else { |
1088 unsigned texture_id; | 1080 GLuint texture_id; |
1089 // NOTE: If the parent is a browser and the child a renderer, the parent | 1081 // NOTE: If the parent is a browser and the child a renderer, the parent |
1090 // is not supposed to have its context wait, because that could induce | 1082 // is not supposed to have its context wait, because that could induce |
1091 // deadlocks and/or security issues. The caller is responsible for | 1083 // deadlocks and/or security issues. The caller is responsible for |
1092 // waiting asynchronously, and resetting sync_point before calling this. | 1084 // waiting asynchronously, and resetting sync_point before calling this. |
1093 // However if the parent is a renderer (e.g. browser tag), it may be ok | 1085 // However if the parent is a renderer (e.g. browser tag), it may be ok |
1094 // (and is simpler) to wait. | 1086 // (and is simpler) to wait. |
1095 if (it->sync_point) | 1087 if (it->sync_point) |
1096 GLC(context3d, context3d->waitSyncPoint(it->sync_point)); | 1088 GLC(gl, gl->WaitSyncPointCHROMIUM(it->sync_point)); |
1097 texture_id = texture_id_allocator_->NextId(); | 1089 texture_id = texture_id_allocator_->NextId(); |
1098 GLC(context3d, context3d->bindTexture(it->target, texture_id)); | 1090 GLC(gl, gl->BindTexture(it->target, texture_id)); |
1099 GLC(context3d, | 1091 GLC(gl, gl->ConsumeTextureCHROMIUM(it->target, it->mailbox.name)); |
1100 context3d->consumeTextureCHROMIUM(it->target, it->mailbox.name)); | |
1101 resource = Resource(texture_id, | 1092 resource = Resource(texture_id, |
1102 it->size, | 1093 it->size, |
1103 it->target, | 1094 it->target, |
1104 it->filter, | 1095 it->filter, |
1105 0, | 1096 0, |
1106 GL_CLAMP_TO_EDGE, | 1097 GL_CLAMP_TO_EDGE, |
1107 TextureUsageAny, | 1098 TextureUsageAny, |
1108 it->format); | 1099 it->format); |
1109 resource.mailbox.SetName(it->mailbox); | 1100 resource.mailbox.SetName(it->mailbox); |
1110 } | 1101 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1156 const ResourceMap::iterator& a_it = a.second; | 1147 const ResourceMap::iterator& a_it = a.second; |
1157 const ResourceMap::iterator& b_it = b.second; | 1148 const ResourceMap::iterator& b_it = b.second; |
1158 const Resource& a_resource = a_it->second; | 1149 const Resource& a_resource = a_it->second; |
1159 const Resource& b_resource = b_it->second; | 1150 const Resource& b_resource = b_it->second; |
1160 return a_resource.child_id < b_resource.child_id; | 1151 return a_resource.child_id < b_resource.child_id; |
1161 } | 1152 } |
1162 | 1153 |
1163 void ResourceProvider::ReceiveReturnsFromParent( | 1154 void ResourceProvider::ReceiveReturnsFromParent( |
1164 const ReturnedResourceArray& resources) { | 1155 const ReturnedResourceArray& resources) { |
1165 DCHECK(thread_checker_.CalledOnValidThread()); | 1156 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1157 GLES2Interface* gl = ContextGL(); |
1166 | 1158 |
1167 int child_id = 0; | 1159 int child_id = 0; |
1168 ResourceIdArray resources_for_child; | 1160 ResourceIdArray resources_for_child; |
1169 | 1161 |
1170 std::vector<std::pair<ReturnedResource, ResourceMap::iterator> > | 1162 std::vector<std::pair<ReturnedResource, ResourceMap::iterator> > |
1171 sorted_resources; | 1163 sorted_resources; |
1172 | 1164 |
1173 for (ReturnedResourceArray::const_iterator it = resources.begin(); | 1165 for (ReturnedResourceArray::const_iterator it = resources.begin(); |
1174 it != resources.end(); | 1166 it != resources.end(); |
1175 ++it) { | 1167 ++it) { |
1176 ResourceId local_id = it->id; | 1168 ResourceId local_id = it->id; |
1177 ResourceMap::iterator map_iterator = resources_.find(local_id); | 1169 ResourceMap::iterator map_iterator = resources_.find(local_id); |
1178 | 1170 |
1179 // Resource was already lost (e.g. it belonged to a child that was | 1171 // Resource was already lost (e.g. it belonged to a child that was |
1180 // destroyed). | 1172 // destroyed). |
1181 if (map_iterator == resources_.end()) | 1173 if (map_iterator == resources_.end()) |
1182 continue; | 1174 continue; |
1183 | 1175 |
1184 sorted_resources.push_back( | 1176 sorted_resources.push_back( |
1185 std::pair<ReturnedResource, ResourceMap::iterator>(*it, map_iterator)); | 1177 std::pair<ReturnedResource, ResourceMap::iterator>(*it, map_iterator)); |
1186 } | 1178 } |
1187 | 1179 |
1188 std::sort(sorted_resources.begin(), | 1180 std::sort(sorted_resources.begin(), |
1189 sorted_resources.end(), | 1181 sorted_resources.end(), |
1190 CompareResourceMapIteratorsByChildId); | 1182 CompareResourceMapIteratorsByChildId); |
1191 | 1183 |
1192 WebGraphicsContext3D* context3d = Context3d(); | |
1193 ChildMap::iterator child_it = children_.end(); | 1184 ChildMap::iterator child_it = children_.end(); |
1194 for (size_t i = 0; i < sorted_resources.size(); ++i) { | 1185 for (size_t i = 0; i < sorted_resources.size(); ++i) { |
1195 ReturnedResource& returned = sorted_resources[i].first; | 1186 ReturnedResource& returned = sorted_resources[i].first; |
1196 ResourceMap::iterator& map_iterator = sorted_resources[i].second; | 1187 ResourceMap::iterator& map_iterator = sorted_resources[i].second; |
1197 ResourceId local_id = map_iterator->first; | 1188 ResourceId local_id = map_iterator->first; |
1198 Resource* resource = &map_iterator->second; | 1189 Resource* resource = &map_iterator->second; |
1199 | 1190 |
1200 CHECK_GE(resource->exported_count, returned.count); | 1191 CHECK_GE(resource->exported_count, returned.count); |
1201 resource->exported_count -= returned.count; | 1192 resource->exported_count -= returned.count; |
1202 resource->lost |= returned.lost; | 1193 resource->lost |= returned.lost; |
1203 if (resource->exported_count) | 1194 if (resource->exported_count) |
1204 continue; | 1195 continue; |
1205 | 1196 |
1206 if (resource->gl_id) { | 1197 if (resource->gl_id) { |
1207 if (returned.sync_point) | 1198 if (returned.sync_point) |
1208 GLC(context3d, context3d->waitSyncPoint(returned.sync_point)); | 1199 GLC(gl, gl->WaitSyncPointCHROMIUM(returned.sync_point)); |
1209 } else if (!resource->shared_bitmap) { | 1200 } else if (!resource->shared_bitmap) { |
1210 resource->mailbox = | 1201 resource->mailbox = |
1211 TextureMailbox(resource->mailbox.name(), returned.sync_point); | 1202 TextureMailbox(resource->mailbox.name(), returned.sync_point); |
1212 } | 1203 } |
1213 | 1204 |
1214 if (!resource->marked_for_deletion) | 1205 if (!resource->marked_for_deletion) |
1215 continue; | 1206 continue; |
1216 | 1207 |
1217 if (!resource->child_id) { | 1208 if (!resource->child_id) { |
1218 // The resource belongs to this ResourceProvider, so it can be destroyed. | 1209 // The resource belongs to this ResourceProvider, so it can be destroyed. |
(...skipping 19 matching lines...) Expand all Loading... |
1238 } | 1229 } |
1239 | 1230 |
1240 if (child_id) { | 1231 if (child_id) { |
1241 DCHECK_NE(resources_for_child.size(), 0u); | 1232 DCHECK_NE(resources_for_child.size(), 0u); |
1242 DCHECK(child_it != children_.end()); | 1233 DCHECK(child_it != children_.end()); |
1243 DeleteAndReturnUnusedResourcesToChild( | 1234 DeleteAndReturnUnusedResourcesToChild( |
1244 child_it, Normal, resources_for_child); | 1235 child_it, Normal, resources_for_child); |
1245 } | 1236 } |
1246 } | 1237 } |
1247 | 1238 |
1248 void ResourceProvider::TransferResource(WebGraphicsContext3D* context, | 1239 void ResourceProvider::TransferResource(GLES2Interface* gl, |
1249 ResourceId id, | 1240 ResourceId id, |
1250 TransferableResource* resource) { | 1241 TransferableResource* resource) { |
1251 Resource* source = GetResource(id); | 1242 Resource* source = GetResource(id); |
1252 DCHECK(!source->locked_for_write); | 1243 DCHECK(!source->locked_for_write); |
1253 DCHECK(!source->lock_for_read_count); | 1244 DCHECK(!source->lock_for_read_count); |
1254 DCHECK(!source->external || (source->external && source->mailbox.IsValid())); | 1245 DCHECK(!source->external || (source->external && source->mailbox.IsValid())); |
1255 DCHECK(source->allocated); | 1246 DCHECK(source->allocated); |
1256 DCHECK_EQ(source->wrap_mode, GL_CLAMP_TO_EDGE); | 1247 DCHECK_EQ(source->wrap_mode, GL_CLAMP_TO_EDGE); |
1257 resource->id = id; | 1248 resource->id = id; |
1258 resource->format = source->format; | 1249 resource->format = source->format; |
1259 resource->target = source->target; | 1250 resource->target = source->target; |
1260 resource->filter = source->filter; | 1251 resource->filter = source->filter; |
1261 resource->size = source->size; | 1252 resource->size = source->size; |
1262 | 1253 |
1263 if (source->shared_bitmap) { | 1254 if (source->shared_bitmap) { |
1264 resource->mailbox = source->shared_bitmap->id(); | 1255 resource->mailbox = source->shared_bitmap->id(); |
1265 resource->is_software = true; | 1256 resource->is_software = true; |
1266 } else if (!source->mailbox.IsValid()) { | 1257 } else if (!source->mailbox.IsValid()) { |
1267 // This is a resource allocated by the compositor, we need to produce it. | 1258 // This is a resource allocated by the compositor, we need to produce it. |
1268 // Don't set a sync point, the caller will do it. | 1259 // Don't set a sync point, the caller will do it. |
1269 DCHECK(source->gl_id); | 1260 DCHECK(source->gl_id); |
1270 GLC(context, context->bindTexture(resource->target, source->gl_id)); | 1261 GLC(gl, gl->BindTexture(resource->target, source->gl_id)); |
1271 GLC(context, context->genMailboxCHROMIUM(resource->mailbox.name)); | 1262 GLC(gl, gl->GenMailboxCHROMIUM(resource->mailbox.name)); |
1272 GLC(context, | 1263 GLC(gl, |
1273 context->produceTextureCHROMIUM(resource->target, | 1264 gl->ProduceTextureCHROMIUM(resource->target, resource->mailbox.name)); |
1274 resource->mailbox.name)); | |
1275 source->mailbox.SetName(resource->mailbox); | 1265 source->mailbox.SetName(resource->mailbox); |
1276 } else { | 1266 } else { |
1277 DCHECK(source->mailbox.IsTexture()); | 1267 DCHECK(source->mailbox.IsTexture()); |
1278 // This is either an external resource, or a compositor resource that we | 1268 // This is either an external resource, or a compositor resource that we |
1279 // already exported. Make sure to forward the sync point that we were given. | 1269 // already exported. Make sure to forward the sync point that we were given. |
1280 resource->mailbox = source->mailbox.name(); | 1270 resource->mailbox = source->mailbox.name(); |
1281 resource->sync_point = source->mailbox.sync_point(); | 1271 resource->sync_point = source->mailbox.sync_point(); |
1282 source->mailbox.ResetSyncPoint(); | 1272 source->mailbox.ResetSyncPoint(); |
1283 } | 1273 } |
1284 } | 1274 } |
1285 | 1275 |
1286 void ResourceProvider::DeleteAndReturnUnusedResourcesToChild( | 1276 void ResourceProvider::DeleteAndReturnUnusedResourcesToChild( |
1287 ChildMap::iterator child_it, | 1277 ChildMap::iterator child_it, |
1288 DeleteStyle style, | 1278 DeleteStyle style, |
1289 const ResourceIdArray& unused) { | 1279 const ResourceIdArray& unused) { |
1290 DCHECK(thread_checker_.CalledOnValidThread()); | 1280 DCHECK(thread_checker_.CalledOnValidThread()); |
1291 DCHECK(child_it != children_.end()); | 1281 DCHECK(child_it != children_.end()); |
1292 Child* child_info = &child_it->second; | 1282 Child* child_info = &child_it->second; |
1293 | 1283 |
1294 if (unused.empty() && !child_info->marked_for_deletion) | 1284 if (unused.empty() && !child_info->marked_for_deletion) |
1295 return; | 1285 return; |
1296 | 1286 |
1297 | |
1298 ReturnedResourceArray to_return; | 1287 ReturnedResourceArray to_return; |
1299 | 1288 |
1300 WebGraphicsContext3D* context3d = Context3d(); | 1289 GLES2Interface* gl = ContextGL(); |
1301 bool need_sync_point = false; | 1290 bool need_sync_point = false; |
1302 for (size_t i = 0; i < unused.size(); ++i) { | 1291 for (size_t i = 0; i < unused.size(); ++i) { |
1303 ResourceId local_id = unused[i]; | 1292 ResourceId local_id = unused[i]; |
1304 | 1293 |
1305 ResourceMap::iterator it = resources_.find(local_id); | 1294 ResourceMap::iterator it = resources_.find(local_id); |
1306 CHECK(it != resources_.end()); | 1295 CHECK(it != resources_.end()); |
1307 Resource& resource = it->second; | 1296 Resource& resource = it->second; |
1308 | 1297 |
1309 DCHECK(!resource.locked_for_write); | 1298 DCHECK(!resource.locked_for_write); |
1310 DCHECK(!resource.lock_for_read_count); | 1299 DCHECK(!resource.lock_for_read_count); |
1311 DCHECK_EQ(0u, child_info->in_use_resources.count(local_id)); | 1300 DCHECK_EQ(0u, child_info->in_use_resources.count(local_id)); |
1312 DCHECK(child_info->parent_to_child_map.count(local_id)); | 1301 DCHECK(child_info->parent_to_child_map.count(local_id)); |
1313 | 1302 |
1314 ResourceId child_id = child_info->parent_to_child_map[local_id]; | 1303 ResourceId child_id = child_info->parent_to_child_map[local_id]; |
1315 DCHECK(child_info->child_to_parent_map.count(child_id)); | 1304 DCHECK(child_info->child_to_parent_map.count(child_id)); |
1316 | 1305 |
1317 bool is_lost = | 1306 bool is_lost = |
1318 resource.lost || (!resource.shared_bitmap && lost_output_surface_); | 1307 resource.lost || (!resource.shared_bitmap && lost_output_surface_); |
1319 if (resource.exported_count > 0) { | 1308 if (resource.exported_count > 0) { |
1320 if (style != ForShutdown) { | 1309 if (style != ForShutdown) { |
1321 // Defer this until we receive the resource back from the parent. | 1310 // Defer this until we receive the resource back from the parent. |
1322 resource.marked_for_deletion = true; | 1311 resource.marked_for_deletion = true; |
1323 continue; | 1312 continue; |
1324 } | 1313 } |
1325 | 1314 |
1326 // We still have an exported_count, so we'll have to lose it. | 1315 // We still have an exported_count, so we'll have to lose it. |
1327 is_lost = true; | 1316 is_lost = true; |
1328 } | 1317 } |
1329 | 1318 |
1330 if (context3d && resource.filter != resource.original_filter) { | 1319 if (gl && resource.filter != resource.original_filter) { |
1331 DCHECK(resource.target); | 1320 DCHECK(resource.target); |
1332 DCHECK(resource.gl_id); | 1321 DCHECK(resource.gl_id); |
1333 | 1322 |
1334 GLC(context3d, context3d->bindTexture(resource.target, resource.gl_id)); | 1323 GLC(gl, gl->BindTexture(resource.target, resource.gl_id)); |
1335 GLC(context3d, | 1324 GLC(gl, |
1336 context3d->texParameteri(resource.target, | 1325 gl->TexParameteri(resource.target, |
1337 GL_TEXTURE_MIN_FILTER, | 1326 GL_TEXTURE_MIN_FILTER, |
1338 resource.original_filter)); | 1327 resource.original_filter)); |
1339 GLC(context3d, | 1328 GLC(gl, |
1340 context3d->texParameteri(resource.target, | 1329 gl->TexParameteri(resource.target, |
1341 GL_TEXTURE_MAG_FILTER, | 1330 GL_TEXTURE_MAG_FILTER, |
1342 resource.original_filter)); | 1331 resource.original_filter)); |
1343 } | 1332 } |
1344 | 1333 |
1345 ReturnedResource returned; | 1334 ReturnedResource returned; |
1346 returned.id = child_id; | 1335 returned.id = child_id; |
1347 returned.sync_point = resource.mailbox.sync_point(); | 1336 returned.sync_point = resource.mailbox.sync_point(); |
1348 if (!returned.sync_point && !resource.shared_bitmap) | 1337 if (!returned.sync_point && !resource.shared_bitmap) |
1349 need_sync_point = true; | 1338 need_sync_point = true; |
1350 returned.count = resource.imported_count; | 1339 returned.count = resource.imported_count; |
1351 returned.lost = is_lost; | 1340 returned.lost = is_lost; |
1352 to_return.push_back(returned); | 1341 to_return.push_back(returned); |
1353 | 1342 |
1354 child_info->parent_to_child_map.erase(local_id); | 1343 child_info->parent_to_child_map.erase(local_id); |
1355 child_info->child_to_parent_map.erase(child_id); | 1344 child_info->child_to_parent_map.erase(child_id); |
1356 resource.imported_count = 0; | 1345 resource.imported_count = 0; |
1357 DeleteResourceInternal(it, style); | 1346 DeleteResourceInternal(it, style); |
1358 } | 1347 } |
1359 if (need_sync_point) { | 1348 if (need_sync_point) { |
1360 DCHECK(context3d); | 1349 DCHECK(gl); |
1361 unsigned int sync_point = context3d->insertSyncPoint(); | 1350 GLuint sync_point = gl->InsertSyncPointCHROMIUM(); |
1362 for (size_t i = 0; i < to_return.size(); ++i) { | 1351 for (size_t i = 0; i < to_return.size(); ++i) { |
1363 if (!to_return[i].sync_point) | 1352 if (!to_return[i].sync_point) |
1364 to_return[i].sync_point = sync_point; | 1353 to_return[i].sync_point = sync_point; |
1365 } | 1354 } |
1366 } | 1355 } |
1367 | 1356 |
1368 if (!to_return.empty()) | 1357 if (!to_return.empty()) |
1369 child_info->return_callback.Run(to_return); | 1358 child_info->return_callback.Run(to_return); |
1370 | 1359 |
1371 if (child_info->marked_for_deletion && | 1360 if (child_info->marked_for_deletion && |
1372 child_info->parent_to_child_map.empty()) { | 1361 child_info->parent_to_child_map.empty()) { |
1373 DCHECK(child_info->child_to_parent_map.empty()); | 1362 DCHECK(child_info->child_to_parent_map.empty()); |
1374 children_.erase(child_it); | 1363 children_.erase(child_it); |
1375 } | 1364 } |
1376 } | 1365 } |
1377 | 1366 |
1378 void ResourceProvider::AcquirePixelBuffer(ResourceId id) { | 1367 void ResourceProvider::AcquirePixelBuffer(ResourceId id) { |
1379 Resource* resource = GetResource(id); | 1368 Resource* resource = GetResource(id); |
1380 DCHECK(!resource->external); | 1369 DCHECK(!resource->external); |
1381 DCHECK_EQ(resource->exported_count, 0); | 1370 DCHECK_EQ(resource->exported_count, 0); |
1382 DCHECK(!resource->image_id); | 1371 DCHECK(!resource->image_id); |
1383 DCHECK_NE(ETC1, resource->format); | 1372 DCHECK_NE(ETC1, resource->format); |
1384 | 1373 |
1385 if (resource->type == GLTexture) { | 1374 if (resource->type == GLTexture) { |
1386 WebGraphicsContext3D* context3d = Context3d(); | 1375 GLES2Interface* gl = ContextGL(); |
1387 DCHECK(context3d); | 1376 DCHECK(gl); |
1388 if (!resource->gl_pixel_buffer_id) | 1377 if (!resource->gl_pixel_buffer_id) |
1389 resource->gl_pixel_buffer_id = buffer_id_allocator_->NextId(); | 1378 resource->gl_pixel_buffer_id = buffer_id_allocator_->NextId(); |
1390 context3d->bindBuffer( | 1379 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, |
1391 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, | 1380 resource->gl_pixel_buffer_id); |
1392 resource->gl_pixel_buffer_id); | |
1393 unsigned bytes_per_pixel = BitsPerPixel(resource->format) / 8; | 1381 unsigned bytes_per_pixel = BitsPerPixel(resource->format) / 8; |
1394 context3d->bufferData( | 1382 gl->BufferData(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, |
1395 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, | 1383 resource->size.height() * |
1396 resource->size.height() * RoundUp(bytes_per_pixel | 1384 RoundUp(bytes_per_pixel * resource->size.width(), 4u), |
1397 * resource->size.width(), 4u), | 1385 NULL, |
1398 NULL, | 1386 GL_DYNAMIC_DRAW); |
1399 GL_DYNAMIC_DRAW); | 1387 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); |
1400 context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); | |
1401 } | 1388 } |
1402 | 1389 |
1403 if (resource->pixels) { | 1390 if (resource->pixels) { |
1404 if (resource->pixel_buffer) | 1391 if (resource->pixel_buffer) |
1405 return; | 1392 return; |
1406 | 1393 |
1407 resource->pixel_buffer = new uint8_t[4 * resource->size.GetArea()]; | 1394 resource->pixel_buffer = new uint8_t[4 * resource->size.GetArea()]; |
1408 } | 1395 } |
1409 } | 1396 } |
1410 | 1397 |
(...skipping 11 matching lines...) Expand all Loading... |
1422 // as each new query has a unique submit count. | 1409 // as each new query has a unique submit count. |
1423 if (resource->pending_set_pixels) { | 1410 if (resource->pending_set_pixels) { |
1424 DCHECK(resource->set_pixels_completion_forced); | 1411 DCHECK(resource->set_pixels_completion_forced); |
1425 resource->pending_set_pixels = false; | 1412 resource->pending_set_pixels = false; |
1426 UnlockForWrite(id); | 1413 UnlockForWrite(id); |
1427 } | 1414 } |
1428 | 1415 |
1429 if (resource->type == GLTexture) { | 1416 if (resource->type == GLTexture) { |
1430 if (!resource->gl_pixel_buffer_id) | 1417 if (!resource->gl_pixel_buffer_id) |
1431 return; | 1418 return; |
1432 WebGraphicsContext3D* context3d = Context3d(); | 1419 GLES2Interface* gl = ContextGL(); |
1433 DCHECK(context3d); | 1420 DCHECK(gl); |
1434 context3d->bindBuffer( | 1421 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, |
1435 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, | 1422 resource->gl_pixel_buffer_id); |
1436 resource->gl_pixel_buffer_id); | 1423 gl->BufferData( |
1437 context3d->bufferData( | 1424 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0, NULL, GL_DYNAMIC_DRAW); |
1438 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, | 1425 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); |
1439 0, | |
1440 NULL, | |
1441 GL_DYNAMIC_DRAW); | |
1442 context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); | |
1443 } | 1426 } |
1444 | 1427 |
1445 if (resource->pixels) { | 1428 if (resource->pixels) { |
1446 if (!resource->pixel_buffer) | 1429 if (!resource->pixel_buffer) |
1447 return; | 1430 return; |
1448 delete[] resource->pixel_buffer; | 1431 delete[] resource->pixel_buffer; |
1449 resource->pixel_buffer = NULL; | 1432 resource->pixel_buffer = NULL; |
1450 } | 1433 } |
1451 } | 1434 } |
1452 | 1435 |
1453 uint8_t* ResourceProvider::MapPixelBuffer(ResourceId id) { | 1436 uint8_t* ResourceProvider::MapPixelBuffer(ResourceId id) { |
1454 Resource* resource = GetResource(id); | 1437 Resource* resource = GetResource(id); |
1455 DCHECK(!resource->external); | 1438 DCHECK(!resource->external); |
1456 DCHECK_EQ(resource->exported_count, 0); | 1439 DCHECK_EQ(resource->exported_count, 0); |
1457 DCHECK(!resource->image_id); | 1440 DCHECK(!resource->image_id); |
1458 | 1441 |
1459 if (resource->type == GLTexture) { | 1442 if (resource->type == GLTexture) { |
1460 WebGraphicsContext3D* context3d = Context3d(); | 1443 GLES2Interface* gl = ContextGL(); |
1461 DCHECK(context3d); | 1444 DCHECK(gl); |
1462 DCHECK(resource->gl_pixel_buffer_id); | 1445 DCHECK(resource->gl_pixel_buffer_id); |
1463 context3d->bindBuffer( | 1446 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, |
1464 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, | 1447 resource->gl_pixel_buffer_id); |
1465 resource->gl_pixel_buffer_id); | 1448 uint8_t* image = static_cast<uint8_t*>(gl->MapBufferCHROMIUM( |
1466 uint8_t* image = static_cast<uint8_t*>( | 1449 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, GL_WRITE_ONLY)); |
1467 context3d->mapBufferCHROMIUM( | 1450 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); |
1468 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, GL_WRITE_ONLY)); | |
1469 context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); | |
1470 // Buffer is required to be 4-byte aligned. | 1451 // Buffer is required to be 4-byte aligned. |
1471 CHECK(!(reinterpret_cast<intptr_t>(image) & 3)); | 1452 CHECK(!(reinterpret_cast<intptr_t>(image) & 3)); |
1472 return image; | 1453 return image; |
1473 } | 1454 } |
1474 | 1455 |
1475 if (resource->pixels) | 1456 if (resource->pixels) |
1476 return resource->pixel_buffer; | 1457 return resource->pixel_buffer; |
1477 | 1458 |
1478 return NULL; | 1459 return NULL; |
1479 } | 1460 } |
1480 | 1461 |
1481 void ResourceProvider::UnmapPixelBuffer(ResourceId id) { | 1462 void ResourceProvider::UnmapPixelBuffer(ResourceId id) { |
1482 Resource* resource = GetResource(id); | 1463 Resource* resource = GetResource(id); |
1483 DCHECK(!resource->external); | 1464 DCHECK(!resource->external); |
1484 DCHECK_EQ(resource->exported_count, 0); | 1465 DCHECK_EQ(resource->exported_count, 0); |
1485 DCHECK(!resource->image_id); | 1466 DCHECK(!resource->image_id); |
1486 | 1467 |
1487 if (resource->type == GLTexture) { | 1468 if (resource->type == GLTexture) { |
1488 WebGraphicsContext3D* context3d = Context3d(); | 1469 GLES2Interface* gl = ContextGL(); |
1489 DCHECK(context3d); | 1470 DCHECK(gl); |
1490 DCHECK(resource->gl_pixel_buffer_id); | 1471 DCHECK(resource->gl_pixel_buffer_id); |
1491 context3d->bindBuffer( | 1472 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, |
1492 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, | 1473 resource->gl_pixel_buffer_id); |
1493 resource->gl_pixel_buffer_id); | 1474 gl->UnmapBufferCHROMIUM(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM); |
1494 context3d->unmapBufferCHROMIUM(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM); | 1475 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); |
1495 context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); | |
1496 } | 1476 } |
1497 } | 1477 } |
1498 | 1478 |
1499 GLenum ResourceProvider::BindForSampling( | 1479 GLenum ResourceProvider::BindForSampling( |
1500 ResourceProvider::ResourceId resource_id, | 1480 ResourceProvider::ResourceId resource_id, |
1501 GLenum unit, | 1481 GLenum unit, |
1502 GLenum filter) { | 1482 GLenum filter) { |
1503 DCHECK(thread_checker_.CalledOnValidThread()); | 1483 DCHECK(thread_checker_.CalledOnValidThread()); |
1504 WebGraphicsContext3D* context3d = Context3d(); | 1484 GLES2Interface* gl = ContextGL(); |
1505 ResourceMap::iterator it = resources_.find(resource_id); | 1485 ResourceMap::iterator it = resources_.find(resource_id); |
1506 DCHECK(it != resources_.end()); | 1486 DCHECK(it != resources_.end()); |
1507 Resource* resource = &it->second; | 1487 Resource* resource = &it->second; |
1508 DCHECK(resource->lock_for_read_count); | 1488 DCHECK(resource->lock_for_read_count); |
1509 DCHECK(!resource->locked_for_write || resource->set_pixels_completion_forced); | 1489 DCHECK(!resource->locked_for_write || resource->set_pixels_completion_forced); |
1510 | 1490 |
1511 ScopedSetActiveTexture scoped_active_tex(context3d, unit); | 1491 ScopedSetActiveTexture scoped_active_tex(gl, unit); |
1512 GLenum target = resource->target; | 1492 GLenum target = resource->target; |
1513 GLC(context3d, context3d->bindTexture(target, resource->gl_id)); | 1493 GLC(gl, gl->BindTexture(target, resource->gl_id)); |
1514 if (filter != resource->filter) { | 1494 if (filter != resource->filter) { |
1515 GLC(context3d, | 1495 GLC(gl, gl->TexParameteri(target, GL_TEXTURE_MIN_FILTER, filter)); |
1516 context3d->texParameteri(target, GL_TEXTURE_MIN_FILTER, filter)); | 1496 GLC(gl, gl->TexParameteri(target, GL_TEXTURE_MAG_FILTER, filter)); |
1517 GLC(context3d, | |
1518 context3d->texParameteri(target, GL_TEXTURE_MAG_FILTER, filter)); | |
1519 resource->filter = filter; | 1497 resource->filter = filter; |
1520 } | 1498 } |
1521 | 1499 |
1522 if (resource->image_id && resource->dirty_image) { | 1500 if (resource->image_id && resource->dirty_image) { |
1523 // Release image currently bound to texture. | 1501 // Release image currently bound to texture. |
1524 if (resource->bound_image_id) | 1502 if (resource->bound_image_id) |
1525 context3d->releaseTexImage2DCHROMIUM(target, resource->bound_image_id); | 1503 gl->ReleaseTexImage2DCHROMIUM(target, resource->bound_image_id); |
1526 context3d->bindTexImage2DCHROMIUM(target, resource->image_id); | 1504 gl->BindTexImage2DCHROMIUM(target, resource->image_id); |
1527 resource->bound_image_id = resource->image_id; | 1505 resource->bound_image_id = resource->image_id; |
1528 resource->dirty_image = false; | 1506 resource->dirty_image = false; |
1529 } | 1507 } |
1530 | 1508 |
1531 return target; | 1509 return target; |
1532 } | 1510 } |
1533 | 1511 |
1534 void ResourceProvider::BeginSetPixels(ResourceId id) { | 1512 void ResourceProvider::BeginSetPixels(ResourceId id) { |
1535 Resource* resource = GetResource(id); | 1513 Resource* resource = GetResource(id); |
1536 DCHECK(!resource->pending_set_pixels); | 1514 DCHECK(!resource->pending_set_pixels); |
1537 | 1515 |
1538 LazyCreate(resource); | 1516 LazyCreate(resource); |
1539 DCHECK(resource->gl_id || resource->allocated); | 1517 DCHECK(resource->gl_id || resource->allocated); |
1540 DCHECK(ReadLockFenceHasPassed(resource)); | 1518 DCHECK(ReadLockFenceHasPassed(resource)); |
1541 DCHECK(!resource->image_id); | 1519 DCHECK(!resource->image_id); |
1542 | 1520 |
1543 bool allocate = !resource->allocated; | 1521 bool allocate = !resource->allocated; |
1544 resource->allocated = true; | 1522 resource->allocated = true; |
1545 LockForWrite(id); | 1523 LockForWrite(id); |
1546 | 1524 |
1547 if (resource->gl_id) { | 1525 if (resource->gl_id) { |
1548 WebGraphicsContext3D* context3d = Context3d(); | 1526 GLES2Interface* gl = ContextGL(); |
1549 DCHECK(context3d); | 1527 DCHECK(gl); |
1550 DCHECK(resource->gl_pixel_buffer_id); | 1528 DCHECK(resource->gl_pixel_buffer_id); |
1551 DCHECK_EQ(resource->target, static_cast<GLenum>(GL_TEXTURE_2D)); | 1529 DCHECK_EQ(resource->target, static_cast<GLenum>(GL_TEXTURE_2D)); |
1552 context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id); | 1530 gl->BindTexture(GL_TEXTURE_2D, resource->gl_id); |
1553 context3d->bindBuffer( | 1531 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, |
1554 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, | 1532 resource->gl_pixel_buffer_id); |
1555 resource->gl_pixel_buffer_id); | |
1556 if (!resource->gl_upload_query_id) | 1533 if (!resource->gl_upload_query_id) |
1557 resource->gl_upload_query_id = context3d->createQueryEXT(); | 1534 gl->GenQueriesEXT(1, &resource->gl_upload_query_id); |
1558 context3d->beginQueryEXT( | 1535 gl->BeginQueryEXT(GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM, |
1559 GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM, | 1536 resource->gl_upload_query_id); |
1560 resource->gl_upload_query_id); | |
1561 if (allocate) { | 1537 if (allocate) { |
1562 context3d->asyncTexImage2DCHROMIUM( | 1538 gl->AsyncTexImage2DCHROMIUM(GL_TEXTURE_2D, |
1563 GL_TEXTURE_2D, | 1539 0, /* level */ |
1564 0, /* level */ | 1540 GLInternalFormat(resource->format), |
1565 GLInternalFormat(resource->format), | 1541 resource->size.width(), |
1566 resource->size.width(), | 1542 resource->size.height(), |
1567 resource->size.height(), | 1543 0, /* border */ |
1568 0, /* border */ | 1544 GLDataFormat(resource->format), |
1569 GLDataFormat(resource->format), | 1545 GLDataType(resource->format), |
1570 GLDataType(resource->format), | 1546 NULL); |
1571 NULL); | |
1572 } else { | 1547 } else { |
1573 context3d->asyncTexSubImage2DCHROMIUM( | 1548 gl->AsyncTexSubImage2DCHROMIUM(GL_TEXTURE_2D, |
1574 GL_TEXTURE_2D, | 1549 0, /* level */ |
1575 0, /* level */ | 1550 0, /* x */ |
1576 0, /* x */ | 1551 0, /* y */ |
1577 0, /* y */ | 1552 resource->size.width(), |
1578 resource->size.width(), | 1553 resource->size.height(), |
1579 resource->size.height(), | 1554 GLDataFormat(resource->format), |
1580 GLDataFormat(resource->format), | 1555 GLDataType(resource->format), |
1581 GLDataType(resource->format), | 1556 NULL); |
1582 NULL); | |
1583 } | 1557 } |
1584 context3d->endQueryEXT(GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM); | 1558 gl->EndQueryEXT(GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM); |
1585 context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); | 1559 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); |
1586 } | 1560 } |
1587 | 1561 |
1588 if (resource->pixels) { | 1562 if (resource->pixels) { |
1589 DCHECK(!resource->mailbox.IsValid()); | 1563 DCHECK(!resource->mailbox.IsValid()); |
1590 DCHECK(resource->pixel_buffer); | 1564 DCHECK(resource->pixel_buffer); |
1591 DCHECK_EQ(RGBA_8888, resource->format); | 1565 DCHECK_EQ(RGBA_8888, resource->format); |
1592 | 1566 |
1593 std::swap(resource->pixels, resource->pixel_buffer); | 1567 std::swap(resource->pixels, resource->pixel_buffer); |
1594 delete[] resource->pixel_buffer; | 1568 delete[] resource->pixel_buffer; |
1595 resource->pixel_buffer = NULL; | 1569 resource->pixel_buffer = NULL; |
1596 } | 1570 } |
1597 | 1571 |
1598 resource->pending_set_pixels = true; | 1572 resource->pending_set_pixels = true; |
1599 resource->set_pixels_completion_forced = false; | 1573 resource->set_pixels_completion_forced = false; |
1600 } | 1574 } |
1601 | 1575 |
1602 void ResourceProvider::ForceSetPixelsToComplete(ResourceId id) { | 1576 void ResourceProvider::ForceSetPixelsToComplete(ResourceId id) { |
1603 Resource* resource = GetResource(id); | 1577 Resource* resource = GetResource(id); |
1604 DCHECK(resource->locked_for_write); | 1578 DCHECK(resource->locked_for_write); |
1605 DCHECK(resource->pending_set_pixels); | 1579 DCHECK(resource->pending_set_pixels); |
1606 DCHECK(!resource->set_pixels_completion_forced); | 1580 DCHECK(!resource->set_pixels_completion_forced); |
1607 | 1581 |
1608 if (resource->gl_id) { | 1582 if (resource->gl_id) { |
1609 WebGraphicsContext3D* context3d = Context3d(); | 1583 GLES2Interface* gl = ContextGL(); |
1610 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id)); | 1584 GLC(gl, gl->BindTexture(GL_TEXTURE_2D, resource->gl_id)); |
1611 GLC(context3d, context3d->waitAsyncTexImage2DCHROMIUM(GL_TEXTURE_2D)); | 1585 GLC(gl, gl->WaitAsyncTexImage2DCHROMIUM(GL_TEXTURE_2D)); |
1612 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, 0)); | 1586 GLC(gl, gl->BindTexture(GL_TEXTURE_2D, 0)); |
1613 } | 1587 } |
1614 | 1588 |
1615 resource->set_pixels_completion_forced = true; | 1589 resource->set_pixels_completion_forced = true; |
1616 } | 1590 } |
1617 | 1591 |
1618 bool ResourceProvider::DidSetPixelsComplete(ResourceId id) { | 1592 bool ResourceProvider::DidSetPixelsComplete(ResourceId id) { |
1619 Resource* resource = GetResource(id); | 1593 Resource* resource = GetResource(id); |
1620 DCHECK(resource->locked_for_write); | 1594 DCHECK(resource->locked_for_write); |
1621 DCHECK(resource->pending_set_pixels); | 1595 DCHECK(resource->pending_set_pixels); |
1622 | 1596 |
1623 if (resource->gl_id) { | 1597 if (resource->gl_id) { |
1624 WebGraphicsContext3D* context3d = Context3d(); | 1598 GLES2Interface* gl = ContextGL(); |
1625 DCHECK(context3d); | 1599 DCHECK(gl); |
1626 DCHECK(resource->gl_upload_query_id); | 1600 DCHECK(resource->gl_upload_query_id); |
1627 unsigned complete = 1; | 1601 GLuint complete = 1; |
1628 context3d->getQueryObjectuivEXT( | 1602 gl->GetQueryObjectuivEXT( |
1629 resource->gl_upload_query_id, | 1603 resource->gl_upload_query_id, GL_QUERY_RESULT_AVAILABLE_EXT, &complete); |
1630 GL_QUERY_RESULT_AVAILABLE_EXT, | |
1631 &complete); | |
1632 if (!complete) | 1604 if (!complete) |
1633 return false; | 1605 return false; |
1634 } | 1606 } |
1635 | 1607 |
1636 resource->pending_set_pixels = false; | 1608 resource->pending_set_pixels = false; |
1637 UnlockForWrite(id); | 1609 UnlockForWrite(id); |
1638 | 1610 |
1639 return true; | 1611 return true; |
1640 } | 1612 } |
1641 | 1613 |
1642 void ResourceProvider::CreateForTesting(ResourceId id) { | 1614 void ResourceProvider::CreateForTesting(ResourceId id) { |
1643 LazyCreate(GetResource(id)); | 1615 LazyCreate(GetResource(id)); |
1644 } | 1616 } |
1645 | 1617 |
1646 GLenum ResourceProvider::TargetForTesting(ResourceId id) { | 1618 GLenum ResourceProvider::TargetForTesting(ResourceId id) { |
1647 Resource* resource = GetResource(id); | 1619 Resource* resource = GetResource(id); |
1648 return resource->target; | 1620 return resource->target; |
1649 } | 1621 } |
1650 | 1622 |
1651 void ResourceProvider::LazyCreate(Resource* resource) { | 1623 void ResourceProvider::LazyCreate(Resource* resource) { |
1652 if (resource->type != GLTexture || resource->gl_id != 0) | 1624 if (resource->type != GLTexture || resource->gl_id != 0) |
1653 return; | 1625 return; |
1654 | 1626 |
1655 // Early out for resources that don't require texture creation. | 1627 // Early out for resources that don't require texture creation. |
1656 if (resource->texture_pool == 0) | 1628 if (resource->texture_pool == 0) |
1657 return; | 1629 return; |
1658 | 1630 |
1659 resource->gl_id = texture_id_allocator_->NextId(); | 1631 resource->gl_id = texture_id_allocator_->NextId(); |
1660 | 1632 |
1661 WebGraphicsContext3D* context3d = Context3d(); | 1633 GLES2Interface* gl = ContextGL(); |
1662 DCHECK(context3d); | 1634 DCHECK(gl); |
1663 | 1635 |
1664 // Create and set texture properties. Allocation is delayed until needed. | 1636 // Create and set texture properties. Allocation is delayed until needed. |
1665 GLC(context3d, context3d->bindTexture(resource->target, resource->gl_id)); | 1637 GLC(gl, gl->BindTexture(resource->target, resource->gl_id)); |
1666 GLC(context3d, | 1638 GLC(gl, |
1667 context3d->texParameteri( | 1639 gl->TexParameteri(resource->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); |
1668 resource->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | 1640 GLC(gl, |
1669 GLC(context3d, | 1641 gl->TexParameteri(resource->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); |
1670 context3d->texParameteri( | 1642 GLC(gl, |
1671 resource->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | 1643 gl->TexParameteri( |
1672 GLC(context3d, | |
1673 context3d->texParameteri( | |
1674 resource->target, GL_TEXTURE_WRAP_S, resource->wrap_mode)); | 1644 resource->target, GL_TEXTURE_WRAP_S, resource->wrap_mode)); |
1675 GLC(context3d, | 1645 GLC(gl, |
1676 context3d->texParameteri( | 1646 gl->TexParameteri( |
1677 resource->target, GL_TEXTURE_WRAP_T, resource->wrap_mode)); | 1647 resource->target, GL_TEXTURE_WRAP_T, resource->wrap_mode)); |
1678 GLC(context3d, | 1648 GLC(gl, |
1679 context3d->texParameteri( | 1649 gl->TexParameteri( |
1680 resource->target, GL_TEXTURE_POOL_CHROMIUM, resource->texture_pool)); | 1650 resource->target, GL_TEXTURE_POOL_CHROMIUM, resource->texture_pool)); |
1681 if (use_texture_usage_hint_ && resource->hint == TextureUsageFramebuffer) { | 1651 if (use_texture_usage_hint_ && resource->hint == TextureUsageFramebuffer) { |
1682 GLC(context3d, | 1652 GLC(gl, |
1683 context3d->texParameteri(resource->target, | 1653 gl->TexParameteri(resource->target, |
1684 GL_TEXTURE_USAGE_ANGLE, | 1654 GL_TEXTURE_USAGE_ANGLE, |
1685 GL_FRAMEBUFFER_ATTACHMENT_ANGLE)); | 1655 GL_FRAMEBUFFER_ATTACHMENT_ANGLE)); |
1686 } | 1656 } |
1687 } | 1657 } |
1688 | 1658 |
1689 void ResourceProvider::AllocateForTesting(ResourceId id) { | 1659 void ResourceProvider::AllocateForTesting(ResourceId id) { |
1690 LazyAllocate(GetResource(id)); | 1660 LazyAllocate(GetResource(id)); |
1691 } | 1661 } |
1692 | 1662 |
1693 void ResourceProvider::LazyAllocate(Resource* resource) { | 1663 void ResourceProvider::LazyAllocate(Resource* resource) { |
1694 DCHECK(resource); | 1664 DCHECK(resource); |
1695 LazyCreate(resource); | 1665 LazyCreate(resource); |
1696 | 1666 |
1697 DCHECK(resource->gl_id || resource->allocated); | 1667 DCHECK(resource->gl_id || resource->allocated); |
1698 if (resource->allocated || !resource->gl_id) | 1668 if (resource->allocated || !resource->gl_id) |
1699 return; | 1669 return; |
1700 resource->allocated = true; | 1670 resource->allocated = true; |
1701 WebGraphicsContext3D* context3d = Context3d(); | 1671 GLES2Interface* gl = ContextGL(); |
1702 gfx::Size& size = resource->size; | 1672 gfx::Size& size = resource->size; |
1703 DCHECK_EQ(resource->target, static_cast<GLenum>(GL_TEXTURE_2D)); | 1673 DCHECK_EQ(resource->target, static_cast<GLenum>(GL_TEXTURE_2D)); |
1704 ResourceFormat format = resource->format; | 1674 ResourceFormat format = resource->format; |
1705 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id)); | 1675 GLC(gl, gl->BindTexture(GL_TEXTURE_2D, resource->gl_id)); |
1706 if (use_texture_storage_ext_ && IsFormatSupportedForStorage(format) && | 1676 if (use_texture_storage_ext_ && IsFormatSupportedForStorage(format) && |
1707 resource->hint != TextureUsageFramebuffer) { | 1677 resource->hint != TextureUsageFramebuffer) { |
1708 GLenum storage_format = TextureToStorageFormat(format); | 1678 GLenum storage_format = TextureToStorageFormat(format); |
1709 GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D, | 1679 GLC(gl, |
1710 1, | 1680 gl->TexStorage2DEXT( |
1711 storage_format, | 1681 GL_TEXTURE_2D, 1, storage_format, size.width(), size.height())); |
1712 size.width(), | |
1713 size.height())); | |
1714 } else { | 1682 } else { |
1715 // ETC1 does not support preallocation. | 1683 // ETC1 does not support preallocation. |
1716 if (format != ETC1) { | 1684 if (format != ETC1) { |
1717 GLC(context3d, | 1685 GLC(gl, |
1718 context3d->texImage2D(GL_TEXTURE_2D, | 1686 gl->TexImage2D(GL_TEXTURE_2D, |
1719 0, | 1687 0, |
1720 GLInternalFormat(format), | 1688 GLInternalFormat(format), |
1721 size.width(), | 1689 size.width(), |
1722 size.height(), | 1690 size.height(), |
1723 0, | 1691 0, |
1724 GLDataFormat(format), | 1692 GLDataFormat(format), |
1725 GLDataType(format), | 1693 GLDataType(format), |
1726 NULL)); | 1694 NULL)); |
1727 } | 1695 } |
1728 } | 1696 } |
1729 } | 1697 } |
1730 | 1698 |
1731 void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id, | 1699 void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id, |
1732 bool enable) { | 1700 bool enable) { |
1733 Resource* resource = GetResource(id); | 1701 Resource* resource = GetResource(id); |
1734 resource->enable_read_lock_fences = enable; | 1702 resource->enable_read_lock_fences = enable; |
1735 } | 1703 } |
1736 | 1704 |
1737 void ResourceProvider::AcquireImage(ResourceId id) { | 1705 void ResourceProvider::AcquireImage(ResourceId id) { |
1738 Resource* resource = GetResource(id); | 1706 Resource* resource = GetResource(id); |
1739 DCHECK(!resource->external); | 1707 DCHECK(!resource->external); |
1740 DCHECK_EQ(resource->exported_count, 0); | 1708 DCHECK_EQ(resource->exported_count, 0); |
1741 | 1709 |
1742 if (resource->type != GLTexture) | 1710 if (resource->type != GLTexture) |
1743 return; | 1711 return; |
1744 | 1712 |
1745 if (resource->image_id) | 1713 if (resource->image_id) |
1746 return; | 1714 return; |
1747 | 1715 |
1748 resource->allocated = true; | 1716 resource->allocated = true; |
1749 WebGraphicsContext3D* context3d = Context3d(); | 1717 GLES2Interface* gl = ContextGL(); |
1750 DCHECK(context3d); | 1718 DCHECK(gl); |
1751 resource->image_id = context3d->createImageCHROMIUM( | 1719 resource->image_id = |
1752 resource->size.width(), | 1720 gl->CreateImageCHROMIUM(resource->size.width(), |
1753 resource->size.height(), | 1721 resource->size.height(), |
1754 TextureToStorageFormat(resource->format)); | 1722 TextureToStorageFormat(resource->format)); |
1755 DCHECK(resource->image_id); | 1723 DCHECK(resource->image_id); |
1756 } | 1724 } |
1757 | 1725 |
1758 void ResourceProvider::ReleaseImage(ResourceId id) { | 1726 void ResourceProvider::ReleaseImage(ResourceId id) { |
1759 Resource* resource = GetResource(id); | 1727 Resource* resource = GetResource(id); |
1760 DCHECK(!resource->external); | 1728 DCHECK(!resource->external); |
1761 DCHECK_EQ(resource->exported_count, 0); | 1729 DCHECK_EQ(resource->exported_count, 0); |
1762 | 1730 |
1763 if (!resource->image_id) | 1731 if (!resource->image_id) |
1764 return; | 1732 return; |
1765 | 1733 |
1766 WebGraphicsContext3D* context3d = Context3d(); | 1734 GLES2Interface* gl = ContextGL(); |
1767 DCHECK(context3d); | 1735 DCHECK(gl); |
1768 context3d->destroyImageCHROMIUM(resource->image_id); | 1736 gl->DestroyImageCHROMIUM(resource->image_id); |
1769 resource->image_id = 0; | 1737 resource->image_id = 0; |
1770 resource->bound_image_id = 0; | 1738 resource->bound_image_id = 0; |
1771 resource->dirty_image = false; | 1739 resource->dirty_image = false; |
1772 resource->allocated = false; | 1740 resource->allocated = false; |
1773 } | 1741 } |
1774 | 1742 |
1775 uint8_t* ResourceProvider::MapImage(ResourceId id) { | 1743 uint8_t* ResourceProvider::MapImage(ResourceId id) { |
1776 Resource* resource = GetResource(id); | 1744 Resource* resource = GetResource(id); |
1777 DCHECK(ReadLockFenceHasPassed(resource)); | 1745 DCHECK(ReadLockFenceHasPassed(resource)); |
1778 DCHECK(!resource->external); | 1746 DCHECK(!resource->external); |
1779 DCHECK_EQ(resource->exported_count, 0); | 1747 DCHECK_EQ(resource->exported_count, 0); |
1780 | 1748 |
1781 if (resource->image_id) { | 1749 if (resource->image_id) { |
1782 WebGraphicsContext3D* context3d = Context3d(); | 1750 GLES2Interface* gl = ContextGL(); |
1783 DCHECK(context3d); | 1751 DCHECK(gl); |
1784 return static_cast<uint8_t*>( | 1752 return static_cast<uint8_t*>( |
1785 context3d->mapImageCHROMIUM(resource->image_id, GL_READ_WRITE)); | 1753 gl->MapImageCHROMIUM(resource->image_id, GL_READ_WRITE)); |
1786 } | 1754 } |
1787 | 1755 |
1788 if (resource->pixels) | 1756 if (resource->pixels) |
1789 return resource->pixels; | 1757 return resource->pixels; |
1790 | 1758 |
1791 return NULL; | 1759 return NULL; |
1792 } | 1760 } |
1793 | 1761 |
1794 void ResourceProvider::UnmapImage(ResourceId id) { | 1762 void ResourceProvider::UnmapImage(ResourceId id) { |
1795 Resource* resource = GetResource(id); | 1763 Resource* resource = GetResource(id); |
1796 DCHECK(!resource->external); | 1764 DCHECK(!resource->external); |
1797 DCHECK_EQ(resource->exported_count, 0); | 1765 DCHECK_EQ(resource->exported_count, 0); |
1798 | 1766 |
1799 if (resource->image_id) { | 1767 if (resource->image_id) { |
1800 WebGraphicsContext3D* context3d = Context3d(); | 1768 GLES2Interface* gl = ContextGL(); |
1801 DCHECK(context3d); | 1769 DCHECK(gl); |
1802 context3d->unmapImageCHROMIUM(resource->image_id); | 1770 gl->UnmapImageCHROMIUM(resource->image_id); |
1803 resource->dirty_image = true; | 1771 resource->dirty_image = true; |
1804 } | 1772 } |
1805 } | 1773 } |
1806 | 1774 |
1807 int ResourceProvider::GetImageStride(ResourceId id) { | 1775 int ResourceProvider::GetImageStride(ResourceId id) { |
1808 Resource* resource = GetResource(id); | 1776 Resource* resource = GetResource(id); |
1809 DCHECK(!resource->external); | 1777 DCHECK(!resource->external); |
1810 DCHECK_EQ(resource->exported_count, 0); | 1778 DCHECK_EQ(resource->exported_count, 0); |
1811 | 1779 |
1812 int stride = 0; | 1780 int stride = 0; |
1813 | 1781 |
1814 if (resource->image_id) { | 1782 if (resource->image_id) { |
1815 WebGraphicsContext3D* context3d = Context3d(); | 1783 GLES2Interface* gl = ContextGL(); |
1816 DCHECK(context3d); | 1784 DCHECK(gl); |
1817 context3d->getImageParameterivCHROMIUM( | 1785 gl->GetImageParameterivCHROMIUM( |
1818 resource->image_id, GL_IMAGE_ROWBYTES_CHROMIUM, &stride); | 1786 resource->image_id, GL_IMAGE_ROWBYTES_CHROMIUM, &stride); |
1819 } | 1787 } |
1820 | 1788 |
1821 return stride; | 1789 return stride; |
1822 } | 1790 } |
1823 | 1791 |
1824 base::SharedMemory* ResourceProvider::GetSharedMemory(ResourceId id) { | 1792 base::SharedMemory* ResourceProvider::GetSharedMemory(ResourceId id) { |
1825 Resource* resource = GetResource(id); | 1793 Resource* resource = GetResource(id); |
1826 DCHECK(!resource->external); | 1794 DCHECK(!resource->external); |
1827 DCHECK_EQ(resource->exported_count, 0); | 1795 DCHECK_EQ(resource->exported_count, 0); |
1828 | 1796 |
1829 if (!resource->shared_bitmap) | 1797 if (!resource->shared_bitmap) |
1830 return NULL; | 1798 return NULL; |
1831 return resource->shared_bitmap->memory(); | 1799 return resource->shared_bitmap->memory(); |
1832 } | 1800 } |
1833 | 1801 |
1834 GLint ResourceProvider::GetActiveTextureUnit(WebGraphicsContext3D* context) { | 1802 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { |
1835 GLint active_unit = 0; | 1803 GLint active_unit = 0; |
1836 context->getIntegerv(GL_ACTIVE_TEXTURE, &active_unit); | 1804 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); |
1837 return active_unit; | 1805 return active_unit; |
1838 } | 1806 } |
1839 | 1807 |
1840 blink::WebGraphicsContext3D* ResourceProvider::Context3d() const { | 1808 GLES2Interface* ResourceProvider::ContextGL() const { |
1841 ContextProvider* context_provider = output_surface_->context_provider(); | 1809 ContextProvider* context_provider = output_surface_->context_provider(); |
1842 return context_provider ? context_provider->Context3d() : NULL; | 1810 return context_provider ? context_provider->ContextGL() : NULL; |
1843 } | 1811 } |
1844 | 1812 |
1845 } // namespace cc | 1813 } // namespace cc |
OLD | NEW |