1 // 2 // Copyright 2013 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 // QueryImpl.h: Defines the abstract rx::QueryImpl class. 8 9 #ifndef LIBANGLE_RENDERER_QUERYIMPL_H_ 10 #define LIBANGLE_RENDERER_QUERYIMPL_H_ 11 12 #include "common/PackedEnums.h" 13 #include "common/angleutils.h" 14 #include "libANGLE/Error.h" 15 16 namespace gl 17 { 18 class Context; 19 } // namespace gl 20 21 namespace rx 22 { 23 class QueryImpl : angle::NonCopyable 24 { 25 public: QueryImpl(gl::QueryType type)26 explicit QueryImpl(gl::QueryType type) : mType(type) {} ~QueryImpl()27 virtual ~QueryImpl() {} 28 29 virtual void onDestroy(const gl::Context *context); 30 31 virtual angle::Result begin(const gl::Context *context) = 0; 32 virtual angle::Result end(const gl::Context *context) = 0; 33 virtual angle::Result queryCounter(const gl::Context *context) = 0; 34 virtual angle::Result getResult(const gl::Context *context, GLint *params) = 0; 35 virtual angle::Result getResult(const gl::Context *context, GLuint *params) = 0; 36 virtual angle::Result getResult(const gl::Context *context, GLint64 *params) = 0; 37 virtual angle::Result getResult(const gl::Context *context, GLuint64 *params) = 0; 38 virtual angle::Result isResultAvailable(const gl::Context *context, bool *available) = 0; 39 getType()40 gl::QueryType getType() const { return mType; } 41 42 // Convenient functions isOcclusionQuery()43 bool isOcclusionQuery() const { return isAnySamplesQuery() || isAnySamplesConservativeQuery(); } isAnySamplesQuery()44 bool isAnySamplesQuery() const { return getType() == gl::QueryType::AnySamples; } 45 isAnySamplesConservativeQuery()46 bool isAnySamplesConservativeQuery() const 47 { 48 return getType() == gl::QueryType::AnySamplesConservative; 49 } 50 51 private: 52 gl::QueryType mType; 53 }; 54 } // namespace rx 55 56 #endif // LIBANGLE_RENDERER_QUERYIMPL_H_ 57