Home | History | Annotate | Download | only in Main
      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 {
     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, destFormat, nullptr,
     22 		                             sw::Surface::pitchB(width, destFormat, true),
     23 		                             sw::Surface::sliceB(width, height, destFormat, true));
     24 	}
     25 
     26 	FrameBufferOzone::~FrameBufferOzone()
     27 	{
     28 		delete buffer;
     29 	}
     30 
     31 	void *FrameBufferOzone::lock()
     32 	{
     33 		locked = buffer->lockInternal(0, 0, 0, sw::LOCK_READWRITE, sw::PUBLIC);
     34 
     35 		return locked;
     36 	}
     37 
     38 	void FrameBufferOzone::unlock()
     39 	{
     40 		buffer->unlockInternal();
     41 
     42 		locked = nullptr;
     43 	}
     44 
     45 	void FrameBufferOzone::blit(void *source, const Rect *sourceRect, const Rect *destRect, Format sourceFormat, size_t sourceStride)
     46 	{
     47 		copy(source, sourceFormat, sourceStride);
     48 	}
     49 }
     50 
     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