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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 | 383 |
384 ResourceProvider::ResourceProvider( | 384 ResourceProvider::ResourceProvider( |
385 ContextProvider* compositor_context_provider, | 385 ContextProvider* compositor_context_provider, |
386 SharedBitmapManager* shared_bitmap_manager, | 386 SharedBitmapManager* shared_bitmap_manager, |
387 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 387 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
388 BlockingTaskRunner* blocking_main_thread_task_runner, | 388 BlockingTaskRunner* blocking_main_thread_task_runner, |
389 int highp_threshold_min, | 389 int highp_threshold_min, |
390 size_t id_allocation_chunk_size, | 390 size_t id_allocation_chunk_size, |
391 bool delegated_sync_points_required, | 391 bool delegated_sync_points_required, |
392 bool use_gpu_memory_buffer_resources, | 392 bool use_gpu_memory_buffer_resources, |
393 const std::vector<unsigned>& use_image_texture_targets) | 393 const RendererSettings::ImageTextureTargetsMap& use_image_texture_targets) |
394 : compositor_context_provider_(compositor_context_provider), | 394 : compositor_context_provider_(compositor_context_provider), |
395 shared_bitmap_manager_(shared_bitmap_manager), | 395 shared_bitmap_manager_(shared_bitmap_manager), |
396 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 396 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
397 blocking_main_thread_task_runner_(blocking_main_thread_task_runner), | 397 blocking_main_thread_task_runner_(blocking_main_thread_task_runner), |
398 lost_output_surface_(false), | 398 lost_output_surface_(false), |
399 highp_threshold_min_(highp_threshold_min), | 399 highp_threshold_min_(highp_threshold_min), |
400 next_id_(1), | 400 next_id_(1), |
401 next_child_(1), | 401 next_child_(1), |
402 delegated_sync_points_required_(delegated_sync_points_required), | 402 delegated_sync_points_required_(delegated_sync_points_required), |
403 default_resource_type_(use_gpu_memory_buffer_resources | 403 default_resource_type_(use_gpu_memory_buffer_resources |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 } | 592 } |
593 | 593 |
594 ResourceId ResourceProvider::CreateGLTexture(const gfx::Size& size, | 594 ResourceId ResourceProvider::CreateGLTexture(const gfx::Size& size, |
595 TextureHint hint, | 595 TextureHint hint, |
596 ResourceType type, | 596 ResourceType type, |
597 ResourceFormat format) { | 597 ResourceFormat format) { |
598 DCHECK_LE(size.width(), max_texture_size_); | 598 DCHECK_LE(size.width(), max_texture_size_); |
599 DCHECK_LE(size.height(), max_texture_size_); | 599 DCHECK_LE(size.height(), max_texture_size_); |
600 DCHECK(thread_checker_.CalledOnValidThread()); | 600 DCHECK(thread_checker_.CalledOnValidThread()); |
601 | 601 |
| 602 // TODO(crbug.com/590317): We should not assume that all resources created by |
| 603 // ResourceProvider are GPU_READ_CPU_READ_WRITE. We should determine this |
| 604 // based on the current RasterBufferProvider's needs. |
602 GLenum target = type == RESOURCE_TYPE_GPU_MEMORY_BUFFER | 605 GLenum target = type == RESOURCE_TYPE_GPU_MEMORY_BUFFER |
603 ? GetImageTextureTarget(format) | 606 ? GetImageTextureTarget( |
| 607 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, format) |
604 : GL_TEXTURE_2D; | 608 : GL_TEXTURE_2D; |
605 | 609 |
606 ResourceId id = next_id_++; | 610 ResourceId id = next_id_++; |
607 Resource* resource = | 611 Resource* resource = |
608 InsertResource(id, Resource(0, size, Resource::INTERNAL, target, | 612 InsertResource(id, Resource(0, size, Resource::INTERNAL, target, |
609 GL_LINEAR, hint, type, format)); | 613 GL_LINEAR, hint, type, format)); |
610 resource->allocated = false; | 614 resource->allocated = false; |
611 return id; | 615 return id; |
612 } | 616 } |
613 | 617 |
(...skipping 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1877 resource->WaitSyncToken(gl); | 1881 resource->WaitSyncToken(gl); |
1878 } | 1882 } |
1879 } | 1883 } |
1880 | 1884 |
1881 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { | 1885 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { |
1882 GLint active_unit = 0; | 1886 GLint active_unit = 0; |
1883 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); | 1887 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); |
1884 return active_unit; | 1888 return active_unit; |
1885 } | 1889 } |
1886 | 1890 |
1887 GLenum ResourceProvider::GetImageTextureTarget(ResourceFormat format) { | 1891 GLenum ResourceProvider::GetImageTextureTarget(gfx::BufferUsage usage, |
| 1892 ResourceFormat format) { |
1888 gfx::BufferFormat buffer_format = BufferFormat(format); | 1893 gfx::BufferFormat buffer_format = BufferFormat(format); |
1889 DCHECK_GT(use_image_texture_targets_.size(), | 1894 auto found = use_image_texture_targets_.find( |
1890 static_cast<size_t>(buffer_format)); | 1895 RendererSettings::ImageTextureTargetKey(usage, buffer_format)); |
1891 return use_image_texture_targets_[static_cast<size_t>(buffer_format)]; | 1896 DCHECK(found != use_image_texture_targets_.end()); |
| 1897 return found->second; |
1892 } | 1898 } |
1893 | 1899 |
1894 void ResourceProvider::ValidateResource(ResourceId id) const { | 1900 void ResourceProvider::ValidateResource(ResourceId id) const { |
1895 DCHECK(thread_checker_.CalledOnValidThread()); | 1901 DCHECK(thread_checker_.CalledOnValidThread()); |
1896 DCHECK(id); | 1902 DCHECK(id); |
1897 DCHECK(resources_.find(id) != resources_.end()); | 1903 DCHECK(resources_.find(id) != resources_.end()); |
1898 } | 1904 } |
1899 | 1905 |
1900 GLES2Interface* ResourceProvider::ContextGL() const { | 1906 GLES2Interface* ResourceProvider::ContextGL() const { |
1901 ContextProvider* context_provider = compositor_context_provider_; | 1907 ContextProvider* context_provider = compositor_context_provider_; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1975 | 1981 |
1976 const int kImportance = 2; | 1982 const int kImportance = 2; |
1977 pmd->CreateSharedGlobalAllocatorDump(guid); | 1983 pmd->CreateSharedGlobalAllocatorDump(guid); |
1978 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 1984 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
1979 } | 1985 } |
1980 | 1986 |
1981 return true; | 1987 return true; |
1982 } | 1988 } |
1983 | 1989 |
1984 } // namespace cc | 1990 } // namespace cc |
OLD | NEW |