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

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

Issue 27973002: cc: Adding ETC1 support to UIResourceBitmap and ResourceProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: latest comments Created 7 years, 2 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 | Annotate | Revision Log
« 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 29 matching lines...) Expand all
40 GLenum storage_format = GL_RGBA8_OES; 40 GLenum storage_format = GL_RGBA8_OES;
41 switch (format) { 41 switch (format) {
42 case RGBA_8888: 42 case RGBA_8888:
43 break; 43 break;
44 case BGRA_8888: 44 case BGRA_8888:
45 storage_format = GL_BGRA8_EXT; 45 storage_format = GL_BGRA8_EXT;
46 break; 46 break;
47 case RGBA_4444: 47 case RGBA_4444:
48 case LUMINANCE_8: 48 case LUMINANCE_8:
49 case RGB_565: 49 case RGB_565:
50 case ETC1:
50 NOTREACHED(); 51 NOTREACHED();
51 break; 52 break;
52 } 53 }
53 54
54 return storage_format; 55 return storage_format;
55 } 56 }
56 57
57 bool IsFormatSupportedForStorage(ResourceFormat format) { 58 bool IsFormatSupportedForStorage(ResourceFormat format) {
58 switch (format) { 59 switch (format) {
59 case RGBA_8888: 60 case RGBA_8888:
60 case BGRA_8888: 61 case BGRA_8888:
61 return true; 62 return true;
62 case RGBA_4444: 63 case RGBA_4444:
63 case LUMINANCE_8: 64 case LUMINANCE_8:
64 case RGB_565: 65 case RGB_565:
66 case ETC1:
65 return false; 67 return false;
66 } 68 }
67 return false; 69 return false;
68 } 70 }
69 71
70 class ScopedSetActiveTexture { 72 class ScopedSetActiveTexture {
71 public: 73 public:
72 ScopedSetActiveTexture(WebGraphicsContext3D* context3d, GLenum unit) 74 ScopedSetActiveTexture(WebGraphicsContext3D* context3d, GLenum unit)
73 : context3d_(context3d), unit_(unit) { 75 : context3d_(context3d), unit_(unit) {
74 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(context3d_)); 76 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(context3d_));
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 default_resource_type_ = GLTexture; 833 default_resource_type_ = GLTexture;
832 834
833 const ContextProvider::Capabilities& caps = 835 const ContextProvider::Capabilities& caps =
834 output_surface_->context_provider()->ContextCapabilities(); 836 output_surface_->context_provider()->ContextCapabilities();
835 837
836 bool use_map_sub = caps.map_sub; 838 bool use_map_sub = caps.map_sub;
837 bool use_bgra = caps.texture_format_bgra8888; 839 bool use_bgra = caps.texture_format_bgra8888;
838 use_texture_storage_ext_ = caps.texture_storage; 840 use_texture_storage_ext_ = caps.texture_storage;
839 use_shallow_flush_ = caps.shallow_flush; 841 use_shallow_flush_ = caps.shallow_flush;
840 use_texture_usage_hint_ = caps.texture_usage; 842 use_texture_usage_hint_ = caps.texture_usage;
843 use_compressed_texture_etc1_ = caps.texture_format_etc1;
841 844
842 texture_uploader_ = 845 texture_uploader_ =
843 TextureUploader::Create(context3d, use_map_sub, use_shallow_flush_); 846 TextureUploader::Create(context3d, use_map_sub, use_shallow_flush_);
844 GLC(context3d, context3d->getIntegerv(GL_MAX_TEXTURE_SIZE, 847 GLC(context3d, context3d->getIntegerv(GL_MAX_TEXTURE_SIZE,
845 &max_texture_size_)); 848 &max_texture_size_));
846 best_texture_format_ = PlatformColor::BestTextureFormat(use_bgra); 849 best_texture_format_ = PlatformColor::BestTextureFormat(use_bgra);
847 850
848 return true; 851 return true;
849 } 852 }
850 853
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 1260
1258 if (!to_return.empty()) 1261 if (!to_return.empty())
1259 child_info->return_callback.Run(to_return); 1262 child_info->return_callback.Run(to_return);
1260 } 1263 }
1261 1264
1262 void ResourceProvider::AcquirePixelBuffer(ResourceId id) { 1265 void ResourceProvider::AcquirePixelBuffer(ResourceId id) {
1263 Resource* resource = GetResource(id); 1266 Resource* resource = GetResource(id);
1264 DCHECK(!resource->external); 1267 DCHECK(!resource->external);
1265 DCHECK_EQ(resource->exported_count, 0); 1268 DCHECK_EQ(resource->exported_count, 0);
1266 DCHECK(!resource->image_id); 1269 DCHECK(!resource->image_id);
1270 DCHECK_NE(ETC1, resource->format);
1267 1271
1268 if (resource->type == GLTexture) { 1272 if (resource->type == GLTexture) {
1269 WebGraphicsContext3D* context3d = Context3d(); 1273 WebGraphicsContext3D* context3d = Context3d();
1270 DCHECK(context3d); 1274 DCHECK(context3d);
1271 if (!resource->gl_pixel_buffer_id) 1275 if (!resource->gl_pixel_buffer_id)
1272 resource->gl_pixel_buffer_id = context3d->createBuffer(); 1276 resource->gl_pixel_buffer_id = context3d->createBuffer();
1273 context3d->bindBuffer( 1277 context3d->bindBuffer(
1274 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 1278 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
1275 resource->gl_pixel_buffer_id); 1279 resource->gl_pixel_buffer_id);
1276 unsigned bytes_per_pixel = BytesPerPixel(resource->format); 1280 unsigned bytes_per_pixel = BitsPerPixel(resource->format) / 8;
1277 context3d->bufferData( 1281 context3d->bufferData(
1278 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 1282 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
1279 resource->size.height() * RoundUp(bytes_per_pixel 1283 resource->size.height() * RoundUp(bytes_per_pixel
1280 * resource->size.width(), 4u), 1284 * resource->size.width(), 4u),
1281 NULL, 1285 NULL,
1282 GL_DYNAMIC_DRAW); 1286 GL_DYNAMIC_DRAW);
1283 context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); 1287 context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
1284 } 1288 }
1285 1289
1286 if (resource->pixels) { 1290 if (resource->pixels) {
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 ResourceFormat format = resource->format; 1593 ResourceFormat format = resource->format;
1590 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id)); 1594 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id));
1591 if (use_texture_storage_ext_ && IsFormatSupportedForStorage(format)) { 1595 if (use_texture_storage_ext_ && IsFormatSupportedForStorage(format)) {
1592 GLenum storage_format = TextureToStorageFormat(format); 1596 GLenum storage_format = TextureToStorageFormat(format);
1593 GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D, 1597 GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D,
1594 1, 1598 1,
1595 storage_format, 1599 storage_format,
1596 size.width(), 1600 size.width(),
1597 size.height())); 1601 size.height()));
1598 } else { 1602 } else {
1599 GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D, 1603 // ETC1 does not support preallocation.
1600 0, 1604 if (format != ETC1) {
1601 GLInternalFormat(format), 1605 GLC(context3d,
1602 size.width(), 1606 context3d->texImage2D(GL_TEXTURE_2D,
1603 size.height(), 1607 0,
1604 0, 1608 GLInternalFormat(format),
1605 GLDataFormat(format), 1609 size.width(),
1606 GLDataType(format), 1610 size.height(),
1607 NULL)); 1611 0,
1612 GLDataFormat(format),
1613 GLDataType(format),
1614 NULL));
1615 }
1608 } 1616 }
1609 } 1617 }
1610 1618
1611 void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id, 1619 void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id,
1612 bool enable) { 1620 bool enable) {
1613 Resource* resource = GetResource(id); 1621 Resource* resource = GetResource(id);
1614 resource->enable_read_lock_fences = enable; 1622 resource->enable_read_lock_fences = enable;
1615 } 1623 }
1616 1624
1617 void ResourceProvider::AcquireImage(ResourceId id) { 1625 void ResourceProvider::AcquireImage(ResourceId id) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1715 context->getIntegerv(GL_ACTIVE_TEXTURE, &active_unit); 1723 context->getIntegerv(GL_ACTIVE_TEXTURE, &active_unit);
1716 return active_unit; 1724 return active_unit;
1717 } 1725 }
1718 1726
1719 WebKit::WebGraphicsContext3D* ResourceProvider::Context3d() const { 1727 WebKit::WebGraphicsContext3D* ResourceProvider::Context3d() const {
1720 ContextProvider* context_provider = output_surface_->context_provider(); 1728 ContextProvider* context_provider = output_surface_->context_provider();
1721 return context_provider ? context_provider->Context3d() : NULL; 1729 return context_provider ? context_provider->Context3d() : NULL;
1722 } 1730 }
1723 1731
1724 } // namespace cc 1732 } // 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