blob: 1b76d2d0e94d1f09c03f29b596e582cc7a48944c [file] [log] [blame]
Nicolas Capens80d6f172016-05-13 19:30:12 -04001// 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
Greg Hartman8b5b5122015-03-20 13:05:34 -070015#ifndef sw_FrameBufferAndroid_hpp
16#define sw_FrameBufferAndroid_hpp
17
Jason Macnak1de497c2020-04-08 11:31:50 -070018#include <cutils/native_handle.h>
19
Greg Hartman8b5b5122015-03-20 13:05:34 -070020#include "Main/FrameBuffer.hpp"
21#include "Common/Debug.hpp"
22
Nicolas Capens9cb01cf2017-08-04 09:36:32 -040023struct ANativeWindow;
24struct ANativeWindowBuffer;
Greg Hartman8b5b5122015-03-20 13:05:34 -070025
26namespace sw
27{
Nicolas Capens0bac2852016-05-07 06:09:58 -040028 class FrameBufferAndroid : public FrameBuffer
29 {
30 public:
Nicolas Capens241f7892015-12-30 23:40:45 -050031 FrameBufferAndroid(ANativeWindow *window, int width, int height);
Greg Hartman8b5b5122015-03-20 13:05:34 -070032
Nicolas Capens6016a142017-05-29 17:20:36 -040033 ~FrameBufferAndroid() override;
Greg Hartman8b5b5122015-03-20 13:05:34 -070034
Ben Clayton414b72d2019-08-27 10:53:37 +010035 void flip(sw::Surface *source) override {blit(source, nullptr, nullptr);}
Nicolas Capens241f7892015-12-30 23:40:45 -050036 void blit(sw::Surface *source, const Rect *sourceRect, const Rect *destRect) override;
Nicolas Capense63db962015-12-11 17:24:40 -050037
38 void *lock() override;
Nicolas Capens22bc79c2015-11-30 13:24:24 -050039 void unlock() override;
Greg Hartman8b5b5122015-03-20 13:05:34 -070040
Nicolas Capens0bac2852016-05-07 06:09:58 -040041 bool setSwapRectangle(int l, int t, int w, int h);
Greg Hartman8b5b5122015-03-20 13:05:34 -070042
Nicolas Capens0bac2852016-05-07 06:09:58 -040043 private:
Nicolas Capens241f7892015-12-30 23:40:45 -050044 ANativeWindow *nativeWindow;
45 ANativeWindowBuffer *buffer;
Jason Macnak1de497c2020-04-08 11:31:50 -070046 buffer_handle_t bufferImportedHandle;
Nicolas Capens0bac2852016-05-07 06:09:58 -040047 };
Greg Hartman8b5b5122015-03-20 13:05:34 -070048}
49
50#endif // sw_FrameBufferAndroid