1 /*
2  * Copyright 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <cstdint>
20 
21 #include <EGL/egl.h>
22 #include <EGL/eglext.h>
23 
24 struct ANativeWindowBuffer;
25 
26 namespace android {
27 namespace RE {
28 
29 class Image {
30 public:
31     virtual ~Image() = 0;
32     virtual bool setNativeWindowBuffer(ANativeWindowBuffer* buffer, bool isProtected,
33                                        int32_t cropWidth, int32_t cropHeight) = 0;
34 };
35 
36 namespace impl {
37 
38 class RenderEngine;
39 
40 class Image : public RE::Image {
41 public:
42     explicit Image(const RenderEngine& engine);
43     ~Image() override;
44 
45     Image(const Image&) = delete;
46     Image& operator=(const Image&) = delete;
47 
48     bool setNativeWindowBuffer(ANativeWindowBuffer* buffer, bool isProtected, int32_t cropWidth,
49                                int32_t cropHeight) override;
50 
51 private:
52     // methods internal to RenderEngine
53     friend class RenderEngine;
getEGLImage()54     EGLSurface getEGLImage() const { return mEGLImage; }
55 
56     EGLDisplay mEGLDisplay;
57     EGLImageKHR mEGLImage = EGL_NO_IMAGE_KHR;
58 };
59 
60 } // namespace impl
61 } // namespace RE
62 } // namespace android
63