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/debug/trace_event.h" | 11 #include "base/debug/trace_event.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 "cc/base/util.h" | 15 #include "cc/base/util.h" |
16 #include "cc/output/gl_renderer.h" // For the GLC() macro. | 16 #include "cc/output/gl_renderer.h" // For the GLC() macro. |
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/transferable_resource.h" | 20 #include "cc/resources/transferable_resource.h" |
21 #include "cc/scheduler/texture_uploader.h" | 21 #include "cc/scheduler/texture_uploader.h" |
22 #include "gpu/GLES2/gl2extchromium.h" | 22 #include "gpu/GLES2/gl2extchromium.h" |
23 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 23 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
24 #include "third_party/khronos/GLES2/gl2.h" | 24 #include "third_party/khronos/GLES2/gl2.h" |
25 #include "third_party/khronos/GLES2/gl2ext.h" | 25 #include "third_party/khronos/GLES2/gl2ext.h" |
| 26 #include "ui/gfx/frame_time.h" |
26 #include "ui/gfx/rect.h" | 27 #include "ui/gfx/rect.h" |
27 #include "ui/gfx/vector2d.h" | 28 #include "ui/gfx/vector2d.h" |
28 | 29 |
29 using blink::WebGraphicsContext3D; | 30 using blink::WebGraphicsContext3D; |
30 | 31 |
31 namespace cc { | 32 namespace cc { |
32 | 33 |
33 class IdAllocator { | 34 class IdAllocator { |
34 public: | 35 public: |
35 virtual ~IdAllocator() {} | 36 virtual ~IdAllocator() {} |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 return texture_uploader_->NumBlockingUploads(); | 643 return texture_uploader_->NumBlockingUploads(); |
643 } | 644 } |
644 | 645 |
645 void ResourceProvider::MarkPendingUploadsAsNonBlocking() { | 646 void ResourceProvider::MarkPendingUploadsAsNonBlocking() { |
646 if (!texture_uploader_) | 647 if (!texture_uploader_) |
647 return; | 648 return; |
648 | 649 |
649 texture_uploader_->MarkPendingUploadsAsNonBlocking(); | 650 texture_uploader_->MarkPendingUploadsAsNonBlocking(); |
650 } | 651 } |
651 | 652 |
652 double ResourceProvider::EstimatedUploadsPerSecond() { | 653 size_t ResourceProvider::EstimatedUploadsPerTick() { |
653 if (!texture_uploader_) | 654 if (!texture_uploader_) |
654 return 0.0; | 655 return 1u; |
655 | 656 |
656 return texture_uploader_->EstimatedTexturesPerSecond(); | 657 double textures_per_second = texture_uploader_->EstimatedTexturesPerSecond(); |
| 658 size_t textures_per_tick = floor( |
| 659 kTextureUploadTickRate * textures_per_second); |
| 660 return textures_per_tick ? textures_per_tick : 1u; |
657 } | 661 } |
658 | 662 |
659 void ResourceProvider::FlushUploads() { | 663 void ResourceProvider::FlushUploads() { |
660 if (!texture_uploader_) | 664 if (!texture_uploader_) |
661 return; | 665 return; |
662 | 666 |
663 texture_uploader_->Flush(); | 667 texture_uploader_->Flush(); |
664 } | 668 } |
665 | 669 |
666 void ResourceProvider::ReleaseCachedData() { | 670 void ResourceProvider::ReleaseCachedData() { |
667 if (!texture_uploader_) | 671 if (!texture_uploader_) |
668 return; | 672 return; |
669 | 673 |
670 texture_uploader_->ReleaseCachedQueries(); | 674 texture_uploader_->ReleaseCachedQueries(); |
671 } | 675 } |
672 | 676 |
673 base::TimeDelta ResourceProvider::TextureUpdateTickRate() { | 677 base::TimeTicks ResourceProvider::EstimatedUploadCompletionTime( |
| 678 size_t uploads_per_tick) { |
| 679 if (lost_output_surface_) |
| 680 return base::TimeTicks(); |
| 681 |
674 // Software resource uploads happen on impl thread, so don't bother batching | 682 // Software resource uploads happen on impl thread, so don't bother batching |
675 // them up and trying to wait for them to complete. | 683 // them up and trying to wait for them to complete. |
676 double rate = | 684 if (!texture_uploader_) { |
677 texture_uploader_ ? kTextureUploadTickRate : kSoftwareUploadTickRate; | 685 return gfx::FrameTime::Now() + base::TimeDelta::FromMicroseconds( |
678 return base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond * | 686 base::Time::kMicrosecondsPerSecond * kSoftwareUploadTickRate); |
679 rate); | 687 } |
| 688 |
| 689 base::TimeDelta upload_one_texture_time = |
| 690 base::TimeDelta::FromMicroseconds( |
| 691 base::Time::kMicrosecondsPerSecond * kTextureUploadTickRate) / |
| 692 uploads_per_tick; |
| 693 |
| 694 size_t total_uploads = NumBlockingUploads() + uploads_per_tick; |
| 695 return gfx::FrameTime::Now() + upload_one_texture_time * total_uploads; |
680 } | 696 } |
681 | 697 |
682 void ResourceProvider::Flush() { | 698 void ResourceProvider::Flush() { |
683 DCHECK(thread_checker_.CalledOnValidThread()); | 699 DCHECK(thread_checker_.CalledOnValidThread()); |
684 WebGraphicsContext3D* context3d = Context3d(); | 700 WebGraphicsContext3D* context3d = Context3d(); |
685 if (context3d) | 701 if (context3d) |
686 context3d->flush(); | 702 context3d->flush(); |
687 } | 703 } |
688 | 704 |
689 void ResourceProvider::Finish() { | 705 void ResourceProvider::Finish() { |
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1834 context->getIntegerv(GL_ACTIVE_TEXTURE, &active_unit); | 1850 context->getIntegerv(GL_ACTIVE_TEXTURE, &active_unit); |
1835 return active_unit; | 1851 return active_unit; |
1836 } | 1852 } |
1837 | 1853 |
1838 blink::WebGraphicsContext3D* ResourceProvider::Context3d() const { | 1854 blink::WebGraphicsContext3D* ResourceProvider::Context3d() const { |
1839 ContextProvider* context_provider = output_surface_->context_provider(); | 1855 ContextProvider* context_provider = output_surface_->context_provider(); |
1840 return context_provider ? context_provider->Context3d() : NULL; | 1856 return context_provider ? context_provider->Context3d() : NULL; |
1841 } | 1857 } |
1842 | 1858 |
1843 } // namespace cc | 1859 } // namespace cc |
OLD | NEW |