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

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLTimerQueryEXT.h

Issue 2341043002: webgl: Replace query task observer with a posted task (Closed)
Patch Set: Make sure queries finish Created 4 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
OLDNEW
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 WebGLTimerQueryEXT_h 5 #ifndef WebGLTimerQueryEXT_h
6 #define WebGLTimerQueryEXT_h 6 #define WebGLTimerQueryEXT_h
7 7
8 #include "modules/webgl/WebGLContextObject.h" 8 #include "modules/webgl/WebGLContextObject.h"
9 9
10 #include "public/platform/WebThread.h" 10 #include "wtf/WeakPtr.h"
11 11
12 namespace gpu { 12 namespace gpu {
13 namespace gles2 { 13 namespace gles2 {
14 class GLES2Interface; 14 class GLES2Interface;
15 } 15 }
16 } 16 }
17 17
18 namespace blink { 18 namespace blink {
19 19
20 class WebGLTimerQueryEXT : public WebGLContextObject, public WebThread::TaskObse rver { 20 class WebTaskRunner;
21
22 class WebGLTimerQueryEXT : public WebGLContextObject {
21 DEFINE_WRAPPERTYPEINFO(); 23 DEFINE_WRAPPERTYPEINFO();
22 24
23 public: 25 public:
24 static WebGLTimerQueryEXT* create(WebGLRenderingContextBase*); 26 static WebGLTimerQueryEXT* create(WebGLRenderingContextBase*);
25 ~WebGLTimerQueryEXT() override; 27 ~WebGLTimerQueryEXT() override;
26 28
27 void setTarget(GLenum target) { m_target = target; } 29 void setTarget(GLenum target) { m_target = target; }
28 30
29 GLuint object() const { return m_queryId; } 31 GLuint object() const { return m_queryId; }
30 bool hasTarget() const { return m_target != 0; } 32 bool hasTarget() const { return m_target != 0; }
31 GLenum target() const { return m_target; } 33 GLenum target() const { return m_target; }
32 34
33 void resetCachedResult(); 35 void resetCachedResult();
34 void updateCachedResult(gpu::gles2::GLES2Interface*); 36 void updateCachedResult(gpu::gles2::GLES2Interface*);
35 37
36 bool isQueryResultAvailable(); 38 bool isQueryResultAvailable();
37 GLuint64 getQueryResult(); 39 GLuint64 getQueryResult();
38 40
39 protected: 41 protected:
40 WebGLTimerQueryEXT(WebGLRenderingContextBase*); 42 WebGLTimerQueryEXT(WebGLRenderingContextBase*);
41 43
42 private: 44 private:
43 bool hasObject() const override { return m_queryId != 0; } 45 bool hasObject() const override { return m_queryId != 0; }
44 void deleteObjectImpl(gpu::gles2::GLES2Interface*) override; 46 void deleteObjectImpl(gpu::gles2::GLES2Interface*) override;
45 47
46 void registerTaskObserver(); 48 void scheduleAllowAvailabilityUpdate();
47 void unregisterTaskObserver(); 49 void allowAvailabilityUpdate();
48
49 // TaskObserver implementation.
50 void didProcessTask() override;
51 void willProcessTask() override { }
52 50
53 GLenum m_target; 51 GLenum m_target;
54 GLuint m_queryId; 52 GLuint m_queryId;
55 53
56 bool m_taskObserverRegistered;
57 bool m_canUpdateAvailability; 54 bool m_canUpdateAvailability;
58 bool m_queryResultAvailable; 55 bool m_queryResultAvailable;
59 GLuint64 m_queryResult; 56 GLuint64 m_queryResult;
57
58 std::unique_ptr<WebTaskRunner> m_taskRunner;
59 WTF::WeakPtrFactory<WebGLTimerQueryEXT> m_weakFactory;
60 }; 60 };
61 61
62 } // namespace blink 62 } // namespace blink
63 63
64 #endif // WebGLTimerQueryEXT_h 64 #endif // WebGLTimerQueryEXT_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698