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" | 30 |
31 #include "ui/gfx/geometry/rect.h" | 31 #include "ui/gfx/geometry/rect.h" |
32 #include "ui/gfx/geometry/vector2d.h" | 32 #include "ui/gfx/geometry/vector2d.h" |
33 #include "ui/gfx/gpu_memory_buffer.h" | 33 #include "ui/gfx/gpu_memory_buffer.h" |
34 | 34 |
35 using gpu::gles2::GLES2Interface; | 35 using gpu::gles2::GLES2Interface; |
36 | 36 |
37 namespace cc { | 37 namespace cc { |
38 | 38 |
39 class IdAllocator { | 39 class IdAllocator { |
40 public: | 40 public: |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 } | 833 } |
834 | 834 |
835 base::TimeTicks ResourceProvider::EstimatedUploadCompletionTime( | 835 base::TimeTicks ResourceProvider::EstimatedUploadCompletionTime( |
836 size_t uploads_per_tick) { | 836 size_t uploads_per_tick) { |
837 if (lost_output_surface_) | 837 if (lost_output_surface_) |
838 return base::TimeTicks(); | 838 return base::TimeTicks(); |
839 | 839 |
840 // Software resource uploads happen on impl thread, so don't bother batching | 840 // Software resource uploads happen on impl thread, so don't bother batching |
841 // them up and trying to wait for them to complete. | 841 // them up and trying to wait for them to complete. |
842 if (!texture_uploader_) { | 842 if (!texture_uploader_) { |
843 return gfx::FrameTime::Now() + base::TimeDelta::FromMicroseconds( | 843 return base::TimeTicks::Now() + |
844 base::Time::kMicrosecondsPerSecond * kSoftwareUploadTickRate); | 844 base::TimeDelta::FromMicroseconds( |
| 845 base::Time::kMicrosecondsPerSecond * kSoftwareUploadTickRate); |
845 } | 846 } |
846 | 847 |
847 base::TimeDelta upload_one_texture_time = | 848 base::TimeDelta upload_one_texture_time = |
848 base::TimeDelta::FromMicroseconds( | 849 base::TimeDelta::FromMicroseconds( |
849 base::Time::kMicrosecondsPerSecond * kTextureUploadTickRate) / | 850 base::Time::kMicrosecondsPerSecond * kTextureUploadTickRate) / |
850 uploads_per_tick; | 851 uploads_per_tick; |
851 | 852 |
852 size_t total_uploads = NumBlockingUploads() + uploads_per_tick; | 853 size_t total_uploads = NumBlockingUploads() + uploads_per_tick; |
853 return gfx::FrameTime::Now() + upload_one_texture_time * total_uploads; | 854 return base::TimeTicks::Now() + upload_one_texture_time * total_uploads; |
854 } | 855 } |
855 | 856 |
856 ResourceProvider::Resource* ResourceProvider::InsertResource( | 857 ResourceProvider::Resource* ResourceProvider::InsertResource( |
857 ResourceId id, | 858 ResourceId id, |
858 const Resource& resource) { | 859 const Resource& resource) { |
859 std::pair<ResourceMap::iterator, bool> result = | 860 std::pair<ResourceMap::iterator, bool> result = |
860 resources_.insert(ResourceMap::value_type(id, resource)); | 861 resources_.insert(ResourceMap::value_type(id, resource)); |
861 DCHECK(result.second); | 862 DCHECK(result.second); |
862 return &result.first->second; | 863 return &result.first->second; |
863 } | 864 } |
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2056 } | 2057 } |
2057 | 2058 |
2058 class GrContext* ResourceProvider::GrContext(bool worker_context) const { | 2059 class GrContext* ResourceProvider::GrContext(bool worker_context) const { |
2059 ContextProvider* context_provider = | 2060 ContextProvider* context_provider = |
2060 worker_context ? output_surface_->worker_context_provider() | 2061 worker_context ? output_surface_->worker_context_provider() |
2061 : output_surface_->context_provider(); | 2062 : output_surface_->context_provider(); |
2062 return context_provider ? context_provider->GrContext() : NULL; | 2063 return context_provider ? context_provider->GrContext() : NULL; |
2063 } | 2064 } |
2064 | 2065 |
2065 } // namespace cc | 2066 } // namespace cc |
OLD | NEW |