180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/* 280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2012 Google Inc. 380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * 480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be 580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file. 680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef GrGLContextInfo_DEFINED 1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define GrGLContextInfo_DEFINED 1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "gl/GrGLInterface.h" 1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "GrGLCaps.h" 1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "GrGLSL.h" 1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "GrGLUtil.h" 1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkString.h" 1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/** 2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Encapsulates information about an OpenGL context including the GrGLInterface 2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * used to make GL calls, the OpenGL version, the GrGLBinding type of the 2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * context, and GLSL version. 2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass GrGLContextInfo { 2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic: 2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru /** 2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Default constructor, creates an uninitialized GrGLContextInfo 2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru GrGLContextInfo(); 3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru /** 3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Creates a GrGLContextInfo from a GrGLInterface and the currently 34363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger * bound OpenGL context accessible by the GrGLInterface. 3580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru explicit GrGLContextInfo(const GrGLInterface* interface); 3780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru /** 3980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copies a GrGLContextInfo 4080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 4180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru GrGLContextInfo(const GrGLContextInfo& ctx); 4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru ~GrGLContextInfo(); 4480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 4580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru /** 4680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copies a GrGLContextInfo 4780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 4880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru GrGLContextInfo& operator = (const GrGLContextInfo& ctx); 4980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 5080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru /** 5180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Initializes a GrGLContextInfo from a GrGLInterface and the currently 5280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * bound OpenGL context accessible by the GrGLInterface. 5380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 5480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru bool initialize(const GrGLInterface* interface); 5580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru bool isInitialized() const; 5680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 5780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru const GrGLInterface* interface() const { return fInterface; } 5880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru GrGLBinding binding() const { return fBindingInUse; } 5980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru GrGLVersion version() const { return fGLVersion; } 6080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru GrGLSLGeneration glslGeneration() const { return fGLSLGeneration; } 61363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger GrGLVendor vendor() const { return fVendor; } 6280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru const GrGLCaps& caps() const { return fGLCaps; } 6380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru GrGLCaps& caps() { return fGLCaps; } 6480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 6580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru /** 6680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Checks for extension support using a cached copy of the GL_EXTENSIONS 6780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * string. 6880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 6980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru bool hasExtension(const char* ext) const { 7080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru if (!this->isInitialized()) { 7180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru return false; 7280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 7380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru return GrGLHasExtensionFromString(ext, fExtensionString.c_str()); 7480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 7580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 7680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate: 7780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void reset(); 7880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 7980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru const GrGLInterface* fInterface; 8080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru GrGLBinding fBindingInUse; 8180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru GrGLVersion fGLVersion; 8280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru GrGLSLGeneration fGLSLGeneration; 83363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger GrGLVendor fVendor; 8480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkString fExtensionString; 8580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru GrGLCaps fGLCaps; 8680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}; 8780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 8880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 89