2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2013-08-07 01:23:46 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
#ifndef WEBGL_QUERY_H_
|
|
|
|
#define WEBGL_QUERY_H_
|
2013-08-07 01:23:46 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
#include "WebGLObjectModel.h"
|
2015-12-19 01:05:42 +03:00
|
|
|
#include "nsThreadUtils.h"
|
2013-08-07 01:23:46 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2018-02-21 04:34:25 +03:00
|
|
|
namespace webgl {
|
|
|
|
class AvailabilityRunnable;
|
|
|
|
} // namespace webgl
|
2013-08-07 01:23:46 +04:00
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
class WebGLQuery final : public WebGLContextBoundObject {
|
2018-02-21 04:34:25 +03:00
|
|
|
friend class webgl::AvailabilityRunnable;
|
2020-01-09 01:19:16 +03:00
|
|
|
|
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(WebGLQuery, override)
|
2013-08-07 01:23:46 +04:00
|
|
|
|
2016-10-04 04:33:52 +03:00
|
|
|
public:
|
|
|
|
const GLuint mGLName;
|
2013-08-07 01:23:46 +04:00
|
|
|
|
2018-02-21 04:34:25 +03:00
|
|
|
private:
|
|
|
|
GLenum mTarget;
|
2020-01-09 01:19:16 +03:00
|
|
|
RefPtr<WebGLQuery>* mActiveSlot;
|
2013-08-07 01:23:46 +04:00
|
|
|
|
2016-11-08 06:38:48 +03:00
|
|
|
bool mCanBeAvailable = false; // Track whether the event loop has spun
|
2013-08-07 01:23:46 +04:00
|
|
|
|
2016-10-04 04:33:52 +03:00
|
|
|
////
|
2018-11-30 13:46:48 +03:00
|
|
|
public:
|
2016-11-08 06:38:48 +03:00
|
|
|
GLenum Target() const { return mTarget; }
|
|
|
|
bool IsActive() const { return bool(mActiveSlot); }
|
2013-08-07 01:23:46 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
////
|
2013-08-07 01:23:46 +04:00
|
|
|
|
2014-06-26 17:30:49 +04:00
|
|
|
explicit WebGLQuery(WebGLContext* webgl);
|
2013-08-07 01:23:46 +04:00
|
|
|
|
2016-10-04 04:33:52 +03:00
|
|
|
private:
|
2020-01-09 01:19:16 +03:00
|
|
|
~WebGLQuery() override;
|
2016-10-04 04:33:52 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
public:
|
|
|
|
////
|
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
void BeginQuery(GLenum target, RefPtr<WebGLQuery>& slot);
|
2016-10-04 04:33:52 +03:00
|
|
|
void EndQuery();
|
2020-01-09 01:19:16 +03:00
|
|
|
Maybe<double> GetQueryParameter(GLenum pname) const;
|
|
|
|
void QueryCounter();
|
2013-08-07 01:23:46 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
#endif // WEBGL_QUERY_H_
|