| Index: cc/resources/resource_provider.cc
|
| diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
|
| index 9779a546958441a5af186e05e316b4dcc795e1bd..fe0547277770fdbd1d82c50e6aa58e96373092e1 100644
|
| --- a/cc/resources/resource_provider.cc
|
| +++ b/cc/resources/resource_provider.cc
|
| @@ -161,9 +161,12 @@ ResourceProvider::Child::~Child() {}
|
|
|
| scoped_ptr<ResourceProvider> ResourceProvider::Create(
|
| OutputSurface* output_surface,
|
| - int highp_threshold_min) {
|
| + int highp_threshold_min,
|
| + bool use_rgba_4444_textures) {
|
| scoped_ptr<ResourceProvider> resource_provider(
|
| - new ResourceProvider(output_surface, highp_threshold_min));
|
| + new ResourceProvider(output_surface,
|
| + highp_threshold_min,
|
| + use_rgba_4444_textures));
|
|
|
| bool success = false;
|
| if (resource_provider->Context3d()) {
|
| @@ -670,7 +673,8 @@ ResourceProvider::ScopedWriteLockSoftware::~ScopedWriteLockSoftware() {
|
| }
|
|
|
| ResourceProvider::ResourceProvider(OutputSurface* output_surface,
|
| - int highp_threshold_min)
|
| + int highp_threshold_min,
|
| + bool use_rgba_4444_textures)
|
| : output_surface_(output_surface),
|
| lost_output_surface_(false),
|
| highp_threshold_min_(highp_threshold_min),
|
| @@ -681,7 +685,8 @@ 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),
|
| + best_texture_type_(use_rgba_4444_textures ? RGBA_4444 : RGBA_8888) {
|
| DCHECK(output_surface_->HasClient());
|
| }
|
|
|
| @@ -719,7 +724,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_,
|
| + best_texture_type_ == RGBA_4444);
|
| GLC(context3d, context3d->getIntegerv(GL_MAX_TEXTURE_SIZE,
|
| &max_texture_size_));
|
| best_texture_format_ = PlatformColor::BestTextureFormat(use_bgra);
|
| @@ -975,9 +983,10 @@ void ResourceProvider::AcquirePixelBuffer(ResourceId id) {
|
| context3d->bindBuffer(
|
| GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
|
| resource->gl_pixel_buffer_id);
|
| + size_t bytes_per_pixel = (best_texture_type_ == RGBA_4444) ? 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 +1168,19 @@ void ResourceProvider::BeginSetPixels(ResourceId id) {
|
| context3d->beginQueryEXT(
|
| GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM,
|
| resource->gl_upload_query_id);
|
| + GLenum texture_data_type = GL_UNSIGNED_BYTE;
|
| + switch (best_texture_type_) {
|
| + case RGBA_4444:
|
| + texture_data_type = GL_UNSIGNED_SHORT_4_4_4_4;
|
| + break;
|
| + case RGBA_8888:
|
| + texture_data_type = GL_UNSIGNED_BYTE;
|
| + break;
|
| + default:
|
| + NOTREACHED();
|
| + break;
|
| + }
|
| +
|
| if (allocate) {
|
| context3d->asyncTexImage2DCHROMIUM(GL_TEXTURE_2D,
|
| 0, /* level */
|
| @@ -1167,7 +1189,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 +1199,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 +1310,18 @@ void ResourceProvider::LazyAllocate(Resource* resource) {
|
| size.width(),
|
| size.height()));
|
| } else {
|
| + GLenum texture_data_type = GL_UNSIGNED_BYTE;
|
| + switch (best_texture_type_) {
|
| + case RGBA_4444:
|
| + texture_data_type = GL_UNSIGNED_SHORT_4_4_4_4;
|
| + break;
|
| + case RGBA_8888:
|
| + texture_data_type = GL_UNSIGNED_BYTE;
|
| + break;
|
| + default:
|
| + NOTREACHED();
|
| + break;
|
| + }
|
| GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D,
|
| 0,
|
| format,
|
| @@ -1295,7 +1329,7 @@ void ResourceProvider::LazyAllocate(Resource* resource) {
|
| size.height(),
|
| 0,
|
| format,
|
| - GL_UNSIGNED_BYTE,
|
| + texture_data_type,
|
| NULL));
|
| }
|
| }
|
|
|