blob: 95e0729b92584ed4874214d926dfe21095bd6804 [file] [log] [blame]
Alexis Hetu64ed0d72017-08-08 11:31:11 -04001// 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
17namespace sw
18{
19 FrameBufferOzone::FrameBufferOzone(intptr_t display, intptr_t window, int width, int height) : FrameBuffer(width, height, false, false)
20 {
Nicolas Capense5a96372017-08-11 15:14:25 -040021 buffer = sw::Surface::create(width, height, 1, format, nullptr,
Nicolas Capensa0aa5fd2017-12-01 13:12:32 -050022 sw::Surface::pitchB(width, 0, format, true),
23 sw::Surface::sliceB(width, height, 0, format, true));
Alexis Hetu64ed0d72017-08-08 11:31:11 -040024 }
25
26 FrameBufferOzone::~FrameBufferOzone()
27 {
28 delete buffer;
29 }
30
31 void *FrameBufferOzone::lock()
32 {
Nicolas Capense5a96372017-08-11 15:14:25 -040033 framebuffer = buffer->lockInternal(0, 0, 0, sw::LOCK_READWRITE, sw::PUBLIC);
Alexis Hetu64ed0d72017-08-08 11:31:11 -040034
Nicolas Capense5a96372017-08-11 15:14:25 -040035 return framebuffer;
Alexis Hetu64ed0d72017-08-08 11:31:11 -040036 }
37
38 void FrameBufferOzone::unlock()
39 {
40 buffer->unlockInternal();
41
Nicolas Capense5a96372017-08-11 15:14:25 -040042 framebuffer = nullptr;
Alexis Hetu64ed0d72017-08-08 11:31:11 -040043 }
44
Nicolas Capens241f7892015-12-30 23:40:45 -050045 void FrameBufferOzone::blit(sw::Surface *source, const Rect *sourceRect, const Rect *destRect)
Alexis Hetu64ed0d72017-08-08 11:31:11 -040046 {
Nicolas Capens241f7892015-12-30 23:40:45 -050047 copy(source);
Alexis Hetu64ed0d72017-08-08 11:31:11 -040048 }
49}
50
51NO_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}