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

Unified 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: Fix raster-on-demand codepath Created 7 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 side-by-side diff with in-line comments
Download patch
Index: cc/resources/resource_provider.cc
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
index 9779a546958441a5af186e05e316b4dcc795e1bd..66b31183ffdaedb9c17c174b2cf2c1ee2ae05bbc 100644
--- a/cc/resources/resource_provider.cc
+++ b/cc/resources/resource_provider.cc
@@ -7,6 +7,10 @@
#include <algorithm>
#include <limits>
+#if defined(OS_ANDROID)
+#include "base/android/sys_utils.h"
+#endif
+
#include "base/containers/hash_tables.h"
#include "base/debug/alias.h"
#include "base/stl_util.h"
@@ -681,8 +685,13 @@ ResourceProvider::ResourceProvider(OutputSurface* output_surface,
use_texture_usage_hint_(false),
use_shallow_flush_(false),
max_texture_size_(0),
- best_texture_format_(0) {
+ best_texture_format_(0),
epennerAtGoogle 2013/09/05 01:54:15 Could we have best_texture_type in addition to bes
kaanb 2013/09/06 02:05:54 Done.
+ use_16_bit_textures_(false) {
DCHECK(output_surface_->HasClient());
+#if defined(OS_ANDROID)
+ if (base::android::SysUtils::IsLowEndDevice())
+ use_16_bit_textures_ = true;
enne (OOO) 2013/09/05 02:01:19 Please make this a LayerTreeSetting and keep the #
kaanb 2013/09/06 02:05:54 Done.
+#endif
}
void ResourceProvider::InitializeSoftware() {
@@ -719,7 +728,10 @@ bool ResourceProvider::InitializeGL() {
use_texture_usage_hint_ = caps.texture_usage;
texture_uploader_ =
- TextureUploader::Create(context3d, use_map_sub, use_shallow_flush_);
+ TextureUploader::Create(context3d,
+ use_map_sub,
+ use_shallow_flush_,
+ use_16_bit_textures_);
GLC(context3d, context3d->getIntegerv(GL_MAX_TEXTURE_SIZE,
&max_texture_size_));
best_texture_format_ = PlatformColor::BestTextureFormat(use_bgra);
@@ -975,9 +987,10 @@ void ResourceProvider::AcquirePixelBuffer(ResourceId id) {
context3d->bindBuffer(
GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
resource->gl_pixel_buffer_id);
+ size_t bytes_per_pixel = use_16_bit_textures_ ? 2 : 4;
context3d->bufferData(
GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
- 4 * resource->size.GetArea(),
+ bytes_per_pixel * resource->size.GetArea(),
NULL,
GL_DYNAMIC_DRAW);
context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
@@ -1159,6 +1172,8 @@ void ResourceProvider::BeginSetPixels(ResourceId id) {
context3d->beginQueryEXT(
GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM,
resource->gl_upload_query_id);
+ GLenum texture_data_type = use_16_bit_textures_
enne (OOO) 2013/09/05 02:01:19 Rather than having to pass around booleans and set
kaanb 2013/09/06 02:05:54 Great point, I didn't have time for it today. I'll
+ ? GL_UNSIGNED_SHORT_4_4_4_4 : GL_UNSIGNED_BYTE;
if (allocate) {
context3d->asyncTexImage2DCHROMIUM(GL_TEXTURE_2D,
0, /* level */
@@ -1167,7 +1182,7 @@ void ResourceProvider::BeginSetPixels(ResourceId id) {
resource->size.height(),
0, /* border */
resource->format,
- GL_UNSIGNED_BYTE,
+ texture_data_type,
NULL);
} else {
context3d->asyncTexSubImage2DCHROMIUM(GL_TEXTURE_2D,
@@ -1177,7 +1192,7 @@ void ResourceProvider::BeginSetPixels(ResourceId id) {
resource->size.width(),
resource->size.height(),
resource->format,
- GL_UNSIGNED_BYTE,
+ texture_data_type,
NULL);
}
context3d->endQueryEXT(GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM);
@@ -1288,6 +1303,8 @@ void ResourceProvider::LazyAllocate(Resource* resource) {
size.width(),
size.height()));
} else {
+ GLenum texture_data_type = use_16_bit_textures_
+ ? GL_UNSIGNED_SHORT_4_4_4_4 : GL_UNSIGNED_BYTE;
GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D,
0,
format,
@@ -1295,7 +1312,7 @@ void ResourceProvider::LazyAllocate(Resource* resource) {
size.height(),
0,
format,
- GL_UNSIGNED_BYTE,
+ texture_data_type,
NULL));
}
}

Powered by Google App Engine
This is Rietveld 408576698