summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/Source/modules/webgl/WebGLTimerQueryEXT.h
blob: e8c4df2b6d4c4621c6629e75e8b8993db27678ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef WebGLTimerQueryEXT_h
#define WebGLTimerQueryEXT_h

#include "modules/webgl/WebGLContextObject.h"

#include "public/platform/WebThread.h"

namespace gpu {
namespace gles2 {
class GLES2Interface;
}
}

namespace blink {

class WebGLTimerQueryEXT : public WebGLContextObject, public WebThread::TaskObserver {
    DEFINE_WRAPPERTYPEINFO();

public:
    static WebGLTimerQueryEXT* create(WebGLRenderingContextBase*);
    ~WebGLTimerQueryEXT() override;

    void setTarget(GLenum target) { m_target = target; }

    GLuint object() const { return m_queryId; }
    bool hasTarget() const { return m_target != 0; }
    GLenum target() const { return m_target; }

    void resetCachedResult();
    void updateCachedResult(gpu::gles2::GLES2Interface*);

    bool isQueryResultAvailable();
    GLuint64 getQueryResult();

protected:
    WebGLTimerQueryEXT(WebGLRenderingContextBase*);

private:
    bool hasObject() const override { return m_queryId != 0; }
    void deleteObjectImpl(WebGraphicsContext3D*) override;

    void registerTaskObserver();
    void unregisterTaskObserver();

    // TaskObserver implementation.
    void didProcessTask() override;
    void willProcessTask() override { }

    GLenum m_target;
    GLuint m_queryId;

    bool m_taskObserverRegistered;
    bool m_canUpdateAvailability;
    bool m_queryResultAvailable;
    GLuint64 m_queryResult;
};

} // namespace blink

#endif // WebGLTimerQueryEXT_h