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/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 case RGBA_8888: | 69 case RGBA_8888: |
70 break; | 70 break; |
71 case BGRA_8888: | 71 case BGRA_8888: |
72 storage_format = GL_BGRA8_EXT; | 72 storage_format = GL_BGRA8_EXT; |
73 break; | 73 break; |
74 case RGBA_4444: | 74 case RGBA_4444: |
75 case ALPHA_8: | 75 case ALPHA_8: |
76 case LUMINANCE_8: | 76 case LUMINANCE_8: |
77 case RGB_565: | 77 case RGB_565: |
78 case ETC1: | 78 case ETC1: |
| 79 case RED_8: |
79 NOTREACHED(); | 80 NOTREACHED(); |
80 break; | 81 break; |
81 } | 82 } |
82 | 83 |
83 return storage_format; | 84 return storage_format; |
84 } | 85 } |
85 | 86 |
86 bool IsFormatSupportedForStorage(ResourceFormat format, bool use_bgra) { | 87 bool IsFormatSupportedForStorage(ResourceFormat format, bool use_bgra) { |
87 switch (format) { | 88 switch (format) { |
88 case RGBA_8888: | 89 case RGBA_8888: |
89 return true; | 90 return true; |
90 case BGRA_8888: | 91 case BGRA_8888: |
91 return use_bgra; | 92 return use_bgra; |
92 case RGBA_4444: | 93 case RGBA_4444: |
93 case ALPHA_8: | 94 case ALPHA_8: |
94 case LUMINANCE_8: | 95 case LUMINANCE_8: |
95 case RGB_565: | 96 case RGB_565: |
96 case ETC1: | 97 case ETC1: |
| 98 case RED_8: |
97 return false; | 99 return false; |
98 } | 100 } |
99 return false; | 101 return false; |
100 } | 102 } |
101 | 103 |
102 GrPixelConfig ToGrPixelConfig(ResourceFormat format) { | 104 GrPixelConfig ToGrPixelConfig(ResourceFormat format) { |
103 switch (format) { | 105 switch (format) { |
104 case RGBA_8888: | 106 case RGBA_8888: |
105 return kRGBA_8888_GrPixelConfig; | 107 return kRGBA_8888_GrPixelConfig; |
106 case BGRA_8888: | 108 case BGRA_8888: |
(...skipping 11 matching lines...) Expand all Loading... |
118 switch (format) { | 120 switch (format) { |
119 case RGBA_8888: | 121 case RGBA_8888: |
120 return gfx::GpuMemoryBuffer::Format::RGBA_8888; | 122 return gfx::GpuMemoryBuffer::Format::RGBA_8888; |
121 case BGRA_8888: | 123 case BGRA_8888: |
122 return gfx::GpuMemoryBuffer::Format::BGRA_8888; | 124 return gfx::GpuMemoryBuffer::Format::BGRA_8888; |
123 case RGBA_4444: | 125 case RGBA_4444: |
124 case ALPHA_8: | 126 case ALPHA_8: |
125 case LUMINANCE_8: | 127 case LUMINANCE_8: |
126 case RGB_565: | 128 case RGB_565: |
127 case ETC1: | 129 case ETC1: |
| 130 case RED_8: |
128 break; | 131 break; |
129 } | 132 } |
130 NOTREACHED(); | 133 NOTREACHED(); |
131 return gfx::GpuMemoryBuffer::Format::RGBA_8888; | 134 return gfx::GpuMemoryBuffer::Format::RGBA_8888; |
132 } | 135 } |
133 | 136 |
134 class ScopedSetActiveTexture { | 137 class ScopedSetActiveTexture { |
135 public: | 138 public: |
136 ScopedSetActiveTexture(GLES2Interface* gl, GLenum unit) | 139 ScopedSetActiveTexture(GLES2Interface* gl, GLenum unit) |
137 : gl_(gl), unit_(unit) { | 140 : gl_(gl), unit_(unit) { |
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1209 blocking_main_thread_task_runner_(blocking_main_thread_task_runner), | 1212 blocking_main_thread_task_runner_(blocking_main_thread_task_runner), |
1210 lost_output_surface_(false), | 1213 lost_output_surface_(false), |
1211 highp_threshold_min_(highp_threshold_min), | 1214 highp_threshold_min_(highp_threshold_min), |
1212 next_id_(1), | 1215 next_id_(1), |
1213 next_child_(1), | 1216 next_child_(1), |
1214 default_resource_type_(InvalidType), | 1217 default_resource_type_(InvalidType), |
1215 use_texture_storage_ext_(false), | 1218 use_texture_storage_ext_(false), |
1216 use_texture_format_bgra_(false), | 1219 use_texture_format_bgra_(false), |
1217 use_texture_usage_hint_(false), | 1220 use_texture_usage_hint_(false), |
1218 use_compressed_texture_etc1_(false), | 1221 use_compressed_texture_etc1_(false), |
| 1222 yuv_resource_format_(LUMINANCE_8), |
1219 max_texture_size_(0), | 1223 max_texture_size_(0), |
1220 best_texture_format_(RGBA_8888), | 1224 best_texture_format_(RGBA_8888), |
1221 use_rgba_4444_texture_format_(use_rgba_4444_texture_format), | 1225 use_rgba_4444_texture_format_(use_rgba_4444_texture_format), |
1222 id_allocation_chunk_size_(id_allocation_chunk_size), | 1226 id_allocation_chunk_size_(id_allocation_chunk_size), |
1223 use_sync_query_(false) { | 1227 use_sync_query_(false) { |
1224 DCHECK(output_surface_->HasClient()); | 1228 DCHECK(output_surface_->HasClient()); |
1225 DCHECK(id_allocation_chunk_size_); | 1229 DCHECK(id_allocation_chunk_size_); |
1226 } | 1230 } |
1227 | 1231 |
1228 void ResourceProvider::InitializeSoftware() { | 1232 void ResourceProvider::InitializeSoftware() { |
(...skipping 18 matching lines...) Expand all Loading... |
1247 default_resource_type_ = GLTexture; | 1251 default_resource_type_ = GLTexture; |
1248 | 1252 |
1249 const ContextProvider::Capabilities& caps = | 1253 const ContextProvider::Capabilities& caps = |
1250 output_surface_->context_provider()->ContextCapabilities(); | 1254 output_surface_->context_provider()->ContextCapabilities(); |
1251 | 1255 |
1252 bool use_bgra = caps.gpu.texture_format_bgra8888; | 1256 bool use_bgra = caps.gpu.texture_format_bgra8888; |
1253 use_texture_storage_ext_ = caps.gpu.texture_storage; | 1257 use_texture_storage_ext_ = caps.gpu.texture_storage; |
1254 use_texture_format_bgra_ = caps.gpu.texture_format_bgra8888; | 1258 use_texture_format_bgra_ = caps.gpu.texture_format_bgra8888; |
1255 use_texture_usage_hint_ = caps.gpu.texture_usage; | 1259 use_texture_usage_hint_ = caps.gpu.texture_usage; |
1256 use_compressed_texture_etc1_ = caps.gpu.texture_format_etc1; | 1260 use_compressed_texture_etc1_ = caps.gpu.texture_format_etc1; |
| 1261 yuv_resource_format_ = caps.gpu.texture_rg ? RED_8 : LUMINANCE_8; |
1257 use_sync_query_ = caps.gpu.sync_query; | 1262 use_sync_query_ = caps.gpu.sync_query; |
1258 | 1263 |
1259 GLES2Interface* gl = ContextGL(); | 1264 GLES2Interface* gl = ContextGL(); |
1260 DCHECK(gl); | 1265 DCHECK(gl); |
1261 | 1266 |
1262 texture_uploader_ = TextureUploader::Create(gl); | 1267 texture_uploader_ = TextureUploader::Create(gl); |
1263 max_texture_size_ = 0; // Context expects cleared value. | 1268 max_texture_size_ = 0; // Context expects cleared value. |
1264 GLC(gl, gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_)); | 1269 GLC(gl, gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_)); |
1265 best_texture_format_ = PlatformColor::BestTextureFormat(use_bgra); | 1270 best_texture_format_ = PlatformColor::BestTextureFormat(use_bgra); |
1266 | 1271 |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2154 ContextProvider* context_provider = output_surface_->context_provider(); | 2159 ContextProvider* context_provider = output_surface_->context_provider(); |
2155 return context_provider ? context_provider->ContextGL() : NULL; | 2160 return context_provider ? context_provider->ContextGL() : NULL; |
2156 } | 2161 } |
2157 | 2162 |
2158 class GrContext* ResourceProvider::GrContext() const { | 2163 class GrContext* ResourceProvider::GrContext() const { |
2159 ContextProvider* context_provider = output_surface_->context_provider(); | 2164 ContextProvider* context_provider = output_surface_->context_provider(); |
2160 return context_provider ? context_provider->GrContext() : NULL; | 2165 return context_provider ? context_provider->GrContext() : NULL; |
2161 } | 2166 } |
2162 | 2167 |
2163 } // namespace cc | 2168 } // namespace cc |
OLD | NEW |