| OLD | NEW |
| 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 <limits.h> | 7 #include <limits.h> |
| 8 | 8 |
| 9 #include "base/debug/alias.h" | 9 #include "base/debug/alias.h" |
| 10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 size(size), | 126 size(size), |
| 127 format(format), | 127 format(format), |
| 128 filter(filter), | 128 filter(filter), |
| 129 type(Bitmap) {} | 129 type(Bitmap) {} |
| 130 | 130 |
| 131 ResourceProvider::Child::Child() {} | 131 ResourceProvider::Child::Child() {} |
| 132 | 132 |
| 133 ResourceProvider::Child::~Child() {} | 133 ResourceProvider::Child::~Child() {} |
| 134 | 134 |
| 135 scoped_ptr<ResourceProvider> ResourceProvider::Create( | 135 scoped_ptr<ResourceProvider> ResourceProvider::Create( |
| 136 OutputSurface* output_surface) { | 136 OutputSurface* output_surface, |
| 137 int highp_threshold_min) { |
| 137 scoped_ptr<ResourceProvider> resource_provider( | 138 scoped_ptr<ResourceProvider> resource_provider( |
| 138 new ResourceProvider(output_surface)); | 139 new ResourceProvider(output_surface)); |
| 139 if (!resource_provider->Initialize()) | 140 if (!resource_provider->Initialize(highp_threshold_min)) |
| 140 return scoped_ptr<ResourceProvider>(); | 141 return scoped_ptr<ResourceProvider>(); |
| 141 return resource_provider.Pass(); | 142 return resource_provider.Pass(); |
| 142 } | 143 } |
| 143 | 144 |
| 144 ResourceProvider::~ResourceProvider() { | 145 ResourceProvider::~ResourceProvider() { |
| 145 WebGraphicsContext3D* context3d = output_surface_->context3d(); | 146 WebGraphicsContext3D* context3d = output_surface_->context3d(); |
| 146 if (!context3d || !context3d->makeContextCurrent()) | 147 if (!context3d || !context3d->makeContextCurrent()) |
| 147 return; | 148 return; |
| 148 texture_uploader_.reset(); | 149 texture_uploader_.reset(); |
| 149 texture_copier_.reset(); | 150 texture_copier_.reset(); |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 : output_surface_(output_surface), | 592 : output_surface_(output_surface), |
| 592 next_id_(1), | 593 next_id_(1), |
| 593 next_child_(1), | 594 next_child_(1), |
| 594 default_resource_type_(GLTexture), | 595 default_resource_type_(GLTexture), |
| 595 use_texture_storage_ext_(false), | 596 use_texture_storage_ext_(false), |
| 596 use_texture_usage_hint_(false), | 597 use_texture_usage_hint_(false), |
| 597 use_shallow_flush_(false), | 598 use_shallow_flush_(false), |
| 598 max_texture_size_(0), | 599 max_texture_size_(0), |
| 599 best_texture_format_(0) {} | 600 best_texture_format_(0) {} |
| 600 | 601 |
| 601 bool ResourceProvider::Initialize() { | 602 bool ResourceProvider::Initialize(int highp_threshold_min) { |
| 602 DCHECK(thread_checker_.CalledOnValidThread()); | 603 DCHECK(thread_checker_.CalledOnValidThread()); |
| 603 WebGraphicsContext3D* context3d = output_surface_->context3d(); | 604 WebGraphicsContext3D* context3d = output_surface_->context3d(); |
| 604 if (!context3d) { | 605 if (!context3d) { |
| 605 max_texture_size_ = INT_MAX / 2; | 606 max_texture_size_ = INT_MAX / 2; |
| 606 best_texture_format_ = GL_RGBA; | 607 best_texture_format_ = GL_RGBA; |
| 607 return true; | 608 return true; |
| 608 } | 609 } |
| 609 if (!context3d->makeContextCurrent()) | 610 if (!context3d->makeContextCurrent()) |
| 610 return false; | 611 return false; |
| 611 | 612 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 624 else if (extensions[i] == "GL_CHROMIUM_map_sub") | 625 else if (extensions[i] == "GL_CHROMIUM_map_sub") |
| 625 use_map_sub = true; | 626 use_map_sub = true; |
| 626 else if (extensions[i] == "GL_CHROMIUM_shallow_flush") | 627 else if (extensions[i] == "GL_CHROMIUM_shallow_flush") |
| 627 use_shallow_flush_ = true; | 628 use_shallow_flush_ = true; |
| 628 else if (extensions[i] == "GL_CHROMIUM_bind_uniform_location") | 629 else if (extensions[i] == "GL_CHROMIUM_bind_uniform_location") |
| 629 use_bind_uniform = true; | 630 use_bind_uniform = true; |
| 630 else if (extensions[i] == "GL_EXT_texture_format_BGRA8888") | 631 else if (extensions[i] == "GL_EXT_texture_format_BGRA8888") |
| 631 use_bgra = true; | 632 use_bgra = true; |
| 632 } | 633 } |
| 633 | 634 |
| 634 texture_copier_ = | 635 texture_copier_ = AcceleratedTextureCopier::Create( |
| 635 AcceleratedTextureCopier::Create(context3d, use_bind_uniform); | 636 context3d, use_bind_uniform, highp_threshold_min); |
| 636 | 637 |
| 637 texture_uploader_ = | 638 texture_uploader_ = |
| 638 TextureUploader::Create(context3d, use_map_sub, use_shallow_flush_); | 639 TextureUploader::Create(context3d, use_map_sub, use_shallow_flush_); |
| 639 GLC(context3d, context3d->getIntegerv(GL_MAX_TEXTURE_SIZE, | 640 GLC(context3d, context3d->getIntegerv(GL_MAX_TEXTURE_SIZE, |
| 640 &max_texture_size_)); | 641 &max_texture_size_)); |
| 641 best_texture_format_ = | 642 best_texture_format_ = |
| 642 PlatformColor::BestTextureFormat(context3d, use_bgra); | 643 PlatformColor::BestTextureFormat(context3d, use_bgra); |
| 643 return true; | 644 return true; |
| 644 } | 645 } |
| 645 | 646 |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1203 void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id, | 1204 void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id, |
| 1204 bool enable) { | 1205 bool enable) { |
| 1205 DCHECK(thread_checker_.CalledOnValidThread()); | 1206 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1206 ResourceMap::iterator it = resources_.find(id); | 1207 ResourceMap::iterator it = resources_.find(id); |
| 1207 CHECK(it != resources_.end()); | 1208 CHECK(it != resources_.end()); |
| 1208 Resource* resource = &it->second; | 1209 Resource* resource = &it->second; |
| 1209 resource->enable_read_lock_fences = enable; | 1210 resource->enable_read_lock_fences = enable; |
| 1210 } | 1211 } |
| 1211 | 1212 |
| 1212 } // namespace cc | 1213 } // namespace cc |
| OLD | NEW |