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

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

Issue 499283002: gpu: support immutable texture on Linux Mesa driver and GLES3. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CompleteHandlingOfGLESandBGRA. Apply CC Created 6 years, 3 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 case LUMINANCE_8: 74 case LUMINANCE_8:
75 case RGB_565: 75 case RGB_565:
76 case ETC1: 76 case ETC1:
77 NOTREACHED(); 77 NOTREACHED();
78 break; 78 break;
79 } 79 }
80 80
81 return storage_format; 81 return storage_format;
82 } 82 }
83 83
84 bool IsFormatSupportedForStorage(ResourceFormat format) { 84 bool IsFormatSupportedForStorage(ResourceFormat format, bool use_bgra) {
85 switch (format) { 85 switch (format) {
86 case RGBA_8888: 86 case RGBA_8888:
87 return true;
87 case BGRA_8888: 88 case BGRA_8888:
88 return true; 89 return use_bgra;
89 case RGBA_4444: 90 case RGBA_4444:
90 case ALPHA_8: 91 case ALPHA_8:
91 case LUMINANCE_8: 92 case LUMINANCE_8:
92 case RGB_565: 93 case RGB_565:
93 case ETC1: 94 case ETC1:
94 return false; 95 return false;
95 } 96 }
96 return false; 97 return false;
97 } 98 }
98 99
(...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 size_t id_allocation_chunk_size, 1233 size_t id_allocation_chunk_size,
1233 bool use_distance_field_text) 1234 bool use_distance_field_text)
1234 : output_surface_(output_surface), 1235 : output_surface_(output_surface),
1235 shared_bitmap_manager_(shared_bitmap_manager), 1236 shared_bitmap_manager_(shared_bitmap_manager),
1236 lost_output_surface_(false), 1237 lost_output_surface_(false),
1237 highp_threshold_min_(highp_threshold_min), 1238 highp_threshold_min_(highp_threshold_min),
1238 next_id_(1), 1239 next_id_(1),
1239 next_child_(1), 1240 next_child_(1),
1240 default_resource_type_(InvalidType), 1241 default_resource_type_(InvalidType),
1241 use_texture_storage_ext_(false), 1242 use_texture_storage_ext_(false),
1243 use_texture_format_bgra_(false),
1242 use_texture_usage_hint_(false), 1244 use_texture_usage_hint_(false),
1243 use_compressed_texture_etc1_(false), 1245 use_compressed_texture_etc1_(false),
1244 max_texture_size_(0), 1246 max_texture_size_(0),
1245 best_texture_format_(RGBA_8888), 1247 best_texture_format_(RGBA_8888),
1246 use_rgba_4444_texture_format_(use_rgba_4444_texture_format), 1248 use_rgba_4444_texture_format_(use_rgba_4444_texture_format),
1247 id_allocation_chunk_size_(id_allocation_chunk_size), 1249 id_allocation_chunk_size_(id_allocation_chunk_size),
1248 use_sync_query_(false), 1250 use_sync_query_(false),
1249 use_distance_field_text_(use_distance_field_text) { 1251 use_distance_field_text_(use_distance_field_text) {
1250 DCHECK(output_surface_->HasClient()); 1252 DCHECK(output_surface_->HasClient());
1251 DCHECK(id_allocation_chunk_size_); 1253 DCHECK(id_allocation_chunk_size_);
(...skipping 18 matching lines...) Expand all
1270 DCHECK(!texture_id_allocator_); 1272 DCHECK(!texture_id_allocator_);
1271 DCHECK(!buffer_id_allocator_); 1273 DCHECK(!buffer_id_allocator_);
1272 1274
1273 default_resource_type_ = GLTexture; 1275 default_resource_type_ = GLTexture;
1274 1276
1275 const ContextProvider::Capabilities& caps = 1277 const ContextProvider::Capabilities& caps =
1276 output_surface_->context_provider()->ContextCapabilities(); 1278 output_surface_->context_provider()->ContextCapabilities();
1277 1279
1278 bool use_bgra = caps.gpu.texture_format_bgra8888; 1280 bool use_bgra = caps.gpu.texture_format_bgra8888;
1279 use_texture_storage_ext_ = caps.gpu.texture_storage; 1281 use_texture_storage_ext_ = caps.gpu.texture_storage;
1282 use_texture_format_bgra_ = caps.gpu.texture_format_bgra8888;
1280 use_texture_usage_hint_ = caps.gpu.texture_usage; 1283 use_texture_usage_hint_ = caps.gpu.texture_usage;
1281 use_compressed_texture_etc1_ = caps.gpu.texture_format_etc1; 1284 use_compressed_texture_etc1_ = caps.gpu.texture_format_etc1;
1282 use_sync_query_ = caps.gpu.sync_query; 1285 use_sync_query_ = caps.gpu.sync_query;
1283 1286
1284 GLES2Interface* gl = ContextGL(); 1287 GLES2Interface* gl = ContextGL();
1285 DCHECK(gl); 1288 DCHECK(gl);
1286 1289
1287 texture_uploader_ = TextureUploader::Create(gl); 1290 texture_uploader_ = TextureUploader::Create(gl);
1288 max_texture_size_ = 0; // Context expects cleared value. 1291 max_texture_size_ = 0; // Context expects cleared value.
1289 GLC(gl, gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_)); 1292 GLC(gl, gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_));
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
2092 2095
2093 DCHECK(resource->gl_id || resource->allocated); 2096 DCHECK(resource->gl_id || resource->allocated);
2094 if (resource->allocated || !resource->gl_id) 2097 if (resource->allocated || !resource->gl_id)
2095 return; 2098 return;
2096 resource->allocated = true; 2099 resource->allocated = true;
2097 GLES2Interface* gl = ContextGL(); 2100 GLES2Interface* gl = ContextGL();
2098 gfx::Size& size = resource->size; 2101 gfx::Size& size = resource->size;
2099 DCHECK_EQ(resource->target, static_cast<GLenum>(GL_TEXTURE_2D)); 2102 DCHECK_EQ(resource->target, static_cast<GLenum>(GL_TEXTURE_2D));
2100 ResourceFormat format = resource->format; 2103 ResourceFormat format = resource->format;
2101 GLC(gl, gl->BindTexture(GL_TEXTURE_2D, resource->gl_id)); 2104 GLC(gl, gl->BindTexture(GL_TEXTURE_2D, resource->gl_id));
2102 if (use_texture_storage_ext_ && IsFormatSupportedForStorage(format) && 2105 if (use_texture_storage_ext_ &&
2106 IsFormatSupportedForStorage(format, use_texture_format_bgra_) &&
2103 (resource->hint & TextureHintImmutable)) { 2107 (resource->hint & TextureHintImmutable)) {
2104 GLenum storage_format = TextureToStorageFormat(format); 2108 GLenum storage_format = TextureToStorageFormat(format);
2105 GLC(gl, 2109 GLC(gl,
2106 gl->TexStorage2DEXT( 2110 gl->TexStorage2DEXT(
2107 GL_TEXTURE_2D, 1, storage_format, size.width(), size.height())); 2111 GL_TEXTURE_2D, 1, storage_format, size.width(), size.height()));
2108 } else { 2112 } else {
2109 // ETC1 does not support preallocation. 2113 // ETC1 does not support preallocation.
2110 if (format != ETC1) { 2114 if (format != ETC1) {
2111 GLC(gl, 2115 GLC(gl,
2112 gl->TexImage2D(GL_TEXTURE_2D, 2116 gl->TexImage2D(GL_TEXTURE_2D,
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
2290 ContextProvider* context_provider = output_surface_->context_provider().get(); 2294 ContextProvider* context_provider = output_surface_->context_provider().get();
2291 return context_provider ? context_provider->ContextGL() : NULL; 2295 return context_provider ? context_provider->ContextGL() : NULL;
2292 } 2296 }
2293 2297
2294 class GrContext* ResourceProvider::GrContext() const { 2298 class GrContext* ResourceProvider::GrContext() const {
2295 ContextProvider* context_provider = output_surface_->context_provider().get(); 2299 ContextProvider* context_provider = output_surface_->context_provider().get();
2296 return context_provider ? context_provider->GrContext() : NULL; 2300 return context_provider ? context_provider->GrContext() : NULL;
2297 } 2301 }
2298 2302
2299 } // namespace cc 2303 } // 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