1// Copyright 2016 The SwiftShader Authors. All Rights Reserved. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15// Display.h: Defines the Display class, representing the abstract 16// display on which graphics are drawn. 17 18#ifndef INCLUDE_DISPLAY_H_ 19#define INCLUDE_DISPLAY_H_ 20 21#include "Surface.h" 22#include "Context.h" 23#include "Device.hpp" 24 25#include <set> 26 27namespace gl 28{ 29 struct DisplayMode 30 { 31 unsigned int width; 32 unsigned int height; 33 sw::Format format; 34 }; 35 36 class Display 37 { 38 public: 39 ~Display(); 40 41 static Display *getDisplay(NativeDisplayType displayId); 42 43 bool initialize(); 44 void terminate(); 45 46 Context *createContext(const Context *shareContext); 47 48 void destroySurface(Surface *surface); 49 void destroyContext(Context *context); 50 51 bool isInitialized() const; 52 bool isValidContext(Context *context); 53 bool isValidSurface(Surface *surface); 54 bool isValidWindow(NativeWindowType window); 55 56 GLint getMinSwapInterval(); 57 GLint getMaxSwapInterval(); 58 59 virtual Surface *getPrimarySurface(); 60 61 NativeDisplayType getNativeDisplay() const; 62 63 private: 64 Display(NativeDisplayType displayId); 65 66 DisplayMode getDisplayMode() const; 67 68 const NativeDisplayType displayId; 69 70 GLint mMaxSwapInterval; 71 GLint mMinSwapInterval; 72 73 typedef std::set<Surface*> SurfaceSet; 74 SurfaceSet mSurfaceSet; 75 76 typedef std::set<Context*> ContextSet; 77 ContextSet mContextSet; 78 }; 79} 80 81#endif // INCLUDE_DISPLAY_H_ 82