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

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

Issue 1269503007: Unify graphics buffer format & usage enums for GpuMemoryBuffer & SurfaceFactoryOzone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add header to BUILD.gn 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 | « no previous file | cc/test/test_gpu_memory_buffer_manager.h » ('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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 return kBGRA_8888_GrPixelConfig; 106 return kBGRA_8888_GrPixelConfig;
107 case RGBA_4444: 107 case RGBA_4444:
108 return kRGBA_4444_GrPixelConfig; 108 return kRGBA_4444_GrPixelConfig;
109 default: 109 default:
110 break; 110 break;
111 } 111 }
112 DCHECK(false) << "Unsupported resource format."; 112 DCHECK(false) << "Unsupported resource format.";
113 return kSkia8888_GrPixelConfig; 113 return kSkia8888_GrPixelConfig;
114 } 114 }
115 115
116 gfx::GpuMemoryBuffer::Format ToGpuMemoryBufferFormat(ResourceFormat format) { 116 gfx::BufferFormat ToGpuMemoryBufferFormat(ResourceFormat format) {
117 switch (format) { 117 switch (format) {
118 case RGBA_8888: 118 case RGBA_8888:
119 return gfx::GpuMemoryBuffer::RGBA_8888; 119 return gfx::BufferFormat::RGBA_8888;
120 case BGRA_8888: 120 case BGRA_8888:
121 return gfx::GpuMemoryBuffer::BGRA_8888; 121 return gfx::BufferFormat::BGRA_8888;
122 case RGBA_4444: 122 case RGBA_4444:
123 return gfx::GpuMemoryBuffer::RGBA_4444; 123 return gfx::BufferFormat::RGBA_4444;
124 case ALPHA_8: 124 case ALPHA_8:
125 case LUMINANCE_8: 125 case LUMINANCE_8:
126 case RGB_565: 126 case RGB_565:
127 case ETC1: 127 case ETC1:
128 case RED_8: 128 case RED_8:
129 break; 129 break;
130 } 130 }
131 NOTREACHED(); 131 NOTREACHED();
132 return gfx::GpuMemoryBuffer::RGBA_8888; 132 return gfx::BufferFormat::RGBA_8888;
133 } 133 }
134 134
135 class ScopedSetActiveTexture { 135 class ScopedSetActiveTexture {
136 public: 136 public:
137 ScopedSetActiveTexture(GLES2Interface* gl, GLenum unit) 137 ScopedSetActiveTexture(GLES2Interface* gl, GLenum unit)
138 : gl_(gl), unit_(unit) { 138 : gl_(gl), unit_(unit) {
139 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(gl_)); 139 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(gl_));
140 140
141 if (unit_ != GL_TEXTURE0) 141 if (unit_ != GL_TEXTURE0)
142 gl_->ActiveTexture(unit_); 142 gl_->ActiveTexture(unit_);
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 // GpuMemoryBuffer provides direct access to the memory used by the GPU. 982 // GpuMemoryBuffer provides direct access to the memory used by the GPU.
983 // Read lock fences are required to ensure that we're not trying to map a 983 // Read lock fences are required to ensure that we're not trying to map a
984 // buffer that is currently in-use by the GPU. 984 // buffer that is currently in-use by the GPU.
985 resource_->read_lock_fences_enabled = true; 985 resource_->read_lock_fences_enabled = true;
986 } 986 }
987 987
988 gfx::GpuMemoryBuffer* 988 gfx::GpuMemoryBuffer*
989 ResourceProvider::ScopedWriteLockGpuMemoryBuffer::GetGpuMemoryBuffer() { 989 ResourceProvider::ScopedWriteLockGpuMemoryBuffer::GetGpuMemoryBuffer() {
990 if (gpu_memory_buffer_) 990 if (gpu_memory_buffer_)
991 return gpu_memory_buffer_; 991 return gpu_memory_buffer_;
992 gfx::GpuMemoryBuffer::Usage usage = 992 gfx::BufferUsage usage =
993 resource_provider_->use_persistent_map_for_gpu_memory_buffers() 993 resource_provider_->use_persistent_map_for_gpu_memory_buffers()
994 ? gfx::GpuMemoryBuffer::PERSISTENT_MAP 994 ? gfx::BufferUsage::PERSISTENT_MAP
995 : gfx::GpuMemoryBuffer::MAP; 995 : gfx::BufferUsage::MAP;
996 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer = 996 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer =
997 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( 997 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer(
998 size_, ToGpuMemoryBufferFormat(format_), usage); 998 size_, ToGpuMemoryBufferFormat(format_), usage);
999 gpu_memory_buffer_ = gpu_memory_buffer.release(); 999 gpu_memory_buffer_ = gpu_memory_buffer.release();
1000 return gpu_memory_buffer_; 1000 return gpu_memory_buffer_;
1001 } 1001 }
1002 1002
1003 ResourceProvider::ScopedWriteLockGr::ScopedWriteLockGr( 1003 ResourceProvider::ScopedWriteLockGr::ScopedWriteLockGr(
1004 ResourceProvider* resource_provider, 1004 ResourceProvider* resource_provider,
1005 ResourceId resource_id) 1005 ResourceId resource_id)
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
1952 } 1952 }
1953 1953
1954 class GrContext* ResourceProvider::GrContext(bool worker_context) const { 1954 class GrContext* ResourceProvider::GrContext(bool worker_context) const {
1955 ContextProvider* context_provider = 1955 ContextProvider* context_provider =
1956 worker_context ? output_surface_->worker_context_provider() 1956 worker_context ? output_surface_->worker_context_provider()
1957 : output_surface_->context_provider(); 1957 : output_surface_->context_provider();
1958 return context_provider ? context_provider->GrContext() : NULL; 1958 return context_provider ? context_provider->GrContext() : NULL;
1959 } 1959 }
1960 1960
1961 } // namespace cc 1961 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/test/test_gpu_memory_buffer_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698