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

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

Issue 375303002: cc: Refactor ResourceProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 src.copyTo(&dst_bitmap, dst_colorType, &allocator); 127 src.copyTo(&dst_bitmap, dst_colorType, &allocator);
128 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the 128 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the
129 // bitmap data. This check will be removed once crbug.com/293728 is fixed. 129 // bitmap data. This check will be removed once crbug.com/293728 is fixed.
130 CHECK_EQ(0u, dst_bitmap.rowBytes() % 4); 130 CHECK_EQ(0u, dst_bitmap.rowBytes() % 4);
131 } 131 }
132 132
133 class ScopedSetActiveTexture { 133 class ScopedSetActiveTexture {
134 public: 134 public:
135 ScopedSetActiveTexture(GLES2Interface* gl, GLenum unit) 135 ScopedSetActiveTexture(GLES2Interface* gl, GLenum unit)
136 : gl_(gl), unit_(unit) { 136 : gl_(gl), unit_(unit) {
137 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(gl_)); 137 DCHECK_EQ(GL_TEXTURE0, ResourceHelper::GetActiveTextureUnit(gl_));
138 138
139 if (unit_ != GL_TEXTURE0) 139 if (unit_ != GL_TEXTURE0)
140 GLC(gl_, gl_->ActiveTexture(unit_)); 140 GLC(gl_, gl_->ActiveTexture(unit_));
141 } 141 }
142 142
143 ~ScopedSetActiveTexture() { 143 ~ScopedSetActiveTexture() {
144 // Active unit being GL_TEXTURE0 is effectively the ground state. 144 // Active unit being GL_TEXTURE0 is effectively the ground state.
145 if (unit_ != GL_TEXTURE0) 145 if (unit_ != GL_TEXTURE0)
146 GLC(gl_, gl_->ActiveTexture(GL_TEXTURE0)); 146 GLC(gl_, gl_->ActiveTexture(GL_TEXTURE0));
147 } 147 }
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 // generationID returns a non-zero, unique value corresponding to the content 452 // generationID returns a non-zero, unique value corresponding to the content
453 // of surface. Hence, a change since DoLockForWrite was called means the 453 // of surface. Hence, a change since DoLockForWrite was called means the
454 // surface has changed. 454 // surface has changed.
455 return surface_ ? surface_generation_id_ != surface_->generationID() : false; 455 return surface_ ? surface_generation_id_ != surface_->generationID() : false;
456 } 456 }
457 457
458 skia::RefPtr<SkSurface> ResourceProvider::GpuRasterBuffer::CreateSurface() { 458 skia::RefPtr<SkSurface> ResourceProvider::GpuRasterBuffer::CreateSurface() {
459 DCHECK_EQ(GLTexture, resource()->type); 459 DCHECK_EQ(GLTexture, resource()->type);
460 DCHECK(resource()->gl_id); 460 DCHECK(resource()->gl_id);
461 461
462 class GrContext* gr_context = resource_provider()->GrContext(); 462 class GrContext* gr_context =
463 resource_provider()->GetResourceHelper()->GrContext();
463 // TODO(alokp): Implement TestContextProvider::GrContext(). 464 // TODO(alokp): Implement TestContextProvider::GrContext().
464 if (!gr_context) 465 if (!gr_context)
465 return skia::RefPtr<SkSurface>(); 466 return skia::RefPtr<SkSurface>();
466 467
467 GrBackendTextureDesc desc; 468 GrBackendTextureDesc desc;
468 desc.fFlags = kRenderTarget_GrBackendTextureFlag; 469 desc.fFlags = kRenderTarget_GrBackendTextureFlag;
469 desc.fWidth = resource()->size.width(); 470 desc.fWidth = resource()->size.width();
470 desc.fHeight = resource()->size.height(); 471 desc.fHeight = resource()->size.height();
471 desc.fConfig = ToGrPixelConfig(resource()->format); 472 desc.fConfig = ToGrPixelConfig(resource()->format);
472 desc.fOrigin = kTopLeft_GrSurfaceOrigin; 473 desc.fOrigin = kTopLeft_GrSurfaceOrigin;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 size_t id_allocation_chunk_size, 590 size_t id_allocation_chunk_size,
590 bool use_distance_field_text) { 591 bool use_distance_field_text) {
591 scoped_ptr<ResourceProvider> resource_provider( 592 scoped_ptr<ResourceProvider> resource_provider(
592 new ResourceProvider(output_surface, 593 new ResourceProvider(output_surface,
593 shared_bitmap_manager, 594 shared_bitmap_manager,
594 highp_threshold_min, 595 highp_threshold_min,
595 use_rgba_4444_texture_format, 596 use_rgba_4444_texture_format,
596 id_allocation_chunk_size, 597 id_allocation_chunk_size,
597 use_distance_field_text)); 598 use_distance_field_text));
598 599
599 if (resource_provider->ContextGL()) 600 if (resource_provider->GetResourceHelper()->ContextGL())
600 resource_provider->InitializeGL(); 601 resource_provider->InitializeGL();
601 else 602 else
602 resource_provider->InitializeSoftware(); 603 resource_provider->InitializeSoftware();
603 604
604 DCHECK_NE(InvalidType, resource_provider->default_resource_type()); 605 DCHECK_NE(InvalidType, resource_provider->default_resource_type());
605 return resource_provider.Pass(); 606 return resource_provider.Pass();
606 } 607 }
607 608
608 ResourceProvider::~ResourceProvider() { 609 ResourceProvider::~ResourceProvider() {
609 while (!children_.empty()) 610 while (!children_.empty())
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 Resource resource(0, 742 Resource resource(0,
742 gfx::Size(), 743 gfx::Size(),
743 Resource::Internal, 744 Resource::Internal,
744 GL_TEXTURE_RECTANGLE_ARB, 745 GL_TEXTURE_RECTANGLE_ARB,
745 GL_LINEAR, 746 GL_LINEAR,
746 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, 747 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM,
747 GL_CLAMP_TO_EDGE, 748 GL_CLAMP_TO_EDGE,
748 TextureUsageAny, 749 TextureUsageAny,
749 RGBA_8888); 750 RGBA_8888);
750 LazyCreate(&resource); 751 LazyCreate(&resource);
751 GLES2Interface* gl = ContextGL(); 752 GLES2Interface* gl = resource_helper_->ContextGL();
752 DCHECK(gl); 753 DCHECK(gl);
753 gl->BindTexture(GL_TEXTURE_RECTANGLE_ARB, resource.gl_id); 754 gl->BindTexture(GL_TEXTURE_RECTANGLE_ARB, resource.gl_id);
754 gl->TexImageIOSurface2DCHROMIUM( 755 gl->TexImageIOSurface2DCHROMIUM(
755 GL_TEXTURE_RECTANGLE_ARB, size.width(), size.height(), io_surface_id, 0); 756 GL_TEXTURE_RECTANGLE_ARB, size.width(), size.height(), io_surface_id, 0);
756 resource.allocated = true; 757 resource.allocated = true;
757 resources_[id] = resource; 758 resources_[id] = resource;
758 return id; 759 return id;
759 } 760 }
760 761
761 ResourceProvider::ResourceId ResourceProvider::CreateResourceFromTextureMailbox( 762 ResourceProvider::ResourceId ResourceProvider::CreateResourceFromTextureMailbox(
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 DCHECK(resource->exported_count == 0 || style != Normal); 830 DCHECK(resource->exported_count == 0 || style != Normal);
830 if (style == ForShutdown && resource->exported_count > 0) 831 if (style == ForShutdown && resource->exported_count > 0)
831 lost_resource = true; 832 lost_resource = true;
832 833
833 resource->gpu_raster_buffer.reset(); 834 resource->gpu_raster_buffer.reset();
834 resource->image_raster_buffer.reset(); 835 resource->image_raster_buffer.reset();
835 resource->pixel_raster_buffer.reset(); 836 resource->pixel_raster_buffer.reset();
836 837
837 if (resource->image_id) { 838 if (resource->image_id) {
838 DCHECK(resource->origin == Resource::Internal); 839 DCHECK(resource->origin == Resource::Internal);
839 GLES2Interface* gl = ContextGL(); 840 GLES2Interface* gl = resource_helper_->ContextGL();
840 DCHECK(gl); 841 DCHECK(gl);
841 GLC(gl, gl->DestroyImageCHROMIUM(resource->image_id)); 842 GLC(gl, gl->DestroyImageCHROMIUM(resource->image_id));
842 } 843 }
843 if (resource->gl_upload_query_id) { 844 if (resource->gl_upload_query_id) {
844 DCHECK(resource->origin == Resource::Internal); 845 DCHECK(resource->origin == Resource::Internal);
845 GLES2Interface* gl = ContextGL(); 846 GLES2Interface* gl = resource_helper_->ContextGL();
846 DCHECK(gl); 847 DCHECK(gl);
847 GLC(gl, gl->DeleteQueriesEXT(1, &resource->gl_upload_query_id)); 848 GLC(gl, gl->DeleteQueriesEXT(1, &resource->gl_upload_query_id));
848 } 849 }
849 if (resource->gl_read_lock_query_id) { 850 if (resource->gl_read_lock_query_id) {
850 DCHECK(resource->origin == Resource::Internal); 851 DCHECK(resource->origin == Resource::Internal);
851 GLES2Interface* gl = ContextGL(); 852 GLES2Interface* gl = resource_helper_->ContextGL();
852 DCHECK(gl); 853 DCHECK(gl);
853 GLC(gl, gl->DeleteQueriesEXT(1, &resource->gl_read_lock_query_id)); 854 GLC(gl, gl->DeleteQueriesEXT(1, &resource->gl_read_lock_query_id));
854 } 855 }
855 if (resource->gl_pixel_buffer_id) { 856 if (resource->gl_pixel_buffer_id) {
856 DCHECK(resource->origin == Resource::Internal); 857 DCHECK(resource->origin == Resource::Internal);
857 GLES2Interface* gl = ContextGL(); 858 GLES2Interface* gl = resource_helper_->ContextGL();
858 DCHECK(gl); 859 DCHECK(gl);
859 GLC(gl, gl->DeleteBuffers(1, &resource->gl_pixel_buffer_id)); 860 GLC(gl, gl->DeleteBuffers(1, &resource->gl_pixel_buffer_id));
860 } 861 }
861 if (resource->origin == Resource::External) { 862 if (resource->origin == Resource::External) {
862 DCHECK(resource->mailbox.IsValid()); 863 DCHECK(resource->mailbox.IsValid());
863 GLuint sync_point = resource->mailbox.sync_point(); 864 GLuint sync_point = resource->mailbox.sync_point();
864 if (resource->type == GLTexture) { 865 if (resource->type == GLTexture) {
865 DCHECK(resource->mailbox.IsTexture()); 866 DCHECK(resource->mailbox.IsTexture());
866 lost_resource |= lost_output_surface_; 867 lost_resource |= lost_output_surface_;
867 GLES2Interface* gl = ContextGL(); 868 GLES2Interface* gl = resource_helper_->ContextGL();
868 DCHECK(gl); 869 DCHECK(gl);
869 if (resource->gl_id) { 870 if (resource->gl_id) {
870 GLC(gl, gl->DeleteTextures(1, &resource->gl_id)); 871 GLC(gl, gl->DeleteTextures(1, &resource->gl_id));
871 resource->gl_id = 0; 872 resource->gl_id = 0;
872 if (!lost_resource) 873 if (!lost_resource)
873 sync_point = gl->InsertSyncPointCHROMIUM(); 874 sync_point = gl->InsertSyncPointCHROMIUM();
874 } 875 }
875 } else { 876 } else {
876 DCHECK(resource->mailbox.IsSharedMemory()); 877 DCHECK(resource->mailbox.IsSharedMemory());
877 base::SharedMemory* shared_memory = resource->mailbox.shared_memory(); 878 base::SharedMemory* shared_memory = resource->mailbox.shared_memory();
878 if (resource->pixels && shared_memory) { 879 if (resource->pixels && shared_memory) {
879 DCHECK(shared_memory->memory() == resource->pixels); 880 DCHECK(shared_memory->memory() == resource->pixels);
880 resource->pixels = NULL; 881 resource->pixels = NULL;
881 delete resource->shared_bitmap; 882 delete resource->shared_bitmap;
882 resource->shared_bitmap = NULL; 883 resource->shared_bitmap = NULL;
883 } 884 }
884 } 885 }
885 resource->release_callback.Run(sync_point, lost_resource); 886 resource->release_callback.Run(sync_point, lost_resource);
886 } 887 }
887 if (resource->gl_id) { 888 if (resource->gl_id) {
888 GLES2Interface* gl = ContextGL(); 889 GLES2Interface* gl = resource_helper_->ContextGL();
889 DCHECK(gl); 890 DCHECK(gl);
890 GLC(gl, gl->DeleteTextures(1, &resource->gl_id)); 891 GLC(gl, gl->DeleteTextures(1, &resource->gl_id));
891 resource->gl_id = 0; 892 resource->gl_id = 0;
892 } 893 }
893 if (resource->shared_bitmap) { 894 if (resource->shared_bitmap) {
894 DCHECK(resource->origin != Resource::External); 895 DCHECK(resource->origin != Resource::External);
895 DCHECK_EQ(Bitmap, resource->type); 896 DCHECK_EQ(Bitmap, resource->type);
896 delete resource->shared_bitmap; 897 delete resource->shared_bitmap;
897 resource->pixels = NULL; 898 resource->pixels = NULL;
898 } 899 }
(...skipping 19 matching lines...) Expand all
918 DCHECK(!resource->lock_for_read_count); 919 DCHECK(!resource->lock_for_read_count);
919 DCHECK(resource->origin == Resource::Internal); 920 DCHECK(resource->origin == Resource::Internal);
920 DCHECK_EQ(resource->exported_count, 0); 921 DCHECK_EQ(resource->exported_count, 0);
921 DCHECK(ReadLockFenceHasPassed(resource)); 922 DCHECK(ReadLockFenceHasPassed(resource));
922 LazyAllocate(resource); 923 LazyAllocate(resource);
923 924
924 if (resource->type == GLTexture) { 925 if (resource->type == GLTexture) {
925 DCHECK(resource->gl_id); 926 DCHECK(resource->gl_id);
926 DCHECK(!resource->pending_set_pixels); 927 DCHECK(!resource->pending_set_pixels);
927 DCHECK_EQ(resource->target, static_cast<GLenum>(GL_TEXTURE_2D)); 928 DCHECK_EQ(resource->target, static_cast<GLenum>(GL_TEXTURE_2D));
928 GLES2Interface* gl = ContextGL(); 929 GLES2Interface* gl = resource_helper_->ContextGL();
929 DCHECK(gl); 930 DCHECK(gl);
930 DCHECK(texture_uploader_.get()); 931 DCHECK(texture_uploader_.get());
931 gl->BindTexture(GL_TEXTURE_2D, resource->gl_id); 932 gl->BindTexture(GL_TEXTURE_2D, resource->gl_id);
932 texture_uploader_->Upload(image, 933 texture_uploader_->Upload(image,
933 image_rect, 934 image_rect,
934 source_rect, 935 source_rect,
935 dest_offset, 936 dest_offset,
936 resource->format, 937 resource->format,
937 resource->size); 938 resource->size);
938 } else { 939 } else {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 1009
1009 base::TimeDelta upload_one_texture_time = 1010 base::TimeDelta upload_one_texture_time =
1010 base::TimeDelta::FromMicroseconds( 1011 base::TimeDelta::FromMicroseconds(
1011 base::Time::kMicrosecondsPerSecond * kTextureUploadTickRate) / 1012 base::Time::kMicrosecondsPerSecond * kTextureUploadTickRate) /
1012 uploads_per_tick; 1013 uploads_per_tick;
1013 1014
1014 size_t total_uploads = NumBlockingUploads() + uploads_per_tick; 1015 size_t total_uploads = NumBlockingUploads() + uploads_per_tick;
1015 return gfx::FrameTime::Now() + upload_one_texture_time * total_uploads; 1016 return gfx::FrameTime::Now() + upload_one_texture_time * total_uploads;
1016 } 1017 }
1017 1018
1018 void ResourceProvider::Flush() {
1019 DCHECK(thread_checker_.CalledOnValidThread());
1020 GLES2Interface* gl = ContextGL();
1021 if (gl)
1022 gl->Flush();
1023 }
1024
1025 void ResourceProvider::Finish() {
1026 DCHECK(thread_checker_.CalledOnValidThread());
1027 GLES2Interface* gl = ContextGL();
1028 if (gl)
1029 gl->Finish();
1030 }
1031
1032 bool ResourceProvider::ShallowFlushIfSupported() {
1033 DCHECK(thread_checker_.CalledOnValidThread());
1034 GLES2Interface* gl = ContextGL();
1035 if (!gl)
1036 return false;
1037
1038 gl->ShallowFlushCHROMIUM();
1039 return true;
1040 }
1041
1042 ResourceProvider::Resource* ResourceProvider::GetResource(ResourceId id) { 1019 ResourceProvider::Resource* ResourceProvider::GetResource(ResourceId id) {
1043 DCHECK(thread_checker_.CalledOnValidThread()); 1020 DCHECK(thread_checker_.CalledOnValidThread());
1044 ResourceMap::iterator it = resources_.find(id); 1021 ResourceMap::iterator it = resources_.find(id);
1045 CHECK(it != resources_.end()); 1022 CHECK(it != resources_.end());
1046 return &it->second; 1023 return &it->second;
1047 } 1024 }
1048 1025
1049 const ResourceProvider::Resource* ResourceProvider::LockForRead(ResourceId id) { 1026 const ResourceProvider::Resource* ResourceProvider::LockForRead(ResourceId id) {
1050 Resource* resource = GetResource(id); 1027 Resource* resource = GetResource(id);
1051 DCHECK(!resource->locked_for_write || 1028 DCHECK(!resource->locked_for_write ||
1052 resource->set_pixels_completion_forced) << 1029 resource->set_pixels_completion_forced) <<
1053 "locked for write: " << resource->locked_for_write << 1030 "locked for write: " << resource->locked_for_write <<
1054 " pixels completion forced: " << resource->set_pixels_completion_forced; 1031 " pixels completion forced: " << resource->set_pixels_completion_forced;
1055 DCHECK_EQ(resource->exported_count, 0); 1032 DCHECK_EQ(resource->exported_count, 0);
1056 // Uninitialized! Call SetPixels or LockForWrite first. 1033 // Uninitialized! Call SetPixels or LockForWrite first.
1057 DCHECK(resource->allocated); 1034 DCHECK(resource->allocated);
1058 1035
1059 LazyCreate(resource); 1036 LazyCreate(resource);
1060 1037
1061 if (resource->type == GLTexture && !resource->gl_id) { 1038 if (resource->type == GLTexture && !resource->gl_id) {
1062 DCHECK(resource->origin != Resource::Internal); 1039 DCHECK(resource->origin != Resource::Internal);
1063 DCHECK(resource->mailbox.IsTexture()); 1040 DCHECK(resource->mailbox.IsTexture());
1064 GLES2Interface* gl = ContextGL(); 1041 GLES2Interface* gl = resource_helper_->ContextGL();
1065 DCHECK(gl); 1042 DCHECK(gl);
1066 if (resource->mailbox.sync_point()) { 1043 if (resource->mailbox.sync_point()) {
1067 GLC(gl, gl->WaitSyncPointCHROMIUM(resource->mailbox.sync_point())); 1044 GLC(gl, gl->WaitSyncPointCHROMIUM(resource->mailbox.sync_point()));
1068 resource->mailbox.set_sync_point(0); 1045 resource->mailbox.set_sync_point(0);
1069 } 1046 }
1070 resource->gl_id = texture_id_allocator_->NextId(); 1047 resource->gl_id = texture_id_allocator_->NextId();
1071 GLC(gl, gl->BindTexture(resource->target, resource->gl_id)); 1048 GLC(gl, gl->BindTexture(resource->target, resource->gl_id));
1072 GLC(gl, 1049 GLC(gl,
1073 gl->ConsumeTextureCHROMIUM(resource->mailbox.target(), 1050 gl->ConsumeTextureCHROMIUM(resource->mailbox.target(),
1074 resource->mailbox.name())); 1051 resource->mailbox.name()));
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 ResourceProvider::PopulateSkBitmapWithResource( 1199 ResourceProvider::PopulateSkBitmapWithResource(
1223 &sk_bitmap_, resource_provider->LockForWrite(resource_id)); 1200 &sk_bitmap_, resource_provider->LockForWrite(resource_id));
1224 DCHECK(valid()); 1201 DCHECK(valid());
1225 sk_canvas_.reset(new SkCanvas(sk_bitmap_)); 1202 sk_canvas_.reset(new SkCanvas(sk_bitmap_));
1226 } 1203 }
1227 1204
1228 ResourceProvider::ScopedWriteLockSoftware::~ScopedWriteLockSoftware() { 1205 ResourceProvider::ScopedWriteLockSoftware::~ScopedWriteLockSoftware() {
1229 resource_provider_->UnlockForWrite(resource_id_); 1206 resource_provider_->UnlockForWrite(resource_id_);
1230 } 1207 }
1231 1208
1232 ResourceProvider::ScopedGpuRaster::ScopedGpuRaster(
1233 ResourceProvider* resource_provider)
1234 : resource_provider_(resource_provider) {
1235 resource_provider_->BeginGpuRaster();
1236 }
1237
1238 ResourceProvider::ScopedGpuRaster::~ScopedGpuRaster() {
1239 resource_provider_->EndGpuRaster();
1240 }
1241
1242 ResourceProvider::ResourceProvider(OutputSurface* output_surface, 1209 ResourceProvider::ResourceProvider(OutputSurface* output_surface,
1243 SharedBitmapManager* shared_bitmap_manager, 1210 SharedBitmapManager* shared_bitmap_manager,
1244 int highp_threshold_min, 1211 int highp_threshold_min,
1245 bool use_rgba_4444_texture_format, 1212 bool use_rgba_4444_texture_format,
1246 size_t id_allocation_chunk_size, 1213 size_t id_allocation_chunk_size,
1247 bool use_distance_field_text) 1214 bool use_distance_field_text)
1248 : output_surface_(output_surface), 1215 : output_surface_(output_surface),
1249 shared_bitmap_manager_(shared_bitmap_manager), 1216 shared_bitmap_manager_(shared_bitmap_manager),
1250 lost_output_surface_(false), 1217 lost_output_surface_(false),
1251 highp_threshold_min_(highp_threshold_min), 1218 highp_threshold_min_(highp_threshold_min),
1252 next_id_(1), 1219 next_id_(1),
1253 next_child_(1), 1220 next_child_(1),
1254 default_resource_type_(InvalidType), 1221 default_resource_type_(InvalidType),
1255 use_texture_storage_ext_(false), 1222 use_texture_storage_ext_(false),
1256 use_texture_usage_hint_(false), 1223 use_texture_usage_hint_(false),
1257 use_compressed_texture_etc1_(false), 1224 use_compressed_texture_etc1_(false),
1258 max_texture_size_(0), 1225 max_texture_size_(0),
1259 best_texture_format_(RGBA_8888), 1226 best_texture_format_(RGBA_8888),
1260 use_rgba_4444_texture_format_(use_rgba_4444_texture_format), 1227 use_rgba_4444_texture_format_(use_rgba_4444_texture_format),
1261 id_allocation_chunk_size_(id_allocation_chunk_size), 1228 id_allocation_chunk_size_(id_allocation_chunk_size),
1262 use_sync_query_(false), 1229 use_sync_query_(false),
1263 use_distance_field_text_(use_distance_field_text) { 1230 use_distance_field_text_(use_distance_field_text),
1231 resource_helper_(new ResourceHelper(output_surface)) {
1264 DCHECK(output_surface_->HasClient()); 1232 DCHECK(output_surface_->HasClient());
1265 DCHECK(id_allocation_chunk_size_); 1233 DCHECK(id_allocation_chunk_size_);
1266 } 1234 }
1267 1235
1268 void ResourceProvider::InitializeSoftware() { 1236 void ResourceProvider::InitializeSoftware() {
1269 DCHECK(thread_checker_.CalledOnValidThread()); 1237 DCHECK(thread_checker_.CalledOnValidThread());
1270 DCHECK_NE(Bitmap, default_resource_type_); 1238 DCHECK_NE(Bitmap, default_resource_type_);
1271 1239
1272 CleanUpGLIfNeeded(); 1240 CleanUpGLIfNeeded();
1273 1241
(...skipping 14 matching lines...) Expand all
1288 1256
1289 const ContextProvider::Capabilities& caps = 1257 const ContextProvider::Capabilities& caps =
1290 output_surface_->context_provider()->ContextCapabilities(); 1258 output_surface_->context_provider()->ContextCapabilities();
1291 1259
1292 bool use_bgra = caps.gpu.texture_format_bgra8888; 1260 bool use_bgra = caps.gpu.texture_format_bgra8888;
1293 use_texture_storage_ext_ = caps.gpu.texture_storage; 1261 use_texture_storage_ext_ = caps.gpu.texture_storage;
1294 use_texture_usage_hint_ = caps.gpu.texture_usage; 1262 use_texture_usage_hint_ = caps.gpu.texture_usage;
1295 use_compressed_texture_etc1_ = caps.gpu.texture_format_etc1; 1263 use_compressed_texture_etc1_ = caps.gpu.texture_format_etc1;
1296 use_sync_query_ = caps.gpu.sync_query; 1264 use_sync_query_ = caps.gpu.sync_query;
1297 1265
1298 GLES2Interface* gl = ContextGL(); 1266 GLES2Interface* gl = resource_helper_->ContextGL();
1299 DCHECK(gl); 1267 DCHECK(gl);
1300 1268
1301 texture_uploader_ = TextureUploader::Create(gl); 1269 texture_uploader_ = TextureUploader::Create(gl);
1302 max_texture_size_ = 0; // Context expects cleared value. 1270 max_texture_size_ = 0; // Context expects cleared value.
1303 GLC(gl, gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_)); 1271 GLC(gl, gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_));
1304 best_texture_format_ = PlatformColor::BestTextureFormat(use_bgra); 1272 best_texture_format_ = PlatformColor::BestTextureFormat(use_bgra);
1305 1273
1306 texture_id_allocator_.reset( 1274 texture_id_allocator_.reset(
1307 new TextureIdAllocator(gl, id_allocation_chunk_size_)); 1275 new TextureIdAllocator(gl, id_allocation_chunk_size_));
1308 buffer_id_allocator_.reset( 1276 buffer_id_allocator_.reset(
1309 new BufferIdAllocator(gl, id_allocation_chunk_size_)); 1277 new BufferIdAllocator(gl, id_allocation_chunk_size_));
1310 } 1278 }
1311 1279
1312 void ResourceProvider::CleanUpGLIfNeeded() { 1280 void ResourceProvider::CleanUpGLIfNeeded() {
1313 GLES2Interface* gl = ContextGL(); 1281 GLES2Interface* gl = resource_helper_->ContextGL();
1314 if (default_resource_type_ != GLTexture) { 1282 if (default_resource_type_ != GLTexture) {
1315 // We are not in GL mode, but double check before returning. 1283 // We are not in GL mode, but double check before returning.
1316 DCHECK(!gl); 1284 DCHECK(!gl);
1317 DCHECK(!texture_uploader_); 1285 DCHECK(!texture_uploader_);
1318 return; 1286 return;
1319 } 1287 }
1320 1288
1321 DCHECK(gl); 1289 DCHECK(gl);
1322 #if DCHECK_IS_ON 1290 #if DCHECK_IS_ON
1323 // Check that all GL resources has been deleted. 1291 // Check that all GL resources has been deleted.
1324 for (ResourceMap::const_iterator itr = resources_.begin(); 1292 for (ResourceMap::const_iterator itr = resources_.begin();
1325 itr != resources_.end(); 1293 itr != resources_.end();
1326 ++itr) { 1294 ++itr) {
1327 DCHECK_NE(GLTexture, itr->second.type); 1295 DCHECK_NE(GLTexture, itr->second.type);
1328 } 1296 }
1329 #endif // DCHECK_IS_ON 1297 #endif // DCHECK_IS_ON
1330 1298
1331 texture_uploader_.reset(); 1299 texture_uploader_.reset();
1332 texture_id_allocator_.reset(); 1300 texture_id_allocator_.reset();
1333 buffer_id_allocator_.reset(); 1301 buffer_id_allocator_.reset();
1334 Finish(); 1302 GetResourceHelper()->Finish();
danakj 2014/07/09 16:01:33 can we just call gl->Finish() directly?
sohanjg 2014/07/10 15:11:06 Done.
1335 } 1303 }
1336 1304
1337 int ResourceProvider::CreateChild(const ReturnCallback& return_callback) { 1305 int ResourceProvider::CreateChild(const ReturnCallback& return_callback) {
1338 DCHECK(thread_checker_.CalledOnValidThread()); 1306 DCHECK(thread_checker_.CalledOnValidThread());
1339 1307
1340 Child child_info; 1308 Child child_info;
1341 child_info.return_callback = return_callback; 1309 child_info.return_callback = return_callback;
1342 1310
1343 int child = next_child_++; 1311 int child = next_child_++;
1344 children_[child] = child_info; 1312 children_[child] = child_info;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 DCHECK(thread_checker_.CalledOnValidThread()); 1347 DCHECK(thread_checker_.CalledOnValidThread());
1380 ChildMap::const_iterator it = children_.find(child); 1348 ChildMap::const_iterator it = children_.find(child);
1381 DCHECK(it != children_.end()); 1349 DCHECK(it != children_.end());
1382 DCHECK(!it->second.marked_for_deletion); 1350 DCHECK(!it->second.marked_for_deletion);
1383 return it->second.child_to_parent_map; 1351 return it->second.child_to_parent_map;
1384 } 1352 }
1385 1353
1386 void ResourceProvider::PrepareSendToParent(const ResourceIdArray& resources, 1354 void ResourceProvider::PrepareSendToParent(const ResourceIdArray& resources,
1387 TransferableResourceArray* list) { 1355 TransferableResourceArray* list) {
1388 DCHECK(thread_checker_.CalledOnValidThread()); 1356 DCHECK(thread_checker_.CalledOnValidThread());
1389 GLES2Interface* gl = ContextGL(); 1357 GLES2Interface* gl = resource_helper_->ContextGL();
1390 bool need_sync_point = false; 1358 bool need_sync_point = false;
1391 for (ResourceIdArray::const_iterator it = resources.begin(); 1359 for (ResourceIdArray::const_iterator it = resources.begin();
1392 it != resources.end(); 1360 it != resources.end();
1393 ++it) { 1361 ++it) {
1394 TransferableResource resource; 1362 TransferableResource resource;
1395 TransferResource(gl, *it, &resource); 1363 TransferResource(gl, *it, &resource);
1396 if (!resource.mailbox_holder.sync_point && !resource.is_software) 1364 if (!resource.mailbox_holder.sync_point && !resource.is_software)
1397 need_sync_point = true; 1365 need_sync_point = true;
1398 ++resources_.find(*it)->second.exported_count; 1366 ++resources_.find(*it)->second.exported_count;
1399 list->push_back(resource); 1367 list->push_back(resource);
1400 } 1368 }
1401 if (need_sync_point) { 1369 if (need_sync_point) {
1402 GLuint sync_point = gl->InsertSyncPointCHROMIUM(); 1370 GLuint sync_point = gl->InsertSyncPointCHROMIUM();
1403 for (TransferableResourceArray::iterator it = list->begin(); 1371 for (TransferableResourceArray::iterator it = list->begin();
1404 it != list->end(); 1372 it != list->end();
1405 ++it) { 1373 ++it) {
1406 if (!it->mailbox_holder.sync_point) 1374 if (!it->mailbox_holder.sync_point)
1407 it->mailbox_holder.sync_point = sync_point; 1375 it->mailbox_holder.sync_point = sync_point;
1408 } 1376 }
1409 } 1377 }
1410 } 1378 }
1411 1379
1412 void ResourceProvider::ReceiveFromChild( 1380 void ResourceProvider::ReceiveFromChild(
1413 int child, const TransferableResourceArray& resources) { 1381 int child, const TransferableResourceArray& resources) {
1414 DCHECK(thread_checker_.CalledOnValidThread()); 1382 DCHECK(thread_checker_.CalledOnValidThread());
1415 GLES2Interface* gl = ContextGL(); 1383 GLES2Interface* gl = resource_helper_->ContextGL();
1416 Child& child_info = children_.find(child)->second; 1384 Child& child_info = children_.find(child)->second;
1417 DCHECK(!child_info.marked_for_deletion); 1385 DCHECK(!child_info.marked_for_deletion);
1418 for (TransferableResourceArray::const_iterator it = resources.begin(); 1386 for (TransferableResourceArray::const_iterator it = resources.begin();
1419 it != resources.end(); 1387 it != resources.end();
1420 ++it) { 1388 ++it) {
1421 ResourceIdMap::iterator resource_in_map_it = 1389 ResourceIdMap::iterator resource_in_map_it =
1422 child_info.child_to_parent_map.find(it->id); 1390 child_info.child_to_parent_map.find(it->id);
1423 if (resource_in_map_it != child_info.child_to_parent_map.end()) { 1391 if (resource_in_map_it != child_info.child_to_parent_map.end()) {
1424 Resource& resource = resources_[resource_in_map_it->second]; 1392 Resource& resource = resources_[resource_in_map_it->second];
1425 resource.marked_for_deletion = false; 1393 resource.marked_for_deletion = false;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 const ResourceMap::iterator& a_it = a.second; 1475 const ResourceMap::iterator& a_it = a.second;
1508 const ResourceMap::iterator& b_it = b.second; 1476 const ResourceMap::iterator& b_it = b.second;
1509 const Resource& a_resource = a_it->second; 1477 const Resource& a_resource = a_it->second;
1510 const Resource& b_resource = b_it->second; 1478 const Resource& b_resource = b_it->second;
1511 return a_resource.child_id < b_resource.child_id; 1479 return a_resource.child_id < b_resource.child_id;
1512 } 1480 }
1513 1481
1514 void ResourceProvider::ReceiveReturnsFromParent( 1482 void ResourceProvider::ReceiveReturnsFromParent(
1515 const ReturnedResourceArray& resources) { 1483 const ReturnedResourceArray& resources) {
1516 DCHECK(thread_checker_.CalledOnValidThread()); 1484 DCHECK(thread_checker_.CalledOnValidThread());
1517 GLES2Interface* gl = ContextGL(); 1485 GLES2Interface* gl = resource_helper_->ContextGL();
1518 1486
1519 int child_id = 0; 1487 int child_id = 0;
1520 ResourceIdArray resources_for_child; 1488 ResourceIdArray resources_for_child;
1521 1489
1522 std::vector<std::pair<ReturnedResource, ResourceMap::iterator> > 1490 std::vector<std::pair<ReturnedResource, ResourceMap::iterator> >
1523 sorted_resources; 1491 sorted_resources;
1524 1492
1525 for (ReturnedResourceArray::const_iterator it = resources.begin(); 1493 for (ReturnedResourceArray::const_iterator it = resources.begin();
1526 it != resources.end(); 1494 it != resources.end();
1527 ++it) { 1495 ++it) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1666 const ResourceIdArray& unused) { 1634 const ResourceIdArray& unused) {
1667 DCHECK(thread_checker_.CalledOnValidThread()); 1635 DCHECK(thread_checker_.CalledOnValidThread());
1668 DCHECK(child_it != children_.end()); 1636 DCHECK(child_it != children_.end());
1669 Child* child_info = &child_it->second; 1637 Child* child_info = &child_it->second;
1670 1638
1671 if (unused.empty() && !child_info->marked_for_deletion) 1639 if (unused.empty() && !child_info->marked_for_deletion)
1672 return; 1640 return;
1673 1641
1674 ReturnedResourceArray to_return; 1642 ReturnedResourceArray to_return;
1675 1643
1676 GLES2Interface* gl = ContextGL(); 1644 GLES2Interface* gl = resource_helper_->ContextGL();
1677 bool need_sync_point = false; 1645 bool need_sync_point = false;
1678 for (size_t i = 0; i < unused.size(); ++i) { 1646 for (size_t i = 0; i < unused.size(); ++i) {
1679 ResourceId local_id = unused[i]; 1647 ResourceId local_id = unused[i];
1680 1648
1681 ResourceMap::iterator it = resources_.find(local_id); 1649 ResourceMap::iterator it = resources_.find(local_id);
1682 CHECK(it != resources_.end()); 1650 CHECK(it != resources_.end());
1683 Resource& resource = it->second; 1651 Resource& resource = it->second;
1684 1652
1685 DCHECK(!resource.locked_for_write); 1653 DCHECK(!resource.locked_for_write);
1686 DCHECK_EQ(0u, child_info->in_use_resources.count(local_id)); 1654 DCHECK_EQ(0u, child_info->in_use_resources.count(local_id));
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1811 void ResourceProvider::AcquirePixelBuffer(Resource* resource) { 1779 void ResourceProvider::AcquirePixelBuffer(Resource* resource) {
1812 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), 1780 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
1813 "ResourceProvider::AcquirePixelBuffer"); 1781 "ResourceProvider::AcquirePixelBuffer");
1814 1782
1815 DCHECK(resource->origin == Resource::Internal); 1783 DCHECK(resource->origin == Resource::Internal);
1816 DCHECK_EQ(resource->exported_count, 0); 1784 DCHECK_EQ(resource->exported_count, 0);
1817 DCHECK(!resource->image_id); 1785 DCHECK(!resource->image_id);
1818 DCHECK_NE(ETC1, resource->format); 1786 DCHECK_NE(ETC1, resource->format);
1819 1787
1820 DCHECK_EQ(GLTexture, resource->type); 1788 DCHECK_EQ(GLTexture, resource->type);
1821 GLES2Interface* gl = ContextGL(); 1789 GLES2Interface* gl = resource_helper_->ContextGL();
1822 DCHECK(gl); 1790 DCHECK(gl);
1823 if (!resource->gl_pixel_buffer_id) 1791 if (!resource->gl_pixel_buffer_id)
1824 resource->gl_pixel_buffer_id = buffer_id_allocator_->NextId(); 1792 resource->gl_pixel_buffer_id = buffer_id_allocator_->NextId();
1825 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 1793 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
1826 resource->gl_pixel_buffer_id); 1794 resource->gl_pixel_buffer_id);
1827 unsigned bytes_per_pixel = BitsPerPixel(resource->format) / 8; 1795 unsigned bytes_per_pixel = BitsPerPixel(resource->format) / 8;
1828 gl->BufferData(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 1796 gl->BufferData(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
1829 resource->size.height() * 1797 resource->size.height() *
1830 RoundUp(bytes_per_pixel * resource->size.width(), 4u), 1798 RoundUp(bytes_per_pixel * resource->size.width(), 4u),
1831 NULL, 1799 NULL,
(...skipping 17 matching lines...) Expand all
1849 // as each new query has a unique submit count. 1817 // as each new query has a unique submit count.
1850 if (resource->pending_set_pixels) { 1818 if (resource->pending_set_pixels) {
1851 DCHECK(resource->set_pixels_completion_forced); 1819 DCHECK(resource->set_pixels_completion_forced);
1852 resource->pending_set_pixels = false; 1820 resource->pending_set_pixels = false;
1853 resource->locked_for_write = false; 1821 resource->locked_for_write = false;
1854 } 1822 }
1855 1823
1856 DCHECK_EQ(GLTexture, resource->type); 1824 DCHECK_EQ(GLTexture, resource->type);
1857 if (!resource->gl_pixel_buffer_id) 1825 if (!resource->gl_pixel_buffer_id)
1858 return; 1826 return;
1859 GLES2Interface* gl = ContextGL(); 1827 GLES2Interface* gl = resource_helper_->ContextGL();
1860 DCHECK(gl); 1828 DCHECK(gl);
1861 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 1829 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
1862 resource->gl_pixel_buffer_id); 1830 resource->gl_pixel_buffer_id);
1863 gl->BufferData( 1831 gl->BufferData(
1864 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0, NULL, GL_DYNAMIC_DRAW); 1832 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0, NULL, GL_DYNAMIC_DRAW);
1865 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); 1833 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
1866 } 1834 }
1867 1835
1868 uint8_t* ResourceProvider::MapPixelBuffer(const Resource* resource, 1836 uint8_t* ResourceProvider::MapPixelBuffer(const Resource* resource,
1869 int* stride) { 1837 int* stride) {
1870 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), 1838 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
1871 "ResourceProvider::MapPixelBuffer"); 1839 "ResourceProvider::MapPixelBuffer");
1872 1840
1873 DCHECK(resource->origin == Resource::Internal); 1841 DCHECK(resource->origin == Resource::Internal);
1874 DCHECK_EQ(resource->exported_count, 0); 1842 DCHECK_EQ(resource->exported_count, 0);
1875 DCHECK(!resource->image_id); 1843 DCHECK(!resource->image_id);
1876 1844
1877 *stride = 0; 1845 *stride = 0;
1878 DCHECK_EQ(GLTexture, resource->type); 1846 DCHECK_EQ(GLTexture, resource->type);
1879 GLES2Interface* gl = ContextGL(); 1847 GLES2Interface* gl = resource_helper_->ContextGL();
1880 DCHECK(gl); 1848 DCHECK(gl);
1881 DCHECK(resource->gl_pixel_buffer_id); 1849 DCHECK(resource->gl_pixel_buffer_id);
1882 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 1850 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
1883 resource->gl_pixel_buffer_id); 1851 resource->gl_pixel_buffer_id);
1884 uint8_t* image = static_cast<uint8_t*>(gl->MapBufferCHROMIUM( 1852 uint8_t* image = static_cast<uint8_t*>(gl->MapBufferCHROMIUM(
1885 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, GL_WRITE_ONLY)); 1853 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, GL_WRITE_ONLY));
1886 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); 1854 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
1887 // Buffer is required to be 4-byte aligned. 1855 // Buffer is required to be 4-byte aligned.
1888 CHECK(!(reinterpret_cast<intptr_t>(image) & 3)); 1856 CHECK(!(reinterpret_cast<intptr_t>(image) & 3));
1889 return image; 1857 return image;
1890 } 1858 }
1891 1859
1892 void ResourceProvider::UnmapPixelBuffer(const Resource* resource) { 1860 void ResourceProvider::UnmapPixelBuffer(const Resource* resource) {
1893 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), 1861 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
1894 "ResourceProvider::UnmapPixelBuffer"); 1862 "ResourceProvider::UnmapPixelBuffer");
1895 1863
1896 DCHECK(resource->origin == Resource::Internal); 1864 DCHECK(resource->origin == Resource::Internal);
1897 DCHECK_EQ(resource->exported_count, 0); 1865 DCHECK_EQ(resource->exported_count, 0);
1898 DCHECK(!resource->image_id); 1866 DCHECK(!resource->image_id);
1899 1867
1900 DCHECK_EQ(GLTexture, resource->type); 1868 DCHECK_EQ(GLTexture, resource->type);
1901 GLES2Interface* gl = ContextGL(); 1869 GLES2Interface* gl = resource_helper_->ContextGL();
1902 DCHECK(gl); 1870 DCHECK(gl);
1903 DCHECK(resource->gl_pixel_buffer_id); 1871 DCHECK(resource->gl_pixel_buffer_id);
1904 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 1872 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
1905 resource->gl_pixel_buffer_id); 1873 resource->gl_pixel_buffer_id);
1906 gl->UnmapBufferCHROMIUM(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM); 1874 gl->UnmapBufferCHROMIUM(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM);
1907 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); 1875 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
1908 } 1876 }
1909 1877
1910 GLenum ResourceProvider::BindForSampling( 1878 GLenum ResourceProvider::BindForSampling(
1911 ResourceProvider::ResourceId resource_id, 1879 ResourceProvider::ResourceId resource_id,
1912 GLenum unit, 1880 GLenum unit,
1913 GLenum filter) { 1881 GLenum filter) {
1914 DCHECK(thread_checker_.CalledOnValidThread()); 1882 DCHECK(thread_checker_.CalledOnValidThread());
1915 GLES2Interface* gl = ContextGL(); 1883 GLES2Interface* gl = resource_helper_->ContextGL();
1916 ResourceMap::iterator it = resources_.find(resource_id); 1884 ResourceMap::iterator it = resources_.find(resource_id);
1917 DCHECK(it != resources_.end()); 1885 DCHECK(it != resources_.end());
1918 Resource* resource = &it->second; 1886 Resource* resource = &it->second;
1919 DCHECK(resource->lock_for_read_count); 1887 DCHECK(resource->lock_for_read_count);
1920 DCHECK(!resource->locked_for_write || resource->set_pixels_completion_forced); 1888 DCHECK(!resource->locked_for_write || resource->set_pixels_completion_forced);
1921 1889
1922 ScopedSetActiveTexture scoped_active_tex(gl, unit); 1890 ScopedSetActiveTexture scoped_active_tex(gl, unit);
1923 GLenum target = resource->target; 1891 GLenum target = resource->target;
1924 GLC(gl, gl->BindTexture(target, resource->gl_id)); 1892 GLC(gl, gl->BindTexture(target, resource->gl_id));
1925 if (filter != resource->filter) { 1893 if (filter != resource->filter) {
(...skipping 20 matching lines...) Expand all
1946 DCHECK(resource->gl_id || resource->allocated); 1914 DCHECK(resource->gl_id || resource->allocated);
1947 DCHECK(ReadLockFenceHasPassed(resource)); 1915 DCHECK(ReadLockFenceHasPassed(resource));
1948 DCHECK(!resource->image_id); 1916 DCHECK(!resource->image_id);
1949 1917
1950 bool allocate = !resource->allocated; 1918 bool allocate = !resource->allocated;
1951 resource->allocated = true; 1919 resource->allocated = true;
1952 LockForWrite(id); 1920 LockForWrite(id);
1953 1921
1954 DCHECK_EQ(GLTexture, resource->type); 1922 DCHECK_EQ(GLTexture, resource->type);
1955 DCHECK(resource->gl_id); 1923 DCHECK(resource->gl_id);
1956 GLES2Interface* gl = ContextGL(); 1924 GLES2Interface* gl = resource_helper_->ContextGL();
1957 DCHECK(gl); 1925 DCHECK(gl);
1958 DCHECK(resource->gl_pixel_buffer_id); 1926 DCHECK(resource->gl_pixel_buffer_id);
1959 DCHECK_EQ(resource->target, static_cast<GLenum>(GL_TEXTURE_2D)); 1927 DCHECK_EQ(resource->target, static_cast<GLenum>(GL_TEXTURE_2D));
1960 gl->BindTexture(GL_TEXTURE_2D, resource->gl_id); 1928 gl->BindTexture(GL_TEXTURE_2D, resource->gl_id);
1961 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 1929 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
1962 resource->gl_pixel_buffer_id); 1930 resource->gl_pixel_buffer_id);
1963 if (!resource->gl_upload_query_id) 1931 if (!resource->gl_upload_query_id)
1964 gl->GenQueriesEXT(1, &resource->gl_upload_query_id); 1932 gl->GenQueriesEXT(1, &resource->gl_upload_query_id);
1965 gl->BeginQueryEXT(GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM, 1933 gl->BeginQueryEXT(GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM,
1966 resource->gl_upload_query_id); 1934 resource->gl_upload_query_id);
(...skipping 28 matching lines...) Expand all
1995 void ResourceProvider::ForceSetPixelsToComplete(ResourceId id) { 1963 void ResourceProvider::ForceSetPixelsToComplete(ResourceId id) {
1996 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), 1964 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
1997 "ResourceProvider::ForceSetPixelsToComplete"); 1965 "ResourceProvider::ForceSetPixelsToComplete");
1998 1966
1999 Resource* resource = GetResource(id); 1967 Resource* resource = GetResource(id);
2000 DCHECK(resource->locked_for_write); 1968 DCHECK(resource->locked_for_write);
2001 DCHECK(resource->pending_set_pixels); 1969 DCHECK(resource->pending_set_pixels);
2002 DCHECK(!resource->set_pixels_completion_forced); 1970 DCHECK(!resource->set_pixels_completion_forced);
2003 1971
2004 if (resource->gl_id) { 1972 if (resource->gl_id) {
2005 GLES2Interface* gl = ContextGL(); 1973 GLES2Interface* gl = resource_helper_->ContextGL();
2006 GLC(gl, gl->BindTexture(GL_TEXTURE_2D, resource->gl_id)); 1974 GLC(gl, gl->BindTexture(GL_TEXTURE_2D, resource->gl_id));
2007 GLC(gl, gl->WaitAsyncTexImage2DCHROMIUM(GL_TEXTURE_2D)); 1975 GLC(gl, gl->WaitAsyncTexImage2DCHROMIUM(GL_TEXTURE_2D));
2008 GLC(gl, gl->BindTexture(GL_TEXTURE_2D, 0)); 1976 GLC(gl, gl->BindTexture(GL_TEXTURE_2D, 0));
2009 } 1977 }
2010 1978
2011 resource->set_pixels_completion_forced = true; 1979 resource->set_pixels_completion_forced = true;
2012 } 1980 }
2013 1981
2014 bool ResourceProvider::DidSetPixelsComplete(ResourceId id) { 1982 bool ResourceProvider::DidSetPixelsComplete(ResourceId id) {
2015 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), 1983 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
2016 "ResourceProvider::DidSetPixelsComplete"); 1984 "ResourceProvider::DidSetPixelsComplete");
2017 1985
2018 Resource* resource = GetResource(id); 1986 Resource* resource = GetResource(id);
2019 DCHECK(resource->locked_for_write); 1987 DCHECK(resource->locked_for_write);
2020 DCHECK(resource->pending_set_pixels); 1988 DCHECK(resource->pending_set_pixels);
2021 1989
2022 if (resource->gl_id) { 1990 if (resource->gl_id) {
2023 GLES2Interface* gl = ContextGL(); 1991 GLES2Interface* gl = resource_helper_->ContextGL();
2024 DCHECK(gl); 1992 DCHECK(gl);
2025 DCHECK(resource->gl_upload_query_id); 1993 DCHECK(resource->gl_upload_query_id);
2026 GLuint complete = 1; 1994 GLuint complete = 1;
2027 gl->GetQueryObjectuivEXT( 1995 gl->GetQueryObjectuivEXT(
2028 resource->gl_upload_query_id, GL_QUERY_RESULT_AVAILABLE_EXT, &complete); 1996 resource->gl_upload_query_id, GL_QUERY_RESULT_AVAILABLE_EXT, &complete);
2029 if (!complete) 1997 if (!complete)
2030 return false; 1998 return false;
2031 } 1999 }
2032 2000
2033 resource->pending_set_pixels = false; 2001 resource->pending_set_pixels = false;
(...skipping 16 matching lines...) Expand all
2050 return; 2018 return;
2051 2019
2052 if (resource->gl_id) 2020 if (resource->gl_id)
2053 return; 2021 return;
2054 2022
2055 DCHECK(resource->texture_pool); 2023 DCHECK(resource->texture_pool);
2056 DCHECK(resource->origin == Resource::Internal); 2024 DCHECK(resource->origin == Resource::Internal);
2057 DCHECK(!resource->mailbox.IsValid()); 2025 DCHECK(!resource->mailbox.IsValid());
2058 resource->gl_id = texture_id_allocator_->NextId(); 2026 resource->gl_id = texture_id_allocator_->NextId();
2059 2027
2060 GLES2Interface* gl = ContextGL(); 2028 GLES2Interface* gl = resource_helper_->ContextGL();
2061 DCHECK(gl); 2029 DCHECK(gl);
2062 2030
2063 // Create and set texture properties. Allocation is delayed until needed. 2031 // Create and set texture properties. Allocation is delayed until needed.
2064 GLC(gl, gl->BindTexture(resource->target, resource->gl_id)); 2032 GLC(gl, gl->BindTexture(resource->target, resource->gl_id));
2065 GLC(gl, 2033 GLC(gl,
2066 gl->TexParameteri(resource->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); 2034 gl->TexParameteri(resource->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
2067 GLC(gl, 2035 GLC(gl,
2068 gl->TexParameteri(resource->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); 2036 gl->TexParameteri(resource->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
2069 GLC(gl, 2037 GLC(gl,
2070 gl->TexParameteri( 2038 gl->TexParameteri(
(...skipping 17 matching lines...) Expand all
2088 } 2056 }
2089 2057
2090 void ResourceProvider::LazyAllocate(Resource* resource) { 2058 void ResourceProvider::LazyAllocate(Resource* resource) {
2091 DCHECK(resource); 2059 DCHECK(resource);
2092 LazyCreate(resource); 2060 LazyCreate(resource);
2093 2061
2094 DCHECK(resource->gl_id || resource->allocated); 2062 DCHECK(resource->gl_id || resource->allocated);
2095 if (resource->allocated || !resource->gl_id) 2063 if (resource->allocated || !resource->gl_id)
2096 return; 2064 return;
2097 resource->allocated = true; 2065 resource->allocated = true;
2098 GLES2Interface* gl = ContextGL(); 2066 GLES2Interface* gl = resource_helper_->ContextGL();
2099 gfx::Size& size = resource->size; 2067 gfx::Size& size = resource->size;
2100 DCHECK_EQ(resource->target, static_cast<GLenum>(GL_TEXTURE_2D)); 2068 DCHECK_EQ(resource->target, static_cast<GLenum>(GL_TEXTURE_2D));
2101 ResourceFormat format = resource->format; 2069 ResourceFormat format = resource->format;
2102 GLC(gl, gl->BindTexture(GL_TEXTURE_2D, resource->gl_id)); 2070 GLC(gl, gl->BindTexture(GL_TEXTURE_2D, resource->gl_id));
2103 if (use_texture_storage_ext_ && IsFormatSupportedForStorage(format) && 2071 if (use_texture_storage_ext_ && IsFormatSupportedForStorage(format) &&
2104 resource->hint != TextureUsageFramebuffer) { 2072 resource->hint != TextureUsageFramebuffer) {
2105 GLenum storage_format = TextureToStorageFormat(format); 2073 GLenum storage_format = TextureToStorageFormat(format);
2106 GLC(gl, 2074 GLC(gl,
2107 gl->TexStorage2DEXT( 2075 gl->TexStorage2DEXT(
2108 GL_TEXTURE_2D, 1, storage_format, size.width(), size.height())); 2076 GL_TEXTURE_2D, 1, storage_format, size.width(), size.height()));
2109 } else { 2077 } else {
2110 // ETC1 does not support preallocation. 2078 // ETC1 does not support preallocation.
2111 if (format != ETC1) { 2079 if (format != ETC1) {
2112 GLC(gl, 2080 GLC(gl,
2113 gl->TexImage2D(GL_TEXTURE_2D, 2081 gl->TexImage2D(GL_TEXTURE_2D,
2114 0, 2082 0,
2115 GLInternalFormat(format), 2083 GLInternalFormat(format),
2116 size.width(), 2084 size.width(),
2117 size.height(), 2085 size.height(),
2118 0, 2086 0,
2119 GLDataFormat(format), 2087 GLDataFormat(format),
2120 GLDataType(format), 2088 GLDataType(format),
2121 NULL)); 2089 NULL));
2122 } 2090 }
2123 } 2091 }
2124 } 2092 }
2125 2093
2126 void ResourceProvider::BindImageForSampling(Resource* resource) { 2094 void ResourceProvider::BindImageForSampling(Resource* resource) {
2127 GLES2Interface* gl = ContextGL(); 2095 GLES2Interface* gl = resource_helper_->ContextGL();
2128 DCHECK(resource->gl_id); 2096 DCHECK(resource->gl_id);
2129 DCHECK(resource->image_id); 2097 DCHECK(resource->image_id);
2130 2098
2131 // Release image currently bound to texture. 2099 // Release image currently bound to texture.
2132 if (resource->bound_image_id) 2100 if (resource->bound_image_id)
2133 gl->ReleaseTexImage2DCHROMIUM(resource->target, resource->bound_image_id); 2101 gl->ReleaseTexImage2DCHROMIUM(resource->target, resource->bound_image_id);
2134 gl->BindTexImage2DCHROMIUM(resource->target, resource->image_id); 2102 gl->BindTexImage2DCHROMIUM(resource->target, resource->image_id);
2135 resource->bound_image_id = resource->image_id; 2103 resource->bound_image_id = resource->image_id;
2136 resource->dirty_image = false; 2104 resource->dirty_image = false;
2137 } 2105 }
2138 2106
2139 void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id, 2107 void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id,
2140 bool enable) { 2108 bool enable) {
2141 Resource* resource = GetResource(id); 2109 Resource* resource = GetResource(id);
2142 resource->enable_read_lock_fences = enable; 2110 resource->enable_read_lock_fences = enable;
2143 } 2111 }
2144 2112
2145 void ResourceProvider::AcquireImage(Resource* resource) { 2113 void ResourceProvider::AcquireImage(Resource* resource) {
2146 DCHECK(resource->origin == Resource::Internal); 2114 DCHECK(resource->origin == Resource::Internal);
2147 DCHECK_EQ(resource->exported_count, 0); 2115 DCHECK_EQ(resource->exported_count, 0);
2148 2116
2149 if (resource->type != GLTexture) 2117 if (resource->type != GLTexture)
2150 return; 2118 return;
2151 2119
2152 if (resource->image_id) 2120 if (resource->image_id)
2153 return; 2121 return;
2154 2122
2155 resource->allocated = true; 2123 resource->allocated = true;
2156 GLES2Interface* gl = ContextGL(); 2124 GLES2Interface* gl = resource_helper_->ContextGL();
2157 DCHECK(gl); 2125 DCHECK(gl);
2158 resource->image_id = 2126 resource->image_id =
2159 gl->CreateImageCHROMIUM(resource->size.width(), 2127 gl->CreateImageCHROMIUM(resource->size.width(),
2160 resource->size.height(), 2128 resource->size.height(),
2161 TextureToStorageFormat(resource->format), 2129 TextureToStorageFormat(resource->format),
2162 GL_IMAGE_MAP_CHROMIUM); 2130 GL_IMAGE_MAP_CHROMIUM);
2163 DCHECK(resource->image_id); 2131 DCHECK(resource->image_id);
2164 } 2132 }
2165 2133
2166 void ResourceProvider::ReleaseImage(Resource* resource) { 2134 void ResourceProvider::ReleaseImage(Resource* resource) {
2167 DCHECK(resource->origin == Resource::Internal); 2135 DCHECK(resource->origin == Resource::Internal);
2168 DCHECK_EQ(resource->exported_count, 0); 2136 DCHECK_EQ(resource->exported_count, 0);
2169 2137
2170 if (!resource->image_id) 2138 if (!resource->image_id)
2171 return; 2139 return;
2172 2140
2173 GLES2Interface* gl = ContextGL(); 2141 GLES2Interface* gl = resource_helper_->ContextGL();
2174 DCHECK(gl); 2142 DCHECK(gl);
2175 gl->DestroyImageCHROMIUM(resource->image_id); 2143 gl->DestroyImageCHROMIUM(resource->image_id);
2176 resource->image_id = 0; 2144 resource->image_id = 0;
2177 resource->bound_image_id = 0; 2145 resource->bound_image_id = 0;
2178 resource->dirty_image = false; 2146 resource->dirty_image = false;
2179 resource->allocated = false; 2147 resource->allocated = false;
2180 } 2148 }
2181 2149
2182 uint8_t* ResourceProvider::MapImage(const Resource* resource, int* stride) { 2150 uint8_t* ResourceProvider::MapImage(const Resource* resource, int* stride) {
2183 DCHECK(ReadLockFenceHasPassed(resource)); 2151 DCHECK(ReadLockFenceHasPassed(resource));
2184 DCHECK(resource->origin == Resource::Internal); 2152 DCHECK(resource->origin == Resource::Internal);
2185 DCHECK_EQ(resource->exported_count, 0); 2153 DCHECK_EQ(resource->exported_count, 0);
2186 2154
2187 if (resource->type == GLTexture) { 2155 if (resource->type == GLTexture) {
2188 DCHECK(resource->image_id); 2156 DCHECK(resource->image_id);
2189 GLES2Interface* gl = ContextGL(); 2157 GLES2Interface* gl = resource_helper_->ContextGL();
2190 DCHECK(gl); 2158 DCHECK(gl);
2191 // MapImageCHROMIUM should be called prior to GetImageParameterivCHROMIUM. 2159 // MapImageCHROMIUM should be called prior to GetImageParameterivCHROMIUM.
2192 uint8_t* pixels = 2160 uint8_t* pixels =
2193 static_cast<uint8_t*>(gl->MapImageCHROMIUM(resource->image_id)); 2161 static_cast<uint8_t*>(gl->MapImageCHROMIUM(resource->image_id));
2194 gl->GetImageParameterivCHROMIUM( 2162 gl->GetImageParameterivCHROMIUM(
2195 resource->image_id, GL_IMAGE_ROWBYTES_CHROMIUM, stride); 2163 resource->image_id, GL_IMAGE_ROWBYTES_CHROMIUM, stride);
2196 return pixels; 2164 return pixels;
2197 } 2165 }
2198 DCHECK_EQ(Bitmap, resource->type); 2166 DCHECK_EQ(Bitmap, resource->type);
2199 *stride = 0; 2167 *stride = 0;
2200 return resource->pixels; 2168 return resource->pixels;
2201 } 2169 }
2202 2170
2203 void ResourceProvider::UnmapImage(const Resource* resource) { 2171 void ResourceProvider::UnmapImage(const Resource* resource) {
2204 DCHECK(resource->origin == Resource::Internal); 2172 DCHECK(resource->origin == Resource::Internal);
2205 DCHECK_EQ(resource->exported_count, 0); 2173 DCHECK_EQ(resource->exported_count, 0);
2206 2174
2207 if (resource->image_id) { 2175 if (resource->image_id) {
2208 GLES2Interface* gl = ContextGL(); 2176 GLES2Interface* gl = resource_helper_->ContextGL();
2209 DCHECK(gl); 2177 DCHECK(gl);
2210 gl->UnmapImageCHROMIUM(resource->image_id); 2178 gl->UnmapImageCHROMIUM(resource->image_id);
2211 } 2179 }
2212 } 2180 }
2213 2181
2214 void ResourceProvider::CopyResource(ResourceId source_id, ResourceId dest_id) { 2182 void ResourceProvider::CopyResource(ResourceId source_id, ResourceId dest_id) {
2215 TRACE_EVENT0("cc", "ResourceProvider::CopyResource"); 2183 TRACE_EVENT0("cc", "ResourceProvider::CopyResource");
2216 2184
2217 Resource* source_resource = GetResource(source_id); 2185 Resource* source_resource = GetResource(source_id);
2218 DCHECK(!source_resource->lock_for_read_count); 2186 DCHECK(!source_resource->lock_for_read_count);
2219 DCHECK(source_resource->origin == Resource::Internal); 2187 DCHECK(source_resource->origin == Resource::Internal);
2220 DCHECK_EQ(source_resource->exported_count, 0); 2188 DCHECK_EQ(source_resource->exported_count, 0);
2221 DCHECK(source_resource->allocated); 2189 DCHECK(source_resource->allocated);
2222 LazyCreate(source_resource); 2190 LazyCreate(source_resource);
2223 2191
2224 Resource* dest_resource = GetResource(dest_id); 2192 Resource* dest_resource = GetResource(dest_id);
2225 DCHECK(!dest_resource->locked_for_write); 2193 DCHECK(!dest_resource->locked_for_write);
2226 DCHECK(!dest_resource->lock_for_read_count); 2194 DCHECK(!dest_resource->lock_for_read_count);
2227 DCHECK(dest_resource->origin == Resource::Internal); 2195 DCHECK(dest_resource->origin == Resource::Internal);
2228 DCHECK_EQ(dest_resource->exported_count, 0); 2196 DCHECK_EQ(dest_resource->exported_count, 0);
2229 LazyCreate(dest_resource); 2197 LazyCreate(dest_resource);
2230 2198
2231 DCHECK_EQ(source_resource->type, dest_resource->type); 2199 DCHECK_EQ(source_resource->type, dest_resource->type);
2232 DCHECK_EQ(source_resource->format, dest_resource->format); 2200 DCHECK_EQ(source_resource->format, dest_resource->format);
2233 DCHECK(source_resource->size == dest_resource->size); 2201 DCHECK(source_resource->size == dest_resource->size);
2234 2202
2235 if (source_resource->type == GLTexture) { 2203 if (source_resource->type == GLTexture) {
2236 GLES2Interface* gl = ContextGL(); 2204 GLES2Interface* gl = resource_helper_->ContextGL();
2237 DCHECK(gl); 2205 DCHECK(gl);
2238 if (source_resource->image_id && source_resource->dirty_image) { 2206 if (source_resource->image_id && source_resource->dirty_image) {
2239 gl->BindTexture(source_resource->target, source_resource->gl_id); 2207 gl->BindTexture(source_resource->target, source_resource->gl_id);
2240 BindImageForSampling(source_resource); 2208 BindImageForSampling(source_resource);
2241 } 2209 }
2242 DCHECK(use_sync_query_) << "CHROMIUM_sync_query extension missing"; 2210 DCHECK(use_sync_query_) << "CHROMIUM_sync_query extension missing";
2243 if (!source_resource->gl_read_lock_query_id) 2211 if (!source_resource->gl_read_lock_query_id)
2244 gl->GenQueriesEXT(1, &source_resource->gl_read_lock_query_id); 2212 gl->GenQueriesEXT(1, &source_resource->gl_read_lock_query_id);
2245 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, 2213 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM,
2246 source_resource->gl_read_lock_query_id); 2214 source_resource->gl_read_lock_query_id);
(...skipping 13 matching lines...) Expand all
2260 } else { 2228 } else {
2261 DCHECK_EQ(Bitmap, source_resource->type); 2229 DCHECK_EQ(Bitmap, source_resource->type);
2262 DCHECK_EQ(RGBA_8888, source_resource->format); 2230 DCHECK_EQ(RGBA_8888, source_resource->format);
2263 LazyAllocate(dest_resource); 2231 LazyAllocate(dest_resource);
2264 2232
2265 size_t bytes = SharedBitmap::CheckedSizeInBytes(source_resource->size); 2233 size_t bytes = SharedBitmap::CheckedSizeInBytes(source_resource->size);
2266 memcpy(dest_resource->pixels, source_resource->pixels, bytes); 2234 memcpy(dest_resource->pixels, source_resource->pixels, bytes);
2267 } 2235 }
2268 } 2236 }
2269 2237
2270 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) {
2271 GLint active_unit = 0;
2272 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit);
2273 return active_unit;
2274 }
2275
2276 GLES2Interface* ResourceProvider::ContextGL() const {
2277 ContextProvider* context_provider = output_surface_->context_provider();
2278 return context_provider ? context_provider->ContextGL() : NULL;
2279 }
2280
2281 class GrContext* ResourceProvider::GrContext() const {
2282 ContextProvider* context_provider = output_surface_->context_provider();
2283 return context_provider ? context_provider->GrContext() : NULL;
2284 }
2285
2286 void ResourceProvider::BeginGpuRaster() {
2287 GLES2Interface* gl = ContextGL();
2288 DCHECK(gl);
2289
2290 // TODO(alokp): Use a trace macro to push/pop markers.
2291 // Using push/pop functions directly incurs cost to evaluate function
2292 // arguments even when tracing is disabled.
2293 gl->PushGroupMarkerEXT(0, "GpuRasterization");
2294
2295 class GrContext* gr_context = GrContext();
2296 if (gr_context)
2297 gr_context->resetContext();
2298 }
2299
2300 void ResourceProvider::EndGpuRaster() {
2301 GLES2Interface* gl = ContextGL();
2302 DCHECK(gl);
2303
2304 class GrContext* gr_context = GrContext();
2305 if (gr_context)
2306 gr_context->flush();
2307
2308 // TODO(alokp): Use a trace macro to push/pop markers.
2309 // Using push/pop functions directly incurs cost to evaluate function
2310 // arguments even when tracing is disabled.
2311 gl->PopGroupMarkerEXT();
2312 }
2313
2314 } // namespace cc 2238 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698