Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: cc/ThrottledTextureUploader.h

Issue 10916292: Adaptively throttle texture uploads (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix platform specific compile errors. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/TextureUploader.h ('k') | cc/ThrottledTextureUploader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <deque>
10 #include <wtf/Deque.h> 11 #include <wtf/Deque.h>
11 12
12 namespace WebKit { 13 namespace WebKit {
13 class WebGraphicsContext3D; 14 class WebGraphicsContext3D;
14 } 15 }
15 16
16 namespace cc { 17 namespace cc {
17 18
18 class ThrottledTextureUploader : public TextureUploader { 19 class ThrottledTextureUploader : public TextureUploader {
19 WTF_MAKE_NONCOPYABLE(ThrottledTextureUploader); 20 WTF_MAKE_NONCOPYABLE(ThrottledTextureUploader);
20 public: 21 public:
21 static PassOwnPtr<ThrottledTextureUploader> create(WebKit::WebGraphicsContex t3D* context) 22 static PassOwnPtr<ThrottledTextureUploader> create(WebKit::WebGraphicsContex t3D* context)
22 { 23 {
23 return adoptPtr(new ThrottledTextureUploader(context)); 24 return adoptPtr(new ThrottledTextureUploader(context));
24 } 25 }
25 static PassOwnPtr<ThrottledTextureUploader> create(WebKit::WebGraphicsContex t3D* context, size_t pendingUploadLimit) 26 static PassOwnPtr<ThrottledTextureUploader> create(WebKit::WebGraphicsContex t3D* context, size_t pendingUploadLimit)
26 { 27 {
27 return adoptPtr(new ThrottledTextureUploader(context, pendingUploadLimit )); 28 return adoptPtr(new ThrottledTextureUploader(context, pendingUploadLimit ));
28 } 29 }
29 virtual ~ThrottledTextureUploader(); 30 virtual ~ThrottledTextureUploader();
30 31
31 virtual bool isBusy() OVERRIDE; 32 virtual bool isBusy() OVERRIDE;
33 virtual double estimatedTexturesPerSecond() OVERRIDE;
32 virtual void beginUploads() OVERRIDE; 34 virtual void beginUploads() OVERRIDE;
33 virtual void endUploads() OVERRIDE; 35 virtual void endUploads() OVERRIDE;
34 virtual void uploadTexture(CCResourceProvider*, Parameters) OVERRIDE; 36 virtual void uploadTexture(CCResourceProvider*, Parameters) OVERRIDE;
35 37
36 private: 38 private:
37 class Query { 39 class Query {
38 public: 40 public:
39 static PassOwnPtr<Query> create(WebKit::WebGraphicsContext3D* context) { return adoptPtr(new Query(context)); } 41 static PassOwnPtr<Query> create(WebKit::WebGraphicsContext3D* context) { return adoptPtr(new Query(context)); }
40 42
41 virtual ~Query(); 43 virtual ~Query();
42 44
43 void begin(); 45 void begin();
44 void end(); 46 void end(double texturesUploaded);
45 bool isPending(); 47 bool isPending();
46 void wait(); 48 void wait();
49 unsigned value();
50 double texturesUploaded();
47 51
48 private: 52 private:
49 explicit Query(WebKit::WebGraphicsContext3D*); 53 explicit Query(WebKit::WebGraphicsContext3D*);
50 54
51 WebKit::WebGraphicsContext3D* m_context; 55 WebKit::WebGraphicsContext3D* m_context;
52 unsigned m_queryId; 56 unsigned m_queryId;
57 unsigned m_value;
58 bool m_hasValue;
59 double m_texturesUploaded;
53 }; 60 };
54 61
55 ThrottledTextureUploader(WebKit::WebGraphicsContext3D*); 62 ThrottledTextureUploader(WebKit::WebGraphicsContext3D*);
56 ThrottledTextureUploader(WebKit::WebGraphicsContext3D*, size_t pendingUpload Limit); 63 ThrottledTextureUploader(WebKit::WebGraphicsContext3D*, size_t pendingUpload Limit);
57 64
58 void processQueries(); 65 void processQueries();
59 66
60 WebKit::WebGraphicsContext3D* m_context; 67 WebKit::WebGraphicsContext3D* m_context;
61 size_t m_maxPendingQueries; 68 size_t m_maxPendingQueries;
62 Deque<OwnPtr<Query> > m_pendingQueries; 69 Deque<OwnPtr<Query> > m_pendingQueries;
63 Deque<OwnPtr<Query> > m_availableQueries; 70 Deque<OwnPtr<Query> > m_availableQueries;
71 std::deque<double> m_texturesPerSecondHistory;
72 double m_texturesUploaded;
64 }; 73 };
65 74
66 } 75 }
67 76
68 #endif 77 #endif
OLDNEW
« no previous file with comments | « cc/TextureUploader.h ('k') | cc/ThrottledTextureUploader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698