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 #ifndef ThrottledTextureUploader_h | 5 #ifndef ThrottledTextureUploader_h |
6 #define ThrottledTextureUploader_h | 6 #define ThrottledTextureUploader_h |
7 | 7 |
8 #include "TextureUploader.h" | 8 #include "TextureUploader.h" |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include <deque> | 11 #include <deque> |
12 #include <wtf/Deque.h> | 12 #include <wtf/Deque.h> |
13 | 13 |
14 namespace WebKit { | 14 namespace WebKit { |
15 class WebGraphicsContext3D; | 15 class WebGraphicsContext3D; |
16 } | 16 } |
17 | 17 |
18 namespace cc { | 18 namespace cc { |
19 | 19 |
20 class ThrottledTextureUploader : public TextureUploader { | 20 class ThrottledTextureUploader : public TextureUploader { |
21 public: | 21 public: |
22 static PassOwnPtr<ThrottledTextureUploader> create(WebKit::WebGraphicsContex
t3D* context) | 22 static PassOwnPtr<ThrottledTextureUploader> create(WebKit::WebGraphicsContex
t3D* context) |
23 { | 23 { |
24 return adoptPtr(new ThrottledTextureUploader(context)); | 24 return adoptPtr(new ThrottledTextureUploader(context)); |
25 } | 25 } |
26 virtual ~ThrottledTextureUploader(); | 26 virtual ~ThrottledTextureUploader(); |
27 | 27 |
28 virtual size_t numPendingUploads() OVERRIDE; | 28 virtual size_t numBlockingUploads() OVERRIDE; |
| 29 virtual void markPendingUploadsAsNonBlocking() OVERRIDE; |
29 virtual double estimatedTexturesPerSecond() OVERRIDE; | 30 virtual double estimatedTexturesPerSecond() OVERRIDE; |
30 virtual void beginUploads() OVERRIDE; | 31 virtual void beginUploads() OVERRIDE; |
31 virtual void endUploads() OVERRIDE; | 32 virtual void endUploads() OVERRIDE; |
32 virtual void uploadTexture(CCResourceProvider*, Parameters) OVERRIDE; | 33 virtual void uploadTexture(CCResourceProvider*, Parameters) OVERRIDE; |
33 | 34 |
34 private: | 35 private: |
35 class Query { | 36 class Query { |
36 public: | 37 public: |
37 static PassOwnPtr<Query> create(WebKit::WebGraphicsContext3D* context) {
return adoptPtr(new Query(context)); } | 38 static PassOwnPtr<Query> create(WebKit::WebGraphicsContext3D* context) {
return adoptPtr(new Query(context)); } |
38 | 39 |
39 virtual ~Query(); | 40 virtual ~Query(); |
40 | 41 |
41 void begin(); | 42 void begin(); |
42 void end(size_t texturesUploaded); | 43 void end(size_t texturesUploaded); |
43 bool isPending(); | 44 bool isPending(); |
44 void wait(); | 45 void wait(); |
45 unsigned value(); | 46 unsigned value(); |
46 size_t texturesUploaded(); | 47 size_t texturesUploaded(); |
| 48 void markAsNonBlocking(); |
| 49 bool isNonBlocking(); |
47 | 50 |
48 private: | 51 private: |
49 explicit Query(WebKit::WebGraphicsContext3D*); | 52 explicit Query(WebKit::WebGraphicsContext3D*); |
50 | 53 |
51 WebKit::WebGraphicsContext3D* m_context; | 54 WebKit::WebGraphicsContext3D* m_context; |
52 unsigned m_queryId; | 55 unsigned m_queryId; |
53 unsigned m_value; | 56 unsigned m_value; |
54 bool m_hasValue; | 57 bool m_hasValue; |
55 size_t m_texturesUploaded; | 58 size_t m_texturesUploaded; |
| 59 bool m_isNonBlocking; |
56 }; | 60 }; |
57 | 61 |
58 ThrottledTextureUploader(WebKit::WebGraphicsContext3D*); | 62 ThrottledTextureUploader(WebKit::WebGraphicsContext3D*); |
59 | 63 |
60 void processQueries(); | 64 void processQueries(); |
61 | 65 |
62 WebKit::WebGraphicsContext3D* m_context; | 66 WebKit::WebGraphicsContext3D* m_context; |
63 Deque<OwnPtr<Query> > m_pendingQueries; | 67 Deque<OwnPtr<Query> > m_pendingQueries; |
64 Deque<OwnPtr<Query> > m_availableQueries; | 68 Deque<OwnPtr<Query> > m_availableQueries; |
65 std::deque<double> m_texturesPerSecondHistory; | 69 std::deque<double> m_texturesPerSecondHistory; |
66 size_t m_texturesUploaded; | 70 size_t m_texturesUploaded; |
67 size_t m_numPendingTextureUploads; | 71 size_t m_numBlockingTextureUploads; |
68 | 72 |
69 DISALLOW_COPY_AND_ASSIGN(ThrottledTextureUploader); | 73 DISALLOW_COPY_AND_ASSIGN(ThrottledTextureUploader); |
70 }; | 74 }; |
71 | 75 |
72 } | 76 } |
73 | 77 |
74 #endif | 78 #endif |
OLD | NEW |