1 // Copyright 2017 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 "FrameBufferOzone.hpp"
16 
17 namespace sw
18 {
FrameBufferOzone(intptr_t display,intptr_t window,int width,int height)19 	FrameBufferOzone::FrameBufferOzone(intptr_t display, intptr_t window, int width, int height) : FrameBuffer(width, height, false, false)
20 	{
21 		buffer = sw::Surface::create(width, height, 1, format, nullptr,
22 		                             sw::Surface::pitchB(width, 0, format, true),
23 		                             sw::Surface::sliceB(width, height, 0, format, true));
24 	}
25 
~FrameBufferOzone()26 	FrameBufferOzone::~FrameBufferOzone()
27 	{
28 		delete buffer;
29 	}
30 
lock()31 	void *FrameBufferOzone::lock()
32 	{
33 		framebuffer = buffer->lockInternal(0, 0, 0, sw::LOCK_READWRITE, sw::PUBLIC);
34 
35 		return framebuffer;
36 	}
37 
unlock()38 	void FrameBufferOzone::unlock()
39 	{
40 		buffer->unlockInternal();
41 
42 		framebuffer = nullptr;
43 	}
44 
blit(sw::Surface * source,const Rect * sourceRect,const Rect * destRect)45 	void FrameBufferOzone::blit(sw::Surface *source, const Rect *sourceRect, const Rect *destRect)
46 	{
47 		copy(source);
48 	}
49 }
50 
createFrameBuffer(void * display,intptr_t window,int width,int height)51 NO_SANITIZE_FUNCTION sw::FrameBuffer *createFrameBuffer(void* display, intptr_t window, int width, int height)
52 {
53 	return new sw::FrameBufferOzone((intptr_t)display, window, width, height);
54 }
55