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