blob: a99461e7dd77bef466f78edc07b6b69a35a1a937 [file] [log] [blame]
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001//
2// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
3// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7// Query.cpp: Implements the gl::Query class
8
9#include "libGLESv2/Query.h"
shannon.woods@transgaming.comb32e1982013-02-28 23:02:59 +000010#include "libGLESv2/renderer/QueryImpl.h"
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000011
12namespace gl
13{
Brandon Jones3b579e32014-08-08 10:54:25 -070014Query::Query(rx::QueryImpl *impl, GLuint id)
15 : RefCountObject(id),
16 mQuery(impl)
17{
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000018}
19
20Query::~Query()
21{
shannon.woods@transgaming.comb32e1982013-02-28 23:02:59 +000022 delete mQuery;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000023}
24
25void Query::begin()
26{
Shannon Woods97d65b72014-08-05 18:04:22 -040027 // TODO: Rather than keeping track of whether the query was successfully
28 // created via a boolean in the GL-level Query object, we should probably
29 // use the error system to track these failed creations at the context level,
30 // and reset the active query ID for the target to 0 upon failure.
31 mStarted = mQuery->begin();
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000032}
33
34void Query::end()
35{
shannon.woods@transgaming.comb32e1982013-02-28 23:02:59 +000036 mQuery->end();
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000037}
38
39GLuint Query::getResult()
40{
shannon.woods@transgaming.comb32e1982013-02-28 23:02:59 +000041 return mQuery->getResult();
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000042}
43
44GLboolean Query::isResultAvailable()
45{
shannon.woods@transgaming.comb32e1982013-02-28 23:02:59 +000046 return mQuery->isResultAvailable();
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000047}
48
49GLenum Query::getType() const
50{
shannon.woods@transgaming.comb32e1982013-02-28 23:02:59 +000051 return mQuery->getType();
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000052}
53
Jamie Madill45c785d2014-05-13 14:09:34 -040054bool Query::isStarted() const
55{
Shannon Woods97d65b72014-08-05 18:04:22 -040056 return mStarted;
Jamie Madill45c785d2014-05-13 14:09:34 -040057}
58
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000059}