1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
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 
16 #include "gles/device_gles.h"
17 #include "gles/gl_functions.h"
18 #include "gles/gpu_image_gles.h"
19 #include "util/log.h"
20 
RENDER_BEGIN_NAMESPACE()21 RENDER_BEGIN_NAMESPACE()
22 BASE_NS::unique_ptr<GpuImage> DeviceGLES::CreateGpuImageView(
23     const GpuImageDesc& desc, const BackendSpecificImageDesc& platformData)
24 {
25     PLUGIN_ASSERT(IsActive());
26     GpuImagePlatformDataGL data {};
27 #if RENDER_HAS_GLES_BACKEND
28     if (backendType_ == DeviceBackendType::OPENGLES) {
29         const ImageDescGLES& tmp = (const ImageDescGLES&)platformData;
30         data.type = tmp.type;
31         data.image = tmp.image;
32         data.bytesperpixel = tmp.bytesperpixel;
33         data.dataType = tmp.dataType;
34         data.format = tmp.format;
35         data.internalFormat = tmp.internalFormat;
36         data.eglImage = tmp.eglImage;
37         data.hwBuffer = tmp.platformHwBuffer;
38     }
39 #endif
40 #if RENDER_HAS_GL_BACKEND
41     if (backendType_ == DeviceBackendType::OPENGL) {
42         const ImageDescGL& tmp = (const ImageDescGL&)platformData;
43         data.type = tmp.type;
44         data.image = tmp.image;
45         data.bytesperpixel = tmp.bytesperpixel;
46         data.dataType = tmp.dataType;
47         data.format = tmp.format;
48         data.internalFormat = tmp.internalFormat;
49     }
50 #endif
51     data.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
52     return CreateGpuImageView(desc, data);
53 }
54 RENDER_END_NAMESPACE()
55