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 <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" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/trace_event/trace_event.h" | 15 #include "base/trace_event/trace_event.h" |
16 #include "cc/base/util.h" | 16 #include "cc/base/util.h" |
17 #include "cc/resources/platform_color.h" | 17 #include "cc/resources/platform_color.h" |
18 #include "cc/resources/returned_resource.h" | 18 #include "cc/resources/returned_resource.h" |
19 #include "cc/resources/shared_bitmap_manager.h" | 19 #include "cc/resources/shared_bitmap_manager.h" |
20 #include "cc/resources/texture_uploader.h" | 20 #include "cc/resources/texture_uploader.h" |
21 #include "cc/resources/transferable_resource.h" | 21 #include "cc/resources/transferable_resource.h" |
22 #include "gpu/GLES2/gl2extchromium.h" | 22 #include "gpu/GLES2/gl2extchromium.h" |
23 #include "gpu/command_buffer/client/gles2_interface.h" | 23 #include "gpu/command_buffer/client/gles2_interface.h" |
24 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" | 24 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
25 #include "third_party/khronos/GLES2/gl2.h" | 25 #include "third_party/khronos/GLES2/gl2.h" |
26 #include "third_party/khronos/GLES2/gl2ext.h" | 26 #include "third_party/khronos/GLES2/gl2ext.h" |
27 #include "third_party/skia/include/core/SkSurface.h" | 27 #include "third_party/skia/include/core/SkSurface.h" |
28 #include "third_party/skia/include/gpu/GrContext.h" | 28 #include "third_party/skia/include/gpu/GrContext.h" |
29 #include "third_party/skia/include/gpu/GrTextureProvider.h" | 29 #include "third_party/skia/include/gpu/GrTextureProvider.h" |
30 #include "ui/gfx/frame_time.h" | |
31 #include "ui/gfx/geometry/rect.h" | 30 #include "ui/gfx/geometry/rect.h" |
32 #include "ui/gfx/geometry/vector2d.h" | 31 #include "ui/gfx/geometry/vector2d.h" |
33 #include "ui/gfx/gpu_memory_buffer.h" | 32 #include "ui/gfx/gpu_memory_buffer.h" |
34 | 33 |
35 using gpu::gles2::GLES2Interface; | 34 using gpu::gles2::GLES2Interface; |
36 | 35 |
37 namespace cc { | 36 namespace cc { |
38 | 37 |
39 class IdAllocator { | 38 class IdAllocator { |
40 public: | 39 public: |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 } | 829 } |
831 | 830 |
832 base::TimeTicks ResourceProvider::EstimatedUploadCompletionTime( | 831 base::TimeTicks ResourceProvider::EstimatedUploadCompletionTime( |
833 size_t uploads_per_tick) { | 832 size_t uploads_per_tick) { |
834 if (lost_output_surface_) | 833 if (lost_output_surface_) |
835 return base::TimeTicks(); | 834 return base::TimeTicks(); |
836 | 835 |
837 // Software resource uploads happen on impl thread, so don't bother batching | 836 // Software resource uploads happen on impl thread, so don't bother batching |
838 // them up and trying to wait for them to complete. | 837 // them up and trying to wait for them to complete. |
839 if (!texture_uploader_) { | 838 if (!texture_uploader_) { |
840 return gfx::FrameTime::Now() + base::TimeDelta::FromMicroseconds( | 839 return base::TimeTicks::Now() + |
841 base::Time::kMicrosecondsPerSecond * kSoftwareUploadTickRate); | 840 base::TimeDelta::FromMicroseconds( |
| 841 base::Time::kMicrosecondsPerSecond * kSoftwareUploadTickRate); |
842 } | 842 } |
843 | 843 |
844 base::TimeDelta upload_one_texture_time = | 844 base::TimeDelta upload_one_texture_time = |
845 base::TimeDelta::FromMicroseconds( | 845 base::TimeDelta::FromMicroseconds( |
846 base::Time::kMicrosecondsPerSecond * kTextureUploadTickRate) / | 846 base::Time::kMicrosecondsPerSecond * kTextureUploadTickRate) / |
847 uploads_per_tick; | 847 uploads_per_tick; |
848 | 848 |
849 size_t total_uploads = NumBlockingUploads() + uploads_per_tick; | 849 size_t total_uploads = NumBlockingUploads() + uploads_per_tick; |
850 return gfx::FrameTime::Now() + upload_one_texture_time * total_uploads; | 850 return base::TimeTicks::Now() + upload_one_texture_time * total_uploads; |
851 } | 851 } |
852 | 852 |
853 ResourceProvider::Resource* ResourceProvider::InsertResource( | 853 ResourceProvider::Resource* ResourceProvider::InsertResource( |
854 ResourceId id, | 854 ResourceId id, |
855 const Resource& resource) { | 855 const Resource& resource) { |
856 std::pair<ResourceMap::iterator, bool> result = | 856 std::pair<ResourceMap::iterator, bool> result = |
857 resources_.insert(ResourceMap::value_type(id, resource)); | 857 resources_.insert(ResourceMap::value_type(id, resource)); |
858 DCHECK(result.second); | 858 DCHECK(result.second); |
859 return &result.first->second; | 859 return &result.first->second; |
860 } | 860 } |
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2052 } | 2052 } |
2053 | 2053 |
2054 class GrContext* ResourceProvider::GrContext(bool worker_context) const { | 2054 class GrContext* ResourceProvider::GrContext(bool worker_context) const { |
2055 ContextProvider* context_provider = | 2055 ContextProvider* context_provider = |
2056 worker_context ? output_surface_->worker_context_provider() | 2056 worker_context ? output_surface_->worker_context_provider() |
2057 : output_surface_->context_provider(); | 2057 : output_surface_->context_provider(); |
2058 return context_provider ? context_provider->GrContext() : NULL; | 2058 return context_provider ? context_provider->GrContext() : NULL; |
2059 } | 2059 } |
2060 | 2060 |
2061 } // namespace cc | 2061 } // namespace cc |
OLD | NEW |