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

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

Issue 21159007: cc: Adding support for RGBA_4444 tile textures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 7 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
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 #if defined(OS_ANDROID)
11 #include "base/android/sys_utils.h"
12 #endif
13
10 #include "base/containers/hash_tables.h" 14 #include "base/containers/hash_tables.h"
11 #include "base/debug/alias.h" 15 #include "base/debug/alias.h"
12 #include "base/stl_util.h" 16 #include "base/stl_util.h"
13 #include "base/strings/string_split.h" 17 #include "base/strings/string_split.h"
14 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
15 #include "cc/output/gl_renderer.h" // For the GLC() macro. 19 #include "cc/output/gl_renderer.h" // For the GLC() macro.
16 #include "cc/resources/platform_color.h" 20 #include "cc/resources/platform_color.h"
17 #include "cc/resources/transferable_resource.h" 21 #include "cc/resources/transferable_resource.h"
18 #include "cc/scheduler/texture_uploader.h" 22 #include "cc/scheduler/texture_uploader.h"
19 #include "gpu/GLES2/gl2extchromium.h" 23 #include "gpu/GLES2/gl2extchromium.h"
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 : output_surface_(output_surface), 682 : output_surface_(output_surface),
679 lost_output_surface_(false), 683 lost_output_surface_(false),
680 highp_threshold_min_(highp_threshold_min), 684 highp_threshold_min_(highp_threshold_min),
681 next_id_(1), 685 next_id_(1),
682 next_child_(1), 686 next_child_(1),
683 default_resource_type_(InvalidType), 687 default_resource_type_(InvalidType),
684 use_texture_storage_ext_(false), 688 use_texture_storage_ext_(false),
685 use_texture_usage_hint_(false), 689 use_texture_usage_hint_(false),
686 use_shallow_flush_(false), 690 use_shallow_flush_(false),
687 max_texture_size_(0), 691 max_texture_size_(0),
688 best_texture_format_(0) {} 692 best_texture_format_(0),
693 use_16bit_textures_(false) {
694 #if defined(OS_ANDROID)
695 if (base::android::SysUtils::IsLowEndDevice())
696 use_16bit_textures_ = true;
697 #endif
698 }
689 699
690 void ResourceProvider::InitializeSoftware() { 700 void ResourceProvider::InitializeSoftware() {
691 DCHECK(thread_checker_.CalledOnValidThread()); 701 DCHECK(thread_checker_.CalledOnValidThread());
692 DCHECK_NE(Bitmap, default_resource_type_); 702 DCHECK_NE(Bitmap, default_resource_type_);
693 703
694 CleanUpGLIfNeeded(); 704 CleanUpGLIfNeeded();
695 705
696 default_resource_type_ = Bitmap; 706 default_resource_type_ = Bitmap;
697 max_texture_size_ = INT_MAX / 2; 707 max_texture_size_ = INT_MAX / 2;
698 best_texture_format_ = GL_RGBA; 708 best_texture_format_ = GL_RGBA;
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 DCHECK(resource->gl_pixel_buffer_id); 1178 DCHECK(resource->gl_pixel_buffer_id);
1169 context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id); 1179 context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id);
1170 context3d->bindBuffer( 1180 context3d->bindBuffer(
1171 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 1181 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
1172 resource->gl_pixel_buffer_id); 1182 resource->gl_pixel_buffer_id);
1173 if (!resource->gl_upload_query_id) 1183 if (!resource->gl_upload_query_id)
1174 resource->gl_upload_query_id = context3d->createQueryEXT(); 1184 resource->gl_upload_query_id = context3d->createQueryEXT();
1175 context3d->beginQueryEXT( 1185 context3d->beginQueryEXT(
1176 GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM, 1186 GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM,
1177 resource->gl_upload_query_id); 1187 resource->gl_upload_query_id);
1188 GLenum texture_data_type = use_16bit_textures_
1189 ? GL_UNSIGNED_SHORT_4_4_4_4 : GL_UNSIGNED_BYTE;
1178 if (allocate) { 1190 if (allocate) {
1179 context3d->asyncTexImage2DCHROMIUM(GL_TEXTURE_2D, 1191 context3d->asyncTexImage2DCHROMIUM(GL_TEXTURE_2D,
1180 0, /* level */ 1192 0, /* level */
1181 resource->format, 1193 resource->format,
1182 resource->size.width(), 1194 resource->size.width(),
1183 resource->size.height(), 1195 resource->size.height(),
1184 0, /* border */ 1196 0, /* border */
1185 resource->format, 1197 resource->format,
1186 GL_UNSIGNED_BYTE, 1198 texture_data_type,
1187 NULL); 1199 NULL);
1188 } else { 1200 } else {
1189 context3d->asyncTexSubImage2DCHROMIUM(GL_TEXTURE_2D, 1201 context3d->asyncTexSubImage2DCHROMIUM(GL_TEXTURE_2D,
1190 0, /* level */ 1202 0, /* level */
1191 0, /* x */ 1203 0, /* x */
1192 0, /* y */ 1204 0, /* y */
1193 resource->size.width(), 1205 resource->size.width(),
1194 resource->size.height(), 1206 resource->size.height(),
1195 resource->format, 1207 resource->format,
1196 GL_UNSIGNED_BYTE, 1208 texture_data_type,
1197 NULL); 1209 NULL);
1198 } 1210 }
1199 context3d->endQueryEXT(GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM); 1211 context3d->endQueryEXT(GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM);
1200 context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); 1212 context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
1201 } 1213 }
1202 1214
1203 if (resource->pixels) { 1215 if (resource->pixels) {
1204 DCHECK(!resource->mailbox.IsValid()); 1216 DCHECK(!resource->mailbox.IsValid());
1205 DCHECK(resource->pixel_buffer); 1217 DCHECK(resource->pixel_buffer);
1206 DCHECK(resource->format == GL_RGBA); 1218 DCHECK(resource->format == GL_RGBA);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 LazyCreate(resource); 1313 LazyCreate(resource);
1302 1314
1303 DCHECK(resource->gl_id || resource->allocated); 1315 DCHECK(resource->gl_id || resource->allocated);
1304 if (resource->allocated || !resource->gl_id) 1316 if (resource->allocated || !resource->gl_id)
1305 return; 1317 return;
1306 resource->allocated = true; 1318 resource->allocated = true;
1307 WebGraphicsContext3D* context3d = output_surface_->context3d(); 1319 WebGraphicsContext3D* context3d = output_surface_->context3d();
1308 gfx::Size& size = resource->size; 1320 gfx::Size& size = resource->size;
1309 GLenum format = resource->format; 1321 GLenum format = resource->format;
1310 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id)); 1322 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id));
1311 if (use_texture_storage_ext_ && IsTextureFormatSupportedForStorage(format)) { 1323 if (use_texture_storage_ext_ && IsTextureFormatSupportedForStorage(format)) {
Sami 2013/08/08 10:11:01 glTexStorage2D should also work with RGBA4_OES so
kaanb 2013/08/08 17:25:05 I'm getting black tiles when I change the internal
1312 GLenum storage_format = TextureToStorageFormat(format); 1324 GLenum storage_format = TextureToStorageFormat(format);
1313 GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D, 1325 GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D,
1314 1, 1326 1,
1315 storage_format, 1327 storage_format,
1316 size.width(), 1328 size.width(),
1317 size.height())); 1329 size.height()));
1318 } else { 1330 } else {
1331 GLenum texture_data_type = use_16bit_textures_
1332 ? GL_UNSIGNED_SHORT_4_4_4_4 : GL_UNSIGNED_BYTE;
1319 GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D, 1333 GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D,
1320 0, 1334 0,
1321 format, 1335 format,
1322 size.width(), 1336 size.width(),
1323 size.height(), 1337 size.height(),
1324 0, 1338 0,
1325 format, 1339 format,
1326 GL_UNSIGNED_BYTE, 1340 texture_data_type,
Sami 2013/08/08 10:11:01 This parameter only sets the format of the data th
kaanb 2013/08/08 17:25:05 See the comment on RGBA4_OES above.
1327 NULL)); 1341 NULL));
1328 } 1342 }
1329 } 1343 }
1330 1344
1331 void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id, 1345 void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id,
1332 bool enable) { 1346 bool enable) {
1333 DCHECK(thread_checker_.CalledOnValidThread()); 1347 DCHECK(thread_checker_.CalledOnValidThread());
1334 ResourceMap::iterator it = resources_.find(id); 1348 ResourceMap::iterator it = resources_.find(id);
1335 CHECK(it != resources_.end()); 1349 CHECK(it != resources_.end());
1336 Resource* resource = &it->second; 1350 Resource* resource = &it->second;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 return stride; 1453 return stride;
1440 } 1454 }
1441 1455
1442 GLint ResourceProvider::GetActiveTextureUnit(WebGraphicsContext3D* context) { 1456 GLint ResourceProvider::GetActiveTextureUnit(WebGraphicsContext3D* context) {
1443 GLint active_unit = 0; 1457 GLint active_unit = 0;
1444 context->getIntegerv(GL_ACTIVE_TEXTURE, &active_unit); 1458 context->getIntegerv(GL_ACTIVE_TEXTURE, &active_unit);
1445 return active_unit; 1459 return active_unit;
1446 } 1460 }
1447 1461
1448 } // namespace cc 1462 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698