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

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: addressed latest comments, rebased 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
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 = BytesPerPixel(resource->format);
(...skipping 312 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 if (format == ETC1) {
1600 0, 1604 DCHECK(use_compressed_texture_etc1_);
1601 GLInternalFormat(format), 1605 DCHECK_EQ(0, size.width() % 4);
1602 size.width(), 1606 DCHECK_EQ(0, size.height() % 4);
1603 size.height(), 1607 GLC(context3d,
1604 0, 1608 context3d->compressedTexImage2D(
1605 GLDataFormat(format), 1609 GL_TEXTURE_2D,
1606 GLDataType(format), 1610 0,
1607 NULL)); 1611 GLInternalFormat(format),
1612 size.width(),
1613 size.height(),
1614 0,
1615 cc::Resource::MemorySizeBytes(size, format),
1616 NULL));
no sievers 2013/10/23 22:49:59 I don't think glCompressedTexImage2D() supports pa
powei 2013/10/23 23:25:58 Done. Thanks for catching that.
1617 } else {
1618 GLC(context3d,
1619 context3d->texImage2D(GL_TEXTURE_2D,
1620 0,
1621 GLInternalFormat(format),
1622 size.width(),
1623 size.height(),
1624 0,
1625 GLDataFormat(format),
1626 GLDataType(format),
1627 NULL));
1628 }
1608 } 1629 }
1609 } 1630 }
1610 1631
1611 void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id, 1632 void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id,
1612 bool enable) { 1633 bool enable) {
1613 Resource* resource = GetResource(id); 1634 Resource* resource = GetResource(id);
1614 resource->enable_read_lock_fences = enable; 1635 resource->enable_read_lock_fences = enable;
1615 } 1636 }
1616 1637
1617 void ResourceProvider::AcquireImage(ResourceId id) { 1638 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); 1736 context->getIntegerv(GL_ACTIVE_TEXTURE, &active_unit);
1716 return active_unit; 1737 return active_unit;
1717 } 1738 }
1718 1739
1719 WebKit::WebGraphicsContext3D* ResourceProvider::Context3d() const { 1740 WebKit::WebGraphicsContext3D* ResourceProvider::Context3d() const {
1720 ContextProvider* context_provider = output_surface_->context_provider(); 1741 ContextProvider* context_provider = output_surface_->context_provider();
1721 return context_provider ? context_provider->Context3d() : NULL; 1742 return context_provider ? context_provider->Context3d() : NULL;
1722 } 1743 }
1723 1744
1724 } // namespace cc 1745 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698