OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 WebGLQuery_h | 5 #ifndef WebGLQuery_h |
6 #define WebGLQuery_h | 6 #define WebGLQuery_h |
7 | 7 |
8 #include "modules/webgl/WebGLSharedPlatform3DObject.h" | 8 #include "modules/webgl/WebGLSharedPlatform3DObject.h" |
| 9 #include "platform/scheduler/CancellableTaskFactory.h" |
9 | 10 |
10 namespace gpu { | 11 namespace gpu { |
11 namespace gles2 { | 12 namespace gles2 { |
12 class GLES2Interface; | 13 class GLES2Interface; |
13 } | 14 } |
14 } | 15 } |
15 | 16 |
16 namespace blink { | 17 namespace blink { |
17 | 18 |
18 class WebGL2RenderingContextBase; | 19 class WebGL2RenderingContextBase; |
| 20 class WebTaskRunner; |
19 | 21 |
20 class WebGLQuery : public WebGLSharedPlatform3DObject, public WebThread::TaskObs
erver { | 22 class WebGLQuery : public WebGLSharedPlatform3DObject { |
21 DEFINE_WRAPPERTYPEINFO(); | 23 DEFINE_WRAPPERTYPEINFO(); |
22 public: | 24 public: |
23 ~WebGLQuery() override; | 25 ~WebGLQuery() override; |
24 | 26 |
25 static WebGLQuery* create(WebGL2RenderingContextBase*); | 27 static WebGLQuery* create(WebGL2RenderingContextBase*); |
26 | 28 |
27 void setTarget(GLenum); | 29 void setTarget(GLenum); |
28 bool hasTarget() const { return m_target != 0; } | 30 bool hasTarget() const { return m_target != 0; } |
29 GLenum getTarget() const { return m_target; } | 31 GLenum getTarget() const { return m_target; } |
30 | 32 |
31 void resetCachedResult(); | 33 void resetCachedResult(); |
32 void updateCachedResult(gpu::gles2::GLES2Interface*); | 34 void updateCachedResult(gpu::gles2::GLES2Interface*); |
33 | 35 |
34 bool isQueryResultAvailable(); | 36 bool isQueryResultAvailable(); |
35 GLuint getQueryResult(); | 37 GLuint getQueryResult(); |
36 | 38 |
37 protected: | 39 protected: |
38 explicit WebGLQuery(WebGL2RenderingContextBase*); | 40 explicit WebGLQuery(WebGL2RenderingContextBase*); |
39 | 41 |
40 void deleteObjectImpl(gpu::gles2::GLES2Interface*) override; | 42 void deleteObjectImpl(gpu::gles2::GLES2Interface*) override; |
41 | 43 |
42 private: | 44 private: |
43 bool isQuery() const override { return true; } | 45 bool isQuery() const override { return true; } |
44 | 46 |
45 void registerTaskObserver(); | 47 void scheduleAllowAvailabilityUpdate(); |
46 void unregisterTaskObserver(); | 48 void allowAvailabilityUpdate(); |
47 | |
48 // TaskObserver implementation. | |
49 void didProcessTask() override; | |
50 void willProcessTask() override { } | |
51 | 49 |
52 GLenum m_target; | 50 GLenum m_target; |
53 | 51 |
54 bool m_taskObserverRegistered; | |
55 bool m_canUpdateAvailability; | 52 bool m_canUpdateAvailability; |
56 bool m_queryResultAvailable; | 53 bool m_queryResultAvailable; |
57 GLuint m_queryResult; | 54 GLuint m_queryResult; |
| 55 |
| 56 std::unique_ptr<WebTaskRunner> m_taskRunner; |
| 57 std::unique_ptr<CancellableTaskFactory> m_cancellableTaskFactory; |
58 }; | 58 }; |
59 | 59 |
60 } // namespace blink | 60 } // namespace blink |
61 | 61 |
62 #endif // WebGLQuery_h | 62 #endif // WebGLQuery_h |
OLD | NEW |