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

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

Issue 1251693003: cc: Fix the format of GpuMemoryBuffer for SurfaceTexture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/resources/resource_provider_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 ResourceProvider::Child::~Child() {} 390 ResourceProvider::Child::~Child() {}
391 391
392 scoped_ptr<ResourceProvider> ResourceProvider::Create( 392 scoped_ptr<ResourceProvider> ResourceProvider::Create(
393 OutputSurface* output_surface, 393 OutputSurface* output_surface,
394 SharedBitmapManager* shared_bitmap_manager, 394 SharedBitmapManager* shared_bitmap_manager,
395 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 395 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
396 BlockingTaskRunner* blocking_main_thread_task_runner, 396 BlockingTaskRunner* blocking_main_thread_task_runner,
397 int highp_threshold_min, 397 int highp_threshold_min,
398 bool use_rgba_4444_texture_format, 398 bool use_rgba_4444_texture_format,
399 size_t id_allocation_chunk_size, 399 size_t id_allocation_chunk_size,
400 bool use_persistent_map_for_gpu_memory_buffers) { 400 bool use_persistent_map_for_gpu_memory_buffers,
401 const std::vector<unsigned>& use_image_texture_targets) {
401 scoped_ptr<ResourceProvider> resource_provider(new ResourceProvider( 402 scoped_ptr<ResourceProvider> resource_provider(new ResourceProvider(
402 output_surface, shared_bitmap_manager, gpu_memory_buffer_manager, 403 output_surface, shared_bitmap_manager, gpu_memory_buffer_manager,
403 blocking_main_thread_task_runner, highp_threshold_min, 404 blocking_main_thread_task_runner, highp_threshold_min,
404 use_rgba_4444_texture_format, id_allocation_chunk_size, 405 use_rgba_4444_texture_format, id_allocation_chunk_size,
405 use_persistent_map_for_gpu_memory_buffers)); 406 use_persistent_map_for_gpu_memory_buffers, use_image_texture_targets));
406 resource_provider->Initialize(); 407 resource_provider->Initialize();
407 return resource_provider; 408 return resource_provider;
408 } 409 }
409 410
410 ResourceProvider::~ResourceProvider() { 411 ResourceProvider::~ResourceProvider() {
411 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( 412 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
412 this); 413 this);
413 414
414 while (!children_.empty()) 415 while (!children_.empty())
415 DestroyChildInternal(children_.begin(), FOR_SHUTDOWN); 416 DestroyChildInternal(children_.begin(), FOR_SHUTDOWN);
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 } 1085 }
1085 1086
1086 ResourceProvider::ResourceProvider( 1087 ResourceProvider::ResourceProvider(
1087 OutputSurface* output_surface, 1088 OutputSurface* output_surface,
1088 SharedBitmapManager* shared_bitmap_manager, 1089 SharedBitmapManager* shared_bitmap_manager,
1089 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 1090 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
1090 BlockingTaskRunner* blocking_main_thread_task_runner, 1091 BlockingTaskRunner* blocking_main_thread_task_runner,
1091 int highp_threshold_min, 1092 int highp_threshold_min,
1092 bool use_rgba_4444_texture_format, 1093 bool use_rgba_4444_texture_format,
1093 size_t id_allocation_chunk_size, 1094 size_t id_allocation_chunk_size,
1094 bool use_persistent_map_for_gpu_memory_buffers) 1095 bool use_persistent_map_for_gpu_memory_buffers,
1096 const std::vector<unsigned>& use_image_texture_targets)
1095 : output_surface_(output_surface), 1097 : output_surface_(output_surface),
1096 shared_bitmap_manager_(shared_bitmap_manager), 1098 shared_bitmap_manager_(shared_bitmap_manager),
1097 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), 1099 gpu_memory_buffer_manager_(gpu_memory_buffer_manager),
1098 blocking_main_thread_task_runner_(blocking_main_thread_task_runner), 1100 blocking_main_thread_task_runner_(blocking_main_thread_task_runner),
1099 lost_output_surface_(false), 1101 lost_output_surface_(false),
1100 highp_threshold_min_(highp_threshold_min), 1102 highp_threshold_min_(highp_threshold_min),
1101 next_id_(1), 1103 next_id_(1),
1102 next_child_(1), 1104 next_child_(1),
1103 default_resource_type_(RESOURCE_TYPE_BITMAP), 1105 default_resource_type_(RESOURCE_TYPE_BITMAP),
1104 use_texture_storage_ext_(false), 1106 use_texture_storage_ext_(false),
1105 use_texture_format_bgra_(false), 1107 use_texture_format_bgra_(false),
1106 use_texture_usage_hint_(false), 1108 use_texture_usage_hint_(false),
1107 use_compressed_texture_etc1_(false), 1109 use_compressed_texture_etc1_(false),
1108 yuv_resource_format_(LUMINANCE_8), 1110 yuv_resource_format_(LUMINANCE_8),
1109 max_texture_size_(0), 1111 max_texture_size_(0),
1110 best_texture_format_(RGBA_8888), 1112 best_texture_format_(RGBA_8888),
1111 best_render_buffer_format_(RGBA_8888), 1113 best_render_buffer_format_(RGBA_8888),
1112 use_rgba_4444_texture_format_(use_rgba_4444_texture_format), 1114 use_rgba_4444_texture_format_(use_rgba_4444_texture_format),
1113 id_allocation_chunk_size_(id_allocation_chunk_size), 1115 id_allocation_chunk_size_(id_allocation_chunk_size),
1114 use_sync_query_(false), 1116 use_sync_query_(false),
1115 use_persistent_map_for_gpu_memory_buffers_( 1117 use_persistent_map_for_gpu_memory_buffers_(
1116 use_persistent_map_for_gpu_memory_buffers) { 1118 use_persistent_map_for_gpu_memory_buffers),
1119 use_image_texture_targets_(use_image_texture_targets) {
1117 DCHECK(output_surface_->HasClient()); 1120 DCHECK(output_surface_->HasClient());
1118 DCHECK(id_allocation_chunk_size_); 1121 DCHECK(id_allocation_chunk_size_);
1119 } 1122 }
1120 1123
1121 void ResourceProvider::Initialize() { 1124 void ResourceProvider::Initialize() {
1122 DCHECK(thread_checker_.CalledOnValidThread()); 1125 DCHECK(thread_checker_.CalledOnValidThread());
1123 1126
1124 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview). 1127 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview).
1125 // Don't register a dump provider in these cases. 1128 // Don't register a dump provider in these cases.
1126 // TODO(ericrk): Get this working in Android Webview. crbug.com/517156 1129 // TODO(ericrk): Get this working in Android Webview. crbug.com/517156
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 1946
1944 resource->read_lock_fence->Wait(); 1947 resource->read_lock_fence->Wait();
1945 } 1948 }
1946 1949
1947 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { 1950 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) {
1948 GLint active_unit = 0; 1951 GLint active_unit = 0;
1949 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); 1952 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit);
1950 return active_unit; 1953 return active_unit;
1951 } 1954 }
1952 1955
1956 GLenum ResourceProvider::GetImageTextureTarget(ResourceFormat format) {
1957 gfx::BufferFormat buffer_format = ToGpuMemoryBufferFormat(format);
1958 DCHECK_GT(use_image_texture_targets_.size(),
1959 static_cast<size_t>(buffer_format));
1960 return use_image_texture_targets_[static_cast<size_t>(buffer_format)];
1961 }
1962
1953 void ResourceProvider::ValidateResource(ResourceId id) const { 1963 void ResourceProvider::ValidateResource(ResourceId id) const {
1954 DCHECK(thread_checker_.CalledOnValidThread()); 1964 DCHECK(thread_checker_.CalledOnValidThread());
1955 DCHECK(id); 1965 DCHECK(id);
1956 DCHECK(resources_.find(id) != resources_.end()); 1966 DCHECK(resources_.find(id) != resources_.end());
1957 } 1967 }
1958 1968
1959 GLES2Interface* ResourceProvider::ContextGL() const { 1969 GLES2Interface* ResourceProvider::ContextGL() const {
1960 ContextProvider* context_provider = output_surface_->context_provider(); 1970 ContextProvider* context_provider = output_surface_->context_provider();
1961 return context_provider ? context_provider->ContextGL() : NULL; 1971 return context_provider ? context_provider->ContextGL() : NULL;
1962 } 1972 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2010 const int kImportance = 2; 2020 const int kImportance = 2;
2011 pmd->CreateSharedGlobalAllocatorDump(guid); 2021 pmd->CreateSharedGlobalAllocatorDump(guid);
2012 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); 2022 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
2013 } 2023 }
2014 } 2024 }
2015 2025
2016 return true; 2026 return true;
2017 } 2027 }
2018 2028
2019 } // namespace cc 2029 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/resources/resource_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698