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/atomic_sequence_num.h" | 10 #include "base/atomic_sequence_num.h" |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 | 317 |
318 ResourceProvider::Child::~Child() {} | 318 ResourceProvider::Child::~Child() {} |
319 | 319 |
320 scoped_ptr<ResourceProvider> ResourceProvider::Create( | 320 scoped_ptr<ResourceProvider> ResourceProvider::Create( |
321 OutputSurface* output_surface, | 321 OutputSurface* output_surface, |
322 SharedBitmapManager* shared_bitmap_manager, | 322 SharedBitmapManager* shared_bitmap_manager, |
323 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 323 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
324 BlockingTaskRunner* blocking_main_thread_task_runner, | 324 BlockingTaskRunner* blocking_main_thread_task_runner, |
325 int highp_threshold_min, | 325 int highp_threshold_min, |
326 size_t id_allocation_chunk_size, | 326 size_t id_allocation_chunk_size, |
| 327 bool use_gpu_memory_buffer_resources, |
327 const std::vector<unsigned>& use_image_texture_targets) { | 328 const std::vector<unsigned>& use_image_texture_targets) { |
328 scoped_ptr<ResourceProvider> resource_provider(new ResourceProvider( | 329 scoped_ptr<ResourceProvider> resource_provider(new ResourceProvider( |
329 output_surface, shared_bitmap_manager, gpu_memory_buffer_manager, | 330 output_surface, shared_bitmap_manager, gpu_memory_buffer_manager, |
330 blocking_main_thread_task_runner, highp_threshold_min, | 331 blocking_main_thread_task_runner, highp_threshold_min, |
331 id_allocation_chunk_size, use_image_texture_targets)); | 332 id_allocation_chunk_size, use_gpu_memory_buffer_resources, |
| 333 use_image_texture_targets)); |
332 resource_provider->Initialize(); | 334 resource_provider->Initialize(); |
333 return resource_provider; | 335 return resource_provider; |
334 } | 336 } |
335 | 337 |
336 ResourceProvider::~ResourceProvider() { | 338 ResourceProvider::~ResourceProvider() { |
337 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( | 339 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( |
338 this); | 340 this); |
339 | 341 |
340 while (!children_.empty()) | 342 while (!children_.empty()) |
341 DestroyChildInternal(children_.begin(), FOR_SHUTDOWN); | 343 DestroyChildInternal(children_.begin(), FOR_SHUTDOWN); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 DCHECK(resource); | 381 DCHECK(resource); |
380 resource->lost = true; | 382 resource->lost = true; |
381 } | 383 } |
382 | 384 |
383 ResourceId ResourceProvider::CreateResource(const gfx::Size& size, | 385 ResourceId ResourceProvider::CreateResource(const gfx::Size& size, |
384 TextureHint hint, | 386 TextureHint hint, |
385 ResourceFormat format) { | 387 ResourceFormat format) { |
386 DCHECK(!size.IsEmpty()); | 388 DCHECK(!size.IsEmpty()); |
387 switch (default_resource_type_) { | 389 switch (default_resource_type_) { |
388 case RESOURCE_TYPE_GL_TEXTURE: | 390 case RESOURCE_TYPE_GL_TEXTURE: |
389 return CreateGLTexture(size, | 391 return CreateGLTexture(size, use_gpu_memory_buffer_resources_ |
390 GL_TEXTURE_2D, | 392 ? GetImageTextureTarget(format) |
391 hint, | 393 : GL_TEXTURE_2D, |
392 format); | 394 hint, format); |
393 case RESOURCE_TYPE_BITMAP: | 395 case RESOURCE_TYPE_BITMAP: |
394 DCHECK_EQ(RGBA_8888, format); | 396 DCHECK_EQ(RGBA_8888, format); |
395 return CreateBitmap(size); | 397 return CreateBitmap(size); |
396 } | 398 } |
397 | 399 |
398 LOG(FATAL) << "Invalid default resource type."; | 400 LOG(FATAL) << "Invalid default resource type."; |
399 return 0; | 401 return 0; |
400 } | 402 } |
401 | 403 |
402 ResourceId ResourceProvider::CreateResourceWithImageTextureTarget( | 404 ResourceId ResourceProvider::CreateResourceWithImageTextureTarget( |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 } | 811 } |
810 | 812 |
811 ResourceProvider::ScopedWriteLockGL::ScopedWriteLockGL( | 813 ResourceProvider::ScopedWriteLockGL::ScopedWriteLockGL( |
812 ResourceProvider* resource_provider, | 814 ResourceProvider* resource_provider, |
813 ResourceId resource_id) | 815 ResourceId resource_id) |
814 : resource_provider_(resource_provider), | 816 : resource_provider_(resource_provider), |
815 resource_(resource_provider->LockForWrite(resource_id)) { | 817 resource_(resource_provider->LockForWrite(resource_id)) { |
816 resource_provider_->LazyAllocate(resource_); | 818 resource_provider_->LazyAllocate(resource_); |
817 texture_id_ = resource_->gl_id; | 819 texture_id_ = resource_->gl_id; |
818 DCHECK(texture_id_); | 820 DCHECK(texture_id_); |
| 821 if (resource_->dirty_image) |
| 822 resource_provider_->BindImageForSampling(resource_); |
819 } | 823 } |
820 | 824 |
821 ResourceProvider::ScopedWriteLockGL::~ScopedWriteLockGL() { | 825 ResourceProvider::ScopedWriteLockGL::~ScopedWriteLockGL() { |
822 resource_provider_->UnlockForWrite(resource_); | 826 resource_provider_->UnlockForWrite(resource_); |
823 } | 827 } |
824 | 828 |
825 void ResourceProvider::PopulateSkBitmapWithResource( | 829 void ResourceProvider::PopulateSkBitmapWithResource( |
826 SkBitmap* sk_bitmap, const Resource* resource) { | 830 SkBitmap* sk_bitmap, const Resource* resource) { |
827 DCHECK_EQ(RGBA_8888, resource->format); | 831 DCHECK_EQ(RGBA_8888, resource->format); |
828 SkImageInfo info = SkImageInfo::MakeN32Premul(resource->size.width(), | 832 SkImageInfo info = SkImageInfo::MakeN32Premul(resource->size.width(), |
(...skipping 24 matching lines...) Expand all Loading... |
853 | 857 |
854 ResourceProvider::ScopedWriteLockSoftware::~ScopedWriteLockSoftware() { | 858 ResourceProvider::ScopedWriteLockSoftware::~ScopedWriteLockSoftware() { |
855 DCHECK(thread_checker_.CalledOnValidThread()); | 859 DCHECK(thread_checker_.CalledOnValidThread()); |
856 resource_provider_->UnlockForWrite(resource_); | 860 resource_provider_->UnlockForWrite(resource_); |
857 } | 861 } |
858 | 862 |
859 ResourceProvider::ScopedWriteLockGpuMemoryBuffer:: | 863 ResourceProvider::ScopedWriteLockGpuMemoryBuffer:: |
860 ScopedWriteLockGpuMemoryBuffer(ResourceProvider* resource_provider, | 864 ScopedWriteLockGpuMemoryBuffer(ResourceProvider* resource_provider, |
861 ResourceId resource_id) | 865 ResourceId resource_id) |
862 : resource_provider_(resource_provider), | 866 : resource_provider_(resource_provider), |
863 resource_(resource_provider->LockForWrite(resource_id)), | 867 resource_(resource_provider->LockForWrite(resource_id)) { |
864 gpu_memory_buffer_manager_(resource_provider->gpu_memory_buffer_manager_), | |
865 gpu_memory_buffer_(nullptr), | |
866 size_(resource_->size), | |
867 format_(resource_->format) { | |
868 DCHECK_EQ(RESOURCE_TYPE_GL_TEXTURE, resource_->type); | 868 DCHECK_EQ(RESOURCE_TYPE_GL_TEXTURE, resource_->type); |
869 std::swap(gpu_memory_buffer_, resource_->gpu_memory_buffer); | 869 gpu_memory_buffer_.reset(resource_->gpu_memory_buffer); |
| 870 resource_->gpu_memory_buffer = nullptr; |
870 } | 871 } |
871 | 872 |
872 ResourceProvider::ScopedWriteLockGpuMemoryBuffer:: | 873 ResourceProvider::ScopedWriteLockGpuMemoryBuffer:: |
873 ~ScopedWriteLockGpuMemoryBuffer() { | 874 ~ScopedWriteLockGpuMemoryBuffer() { |
874 DCHECK(thread_checker_.CalledOnValidThread()); | 875 DCHECK(thread_checker_.CalledOnValidThread()); |
875 resource_provider_->UnlockForWrite(resource_); | 876 resource_provider_->UnlockForWrite(resource_); |
876 if (!gpu_memory_buffer_) | 877 if (!gpu_memory_buffer_) |
877 return; | 878 return; |
878 | 879 |
| 880 DCHECK(!resource_->gpu_memory_buffer); |
879 resource_provider_->LazyCreate(resource_); | 881 resource_provider_->LazyCreate(resource_); |
880 | 882 resource_->gpu_memory_buffer = gpu_memory_buffer_.release(); |
881 if (!resource_->image_id) { | |
882 GLES2Interface* gl = resource_provider_->ContextGL(); | |
883 DCHECK(gl); | |
884 | |
885 #if defined(OS_CHROMEOS) | |
886 // TODO(reveman): GL_COMMANDS_ISSUED_CHROMIUM is used for synchronization | |
887 // on ChromeOS to avoid some performance issues. This only works with | |
888 // shared memory backed buffers. crbug.com/436314 | |
889 DCHECK_EQ(gpu_memory_buffer_->GetHandle().type, gfx::SHARED_MEMORY_BUFFER); | |
890 #endif | |
891 | |
892 resource_->image_id = gl->CreateImageCHROMIUM( | |
893 gpu_memory_buffer_->AsClientBuffer(), size_.width(), size_.height(), | |
894 GLInternalFormat(resource_->format)); | |
895 } | |
896 | |
897 std::swap(resource_->gpu_memory_buffer, gpu_memory_buffer_); | |
898 resource_->allocated = true; | 883 resource_->allocated = true; |
| 884 resource_provider_->LazyCreateImage(resource_); |
899 resource_->dirty_image = true; | 885 resource_->dirty_image = true; |
| 886 resource_->is_overlay_candidate = true; |
900 | 887 |
901 // GpuMemoryBuffer provides direct access to the memory used by the GPU. | 888 // GpuMemoryBuffer provides direct access to the memory used by the GPU. |
902 // Read lock fences are required to ensure that we're not trying to map a | 889 // Read lock fences are required to ensure that we're not trying to map a |
903 // buffer that is currently in-use by the GPU. | 890 // buffer that is currently in-use by the GPU. |
904 resource_->read_lock_fences_enabled = true; | 891 resource_->read_lock_fences_enabled = true; |
905 } | 892 } |
906 | 893 |
907 gfx::GpuMemoryBuffer* | 894 gfx::GpuMemoryBuffer* |
908 ResourceProvider::ScopedWriteLockGpuMemoryBuffer::GetGpuMemoryBuffer() { | 895 ResourceProvider::ScopedWriteLockGpuMemoryBuffer::GetGpuMemoryBuffer() { |
909 if (gpu_memory_buffer_) | 896 if (!gpu_memory_buffer_) { |
910 return gpu_memory_buffer_; | 897 gpu_memory_buffer_ = |
911 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer = | 898 resource_provider_->gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( |
912 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( | 899 resource_->size, BufferFormat(resource_->format), |
913 size_, BufferFormat(format_), | 900 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE); |
914 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE); | 901 } |
915 gpu_memory_buffer_ = gpu_memory_buffer.release(); | 902 return gpu_memory_buffer_.get(); |
916 return gpu_memory_buffer_; | |
917 } | 903 } |
918 | 904 |
919 ResourceProvider::ScopedWriteLockGr::ScopedWriteLockGr( | 905 ResourceProvider::ScopedWriteLockGr::ScopedWriteLockGr( |
920 ResourceProvider* resource_provider, | 906 ResourceProvider* resource_provider, |
921 ResourceId resource_id) | 907 ResourceId resource_id) |
922 : resource_provider_(resource_provider), | 908 : resource_provider_(resource_provider), |
923 resource_(resource_provider->LockForWrite(resource_id)) { | 909 resource_(resource_provider->LockForWrite(resource_id)) { |
924 DCHECK(thread_checker_.CalledOnValidThread()); | 910 DCHECK(thread_checker_.CalledOnValidThread()); |
925 resource_provider_->LazyAllocate(resource_); | 911 resource_provider_->LazyAllocate(resource_); |
926 } | 912 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 gl_->Finish(); | 981 gl_->Finish(); |
996 } | 982 } |
997 | 983 |
998 ResourceProvider::ResourceProvider( | 984 ResourceProvider::ResourceProvider( |
999 OutputSurface* output_surface, | 985 OutputSurface* output_surface, |
1000 SharedBitmapManager* shared_bitmap_manager, | 986 SharedBitmapManager* shared_bitmap_manager, |
1001 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 987 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
1002 BlockingTaskRunner* blocking_main_thread_task_runner, | 988 BlockingTaskRunner* blocking_main_thread_task_runner, |
1003 int highp_threshold_min, | 989 int highp_threshold_min, |
1004 size_t id_allocation_chunk_size, | 990 size_t id_allocation_chunk_size, |
| 991 bool use_gpu_memory_buffer_resources, |
1005 const std::vector<unsigned>& use_image_texture_targets) | 992 const std::vector<unsigned>& use_image_texture_targets) |
1006 : output_surface_(output_surface), | 993 : output_surface_(output_surface), |
1007 shared_bitmap_manager_(shared_bitmap_manager), | 994 shared_bitmap_manager_(shared_bitmap_manager), |
1008 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 995 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
1009 blocking_main_thread_task_runner_(blocking_main_thread_task_runner), | 996 blocking_main_thread_task_runner_(blocking_main_thread_task_runner), |
1010 lost_output_surface_(false), | 997 lost_output_surface_(false), |
1011 highp_threshold_min_(highp_threshold_min), | 998 highp_threshold_min_(highp_threshold_min), |
1012 next_id_(1), | 999 next_id_(1), |
1013 next_child_(1), | 1000 next_child_(1), |
1014 default_resource_type_(RESOURCE_TYPE_BITMAP), | 1001 default_resource_type_(RESOURCE_TYPE_BITMAP), |
| 1002 use_gpu_memory_buffer_resources_(use_gpu_memory_buffer_resources), |
1015 use_texture_storage_ext_(false), | 1003 use_texture_storage_ext_(false), |
1016 use_texture_format_bgra_(false), | 1004 use_texture_format_bgra_(false), |
1017 use_texture_usage_hint_(false), | 1005 use_texture_usage_hint_(false), |
1018 use_compressed_texture_etc1_(false), | 1006 use_compressed_texture_etc1_(false), |
1019 yuv_resource_format_(LUMINANCE_8), | 1007 yuv_resource_format_(LUMINANCE_8), |
1020 max_texture_size_(0), | 1008 max_texture_size_(0), |
1021 best_texture_format_(RGBA_8888), | 1009 best_texture_format_(RGBA_8888), |
1022 best_render_buffer_format_(RGBA_8888), | 1010 best_render_buffer_format_(RGBA_8888), |
1023 id_allocation_chunk_size_(id_allocation_chunk_size), | 1011 id_allocation_chunk_size_(id_allocation_chunk_size), |
1024 use_sync_query_(false), | 1012 use_sync_query_(false), |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1302 resource->read_lock_fences_enabled = source->read_lock_fences_enabled; | 1290 resource->read_lock_fences_enabled = source->read_lock_fences_enabled; |
1303 resource->is_overlay_candidate = source->is_overlay_candidate; | 1291 resource->is_overlay_candidate = source->is_overlay_candidate; |
1304 | 1292 |
1305 if (source->type == RESOURCE_TYPE_BITMAP) { | 1293 if (source->type == RESOURCE_TYPE_BITMAP) { |
1306 resource->mailbox_holder.mailbox = source->shared_bitmap_id; | 1294 resource->mailbox_holder.mailbox = source->shared_bitmap_id; |
1307 resource->is_software = true; | 1295 resource->is_software = true; |
1308 } else if (!source->mailbox.IsValid()) { | 1296 } else if (!source->mailbox.IsValid()) { |
1309 LazyCreate(source); | 1297 LazyCreate(source); |
1310 DCHECK(source->gl_id); | 1298 DCHECK(source->gl_id); |
1311 DCHECK(source->origin == Resource::INTERNAL); | 1299 DCHECK(source->origin == Resource::INTERNAL); |
1312 if (source->image_id) { | 1300 if (source->image_id && source->dirty_image) |
1313 DCHECK(source->dirty_image); | |
1314 gl->BindTexture(resource->mailbox_holder.texture_target, source->gl_id); | |
1315 BindImageForSampling(source); | 1301 BindImageForSampling(source); |
1316 } | |
1317 // This is a resource allocated by the compositor, we need to produce it. | 1302 // This is a resource allocated by the compositor, we need to produce it. |
1318 // Don't set a sync point, the caller will do it. | 1303 // Don't set a sync point, the caller will do it. |
1319 gl->GenMailboxCHROMIUM(resource->mailbox_holder.mailbox.name); | 1304 gl->GenMailboxCHROMIUM(resource->mailbox_holder.mailbox.name); |
1320 gl->ProduceTextureDirectCHROMIUM(source->gl_id, | 1305 gl->ProduceTextureDirectCHROMIUM(source->gl_id, |
1321 resource->mailbox_holder.texture_target, | 1306 resource->mailbox_holder.texture_target, |
1322 resource->mailbox_holder.mailbox.name); | 1307 resource->mailbox_holder.mailbox.name); |
1323 | 1308 |
1324 source->mailbox = TextureMailbox(resource->mailbox_holder); | 1309 source->mailbox = TextureMailbox(resource->mailbox_holder); |
1325 } else { | 1310 } else { |
1326 DCHECK(source->mailbox.IsTexture()); | 1311 DCHECK(source->mailbox.IsTexture()); |
1327 if (source->image_id && source->dirty_image) { | 1312 if (source->image_id && source->dirty_image) { |
1328 DCHECK(source->gl_id); | 1313 DCHECK(source->gl_id); |
1329 DCHECK(source->origin == Resource::INTERNAL); | 1314 DCHECK(source->origin == Resource::INTERNAL); |
1330 gl->BindTexture(resource->mailbox_holder.texture_target, source->gl_id); | |
1331 BindImageForSampling(source); | 1315 BindImageForSampling(source); |
1332 } | 1316 } |
1333 // This is either an external resource, or a compositor resource that we | 1317 // This is either an external resource, or a compositor resource that we |
1334 // already exported. Make sure to forward the sync point that we were given. | 1318 // already exported. Make sure to forward the sync point that we were given. |
1335 resource->mailbox_holder.mailbox = source->mailbox.mailbox(); | 1319 resource->mailbox_holder.mailbox = source->mailbox.mailbox(); |
1336 resource->mailbox_holder.texture_target = source->mailbox.target(); | 1320 resource->mailbox_holder.texture_target = source->mailbox.target(); |
1337 resource->mailbox_holder.sync_point = source->mailbox.sync_point(); | 1321 resource->mailbox_holder.sync_point = source->mailbox.sync_point(); |
1338 source->mailbox.set_sync_point(0); | 1322 source->mailbox.set_sync_point(0); |
1339 } | 1323 } |
1340 } | 1324 } |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1508 if (resource->allocated) | 1492 if (resource->allocated) |
1509 return; | 1493 return; |
1510 LazyCreate(resource); | 1494 LazyCreate(resource); |
1511 if (!resource->gl_id) | 1495 if (!resource->gl_id) |
1512 return; | 1496 return; |
1513 resource->allocated = true; | 1497 resource->allocated = true; |
1514 GLES2Interface* gl = ContextGL(); | 1498 GLES2Interface* gl = ContextGL(); |
1515 gfx::Size& size = resource->size; | 1499 gfx::Size& size = resource->size; |
1516 ResourceFormat format = resource->format; | 1500 ResourceFormat format = resource->format; |
1517 gl->BindTexture(resource->target, resource->gl_id); | 1501 gl->BindTexture(resource->target, resource->gl_id); |
1518 if (use_texture_storage_ext_ && | 1502 if (use_gpu_memory_buffer_resources_) { |
1519 IsFormatSupportedForStorage(format, use_texture_format_bgra_) && | 1503 resource->gpu_memory_buffer = |
1520 (resource->hint & TEXTURE_HINT_IMMUTABLE)) { | 1504 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( |
| 1505 size, BufferFormat(format), |
| 1506 gfx::BufferUsage::SCANOUT) |
| 1507 .release(); |
| 1508 LazyCreateImage(resource); |
| 1509 resource->dirty_image = true; |
| 1510 resource->is_overlay_candidate = true; |
| 1511 } else if (use_texture_storage_ext_ && |
| 1512 IsFormatSupportedForStorage(format, use_texture_format_bgra_) && |
| 1513 (resource->hint & TEXTURE_HINT_IMMUTABLE)) { |
1521 GLenum storage_format = TextureToStorageFormat(format); | 1514 GLenum storage_format = TextureToStorageFormat(format); |
1522 gl->TexStorage2DEXT(resource->target, 1, storage_format, size.width(), | 1515 gl->TexStorage2DEXT(resource->target, 1, storage_format, size.width(), |
1523 size.height()); | 1516 size.height()); |
1524 } else { | 1517 } else { |
1525 // ETC1 does not support preallocation. | 1518 // ETC1 does not support preallocation. |
1526 if (format != ETC1) { | 1519 if (format != ETC1) { |
1527 gl->TexImage2D(resource->target, 0, GLInternalFormat(format), | 1520 gl->TexImage2D(resource->target, 0, GLInternalFormat(format), |
1528 size.width(), size.height(), 0, GLDataFormat(format), | 1521 size.width(), size.height(), 0, GLDataFormat(format), |
1529 GLDataType(format), NULL); | 1522 GLDataType(format), NULL); |
1530 } | 1523 } |
1531 } | 1524 } |
1532 } | 1525 } |
1533 | 1526 |
| 1527 void ResourceProvider::LazyCreateImage(Resource* resource) { |
| 1528 DCHECK(resource->gpu_memory_buffer); |
| 1529 DCHECK(resource->gl_id); |
| 1530 DCHECK(resource->allocated); |
| 1531 if (!resource->image_id) { |
| 1532 GLES2Interface* gl = ContextGL(); |
| 1533 DCHECK(gl); |
| 1534 |
| 1535 #if defined(OS_CHROMEOS) |
| 1536 // TODO(reveman): GL_COMMANDS_ISSUED_CHROMIUM is used for synchronization |
| 1537 // on ChromeOS to avoid some performance issues. This only works with |
| 1538 // shared memory backed buffers. crbug.com/436314 |
| 1539 DCHECK_EQ(resource->gpu_memory_buffer->GetHandle().type, |
| 1540 gfx::SHARED_MEMORY_BUFFER); |
| 1541 #endif |
| 1542 resource->image_id = gl->CreateImageCHROMIUM( |
| 1543 resource->gpu_memory_buffer->AsClientBuffer(), resource->size.width(), |
| 1544 resource->size.height(), GLInternalFormat(resource->format)); |
| 1545 } |
| 1546 } |
| 1547 |
1534 void ResourceProvider::BindImageForSampling(Resource* resource) { | 1548 void ResourceProvider::BindImageForSampling(Resource* resource) { |
1535 GLES2Interface* gl = ContextGL(); | 1549 GLES2Interface* gl = ContextGL(); |
1536 DCHECK(resource->gl_id); | 1550 DCHECK(resource->gl_id); |
1537 DCHECK(resource->image_id); | 1551 DCHECK(resource->image_id); |
1538 | 1552 |
1539 // Release image currently bound to texture. | 1553 // Release image currently bound to texture. |
| 1554 gl->BindTexture(resource->target, resource->gl_id); |
1540 if (resource->bound_image_id) | 1555 if (resource->bound_image_id) |
1541 gl->ReleaseTexImage2DCHROMIUM(resource->target, resource->bound_image_id); | 1556 gl->ReleaseTexImage2DCHROMIUM(resource->target, resource->bound_image_id); |
1542 gl->BindTexImage2DCHROMIUM(resource->target, resource->image_id); | 1557 gl->BindTexImage2DCHROMIUM(resource->target, resource->image_id); |
1543 resource->bound_image_id = resource->image_id; | 1558 resource->bound_image_id = resource->image_id; |
1544 resource->dirty_image = false; | 1559 resource->dirty_image = false; |
1545 } | 1560 } |
1546 | 1561 |
1547 void ResourceProvider::WaitSyncPointIfNeeded(ResourceId id) { | 1562 void ResourceProvider::WaitSyncPointIfNeeded(ResourceId id) { |
1548 Resource* resource = GetResource(id); | 1563 Resource* resource = GetResource(id); |
1549 DCHECK_EQ(resource->exported_count, 0); | 1564 DCHECK_EQ(resource->exported_count, 0); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1637 const int kImportance = 2; | 1652 const int kImportance = 2; |
1638 pmd->CreateSharedGlobalAllocatorDump(guid); | 1653 pmd->CreateSharedGlobalAllocatorDump(guid); |
1639 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 1654 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
1640 } | 1655 } |
1641 } | 1656 } |
1642 | 1657 |
1643 return true; | 1658 return true; |
1644 } | 1659 } |
1645 | 1660 |
1646 } // namespace cc | 1661 } // namespace cc |
OLD | NEW |