Nicolas Capens | 80d6f17 | 2016-05-13 19:30:12 -0400 | [diff] [blame] | 1 | // 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 Hartman | 8b5b512 | 2015-03-20 13:05:34 -0700 | [diff] [blame] | 15 | #ifndef sw_FrameBufferAndroid_hpp |
| 16 | #define sw_FrameBufferAndroid_hpp |
| 17 | |
Jason Macnak | 1de497c | 2020-04-08 11:31:50 -0700 | [diff] [blame] | 18 | #include <cutils/native_handle.h> |
| 19 | |
Greg Hartman | 8b5b512 | 2015-03-20 13:05:34 -0700 | [diff] [blame] | 20 | #include "Main/FrameBuffer.hpp" |
| 21 | #include "Common/Debug.hpp" |
| 22 | |
Nicolas Capens | 9cb01cf | 2017-08-04 09:36:32 -0400 | [diff] [blame] | 23 | struct ANativeWindow; |
| 24 | struct ANativeWindowBuffer; |
Greg Hartman | 8b5b512 | 2015-03-20 13:05:34 -0700 | [diff] [blame] | 25 | |
| 26 | namespace sw |
| 27 | { |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 28 | class FrameBufferAndroid : public FrameBuffer |
| 29 | { |
| 30 | public: |
Nicolas Capens | 241f789 | 2015-12-30 23:40:45 -0500 | [diff] [blame] | 31 | FrameBufferAndroid(ANativeWindow *window, int width, int height); |
Greg Hartman | 8b5b512 | 2015-03-20 13:05:34 -0700 | [diff] [blame] | 32 | |
Nicolas Capens | 6016a14 | 2017-05-29 17:20:36 -0400 | [diff] [blame] | 33 | ~FrameBufferAndroid() override; |
Greg Hartman | 8b5b512 | 2015-03-20 13:05:34 -0700 | [diff] [blame] | 34 | |
Ben Clayton | 414b72d | 2019-08-27 10:53:37 +0100 | [diff] [blame] | 35 | void flip(sw::Surface *source) override {blit(source, nullptr, nullptr);} |
Nicolas Capens | 241f789 | 2015-12-30 23:40:45 -0500 | [diff] [blame] | 36 | void blit(sw::Surface *source, const Rect *sourceRect, const Rect *destRect) override; |
Nicolas Capens | e63db96 | 2015-12-11 17:24:40 -0500 | [diff] [blame] | 37 | |
| 38 | void *lock() override; |
Nicolas Capens | 22bc79c | 2015-11-30 13:24:24 -0500 | [diff] [blame] | 39 | void unlock() override; |
Greg Hartman | 8b5b512 | 2015-03-20 13:05:34 -0700 | [diff] [blame] | 40 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 41 | bool setSwapRectangle(int l, int t, int w, int h); |
Greg Hartman | 8b5b512 | 2015-03-20 13:05:34 -0700 | [diff] [blame] | 42 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 43 | private: |
Nicolas Capens | 241f789 | 2015-12-30 23:40:45 -0500 | [diff] [blame] | 44 | ANativeWindow *nativeWindow; |
| 45 | ANativeWindowBuffer *buffer; |
Jason Macnak | 1de497c | 2020-04-08 11:31:50 -0700 | [diff] [blame] | 46 | buffer_handle_t bufferImportedHandle; |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 47 | }; |
Greg Hartman | 8b5b512 | 2015-03-20 13:05:34 -0700 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | #endif // sw_FrameBufferAndroid |