| 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 <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 WebCore { | 17 namespace WebCore { |
| 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 estimatedPixelsPerSecond() 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 pixelsUploaded); |
| 45 bool isPending(); | 47 bool isPending(); |
| 46 void wait(); | 48 void wait(); |
| 49 unsigned value(); |
| 50 double pixelsUploaded(); |
| 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 double m_pixelsUploaded; |
| 53 }; | 58 }; |
| 54 | 59 |
| 55 ThrottledTextureUploader(WebKit::WebGraphicsContext3D*); | 60 ThrottledTextureUploader(WebKit::WebGraphicsContext3D*); |
| 56 ThrottledTextureUploader(WebKit::WebGraphicsContext3D*, size_t pendingUpload
Limit); | 61 ThrottledTextureUploader(WebKit::WebGraphicsContext3D*, size_t pendingUpload
Limit); |
| 57 | 62 |
| 58 void processQueries(); | 63 void processQueries(); |
| 59 | 64 |
| 60 WebKit::WebGraphicsContext3D* m_context; | 65 WebKit::WebGraphicsContext3D* m_context; |
| 61 size_t m_maxPendingQueries; | 66 size_t m_maxPendingQueries; |
| 62 Deque<OwnPtr<Query> > m_pendingQueries; | 67 Deque<OwnPtr<Query> > m_pendingQueries; |
| 63 Deque<OwnPtr<Query> > m_availableQueries; | 68 Deque<OwnPtr<Query> > m_availableQueries; |
| 69 std::deque<double> m_pixelsPerSecondHistory; |
| 70 double m_pixelsUploaded; |
| 64 }; | 71 }; |
| 65 | 72 |
| 66 } | 73 } |
| 67 | 74 |
| 68 #endif | 75 #endif |
| OLD | NEW |