Alexis Hetu | 64ed0d7 | 2017-08-08 11:31:11 -0400 | [diff] [blame] | 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 | { |
Nicolas Capens | e5a9637 | 2017-08-11 15:14:25 -0400 | [diff] [blame] | 21 | buffer = sw::Surface::create(width, height, 1, format, nullptr, |
Nicolas Capens | a0aa5fd | 2017-12-01 13:12:32 -0500 | [diff] [blame] | 22 | sw::Surface::pitchB(width, 0, format, true), |
| 23 | sw::Surface::sliceB(width, height, 0, format, true)); |
Alexis Hetu | 64ed0d7 | 2017-08-08 11:31:11 -0400 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | FrameBufferOzone::~FrameBufferOzone() |
| 27 | { |
| 28 | delete buffer; |
| 29 | } |
| 30 | |
| 31 | void *FrameBufferOzone::lock() |
| 32 | { |
Nicolas Capens | e5a9637 | 2017-08-11 15:14:25 -0400 | [diff] [blame] | 33 | framebuffer = buffer->lockInternal(0, 0, 0, sw::LOCK_READWRITE, sw::PUBLIC); |
Alexis Hetu | 64ed0d7 | 2017-08-08 11:31:11 -0400 | [diff] [blame] | 34 | |
Nicolas Capens | e5a9637 | 2017-08-11 15:14:25 -0400 | [diff] [blame] | 35 | return framebuffer; |
Alexis Hetu | 64ed0d7 | 2017-08-08 11:31:11 -0400 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | void FrameBufferOzone::unlock() |
| 39 | { |
| 40 | buffer->unlockInternal(); |
| 41 | |
Nicolas Capens | e5a9637 | 2017-08-11 15:14:25 -0400 | [diff] [blame] | 42 | framebuffer = nullptr; |
Alexis Hetu | 64ed0d7 | 2017-08-08 11:31:11 -0400 | [diff] [blame] | 43 | } |
| 44 | |
Nicolas Capens | 241f789 | 2015-12-30 23:40:45 -0500 | [diff] [blame] | 45 | void FrameBufferOzone::blit(sw::Surface *source, const Rect *sourceRect, const Rect *destRect) |
Alexis Hetu | 64ed0d7 | 2017-08-08 11:31:11 -0400 | [diff] [blame] | 46 | { |
Nicolas Capens | 241f789 | 2015-12-30 23:40:45 -0500 | [diff] [blame] | 47 | copy(source); |
Alexis Hetu | 64ed0d7 | 2017-08-08 11:31:11 -0400 | [diff] [blame] | 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 | } |