Home | History | Annotate | Download | only in Main
      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 #include "FrameBufferWin.hpp"
     16 
     17 namespace sw
     18 {
     19 	FrameBufferWin::FrameBufferWin(HWND windowHandle, int width, int height, bool fullscreen, bool topLeftOrigin) : FrameBuffer(width, height, fullscreen, topLeftOrigin), windowHandle(windowHandle)
     20 	{
     21 		if(!windowed)
     22 		{
     23 			// Force fullscreen window style (no borders)
     24 			originalWindowStyle = GetWindowLong(windowHandle, GWL_STYLE);
     25 			SetWindowLong(windowHandle, GWL_STYLE, WS_POPUP);
     26 		}
     27 	}
     28 
     29 	FrameBufferWin::~FrameBufferWin()
     30 	{
     31 		if(!windowed && GetWindowLong(windowHandle, GWL_STYLE) == WS_POPUP)
     32 		{
     33 			SetWindowLong(windowHandle, GWL_STYLE, originalWindowStyle);
     34 		}
     35 	}
     36 
     37 	void FrameBufferWin::updateBounds(HWND windowOverride)
     38 	{
     39 		HWND window = windowOverride ? windowOverride : windowHandle;
     40 
     41 		if(windowed)
     42 		{
     43 			GetClientRect(window, &bounds);
     44 			ClientToScreen(window, (POINT*)&bounds);
     45 			ClientToScreen(window, (POINT*)&bounds + 1);
     46 		}
     47 		else
     48 		{
     49 			SetRect(&bounds, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
     50 		}
     51 	}
     52 }
     53 
     54 #include "FrameBufferDD.hpp"
     55 #include "FrameBufferGDI.hpp"
     56 #include "Common/Configurator.hpp"
     57 
     58 sw::FrameBufferWin *createFrameBufferWin(HWND windowHandle, int width, int height, bool fullscreen, bool topLeftOrigin)
     59 {
     60 	sw::Configurator ini("SwiftShader.ini");
     61 	int api = ini.getInteger("Testing", "FrameBufferAPI", 0);
     62 
     63 	if(api == 0 && topLeftOrigin)
     64 	{
     65 		return new sw::FrameBufferDD(windowHandle, width, height, fullscreen, topLeftOrigin);
     66 	}
     67 	else
     68 	{
     69 		return new sw::FrameBufferGDI(windowHandle, width, height, fullscreen, topLeftOrigin);
     70 	}
     71 
     72 	return 0;
     73 }
     74 
     75 sw::FrameBuffer *createFrameBuffer(void *display, HWND window, int width, int height)
     76 {
     77 	return createFrameBufferWin(window, width, height, false, false);
     78 }
     79