1 /* 2 * Copyright (c) 2021 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 #ifndef INTERFACES_INNERKITS_SURFACE_SURFACE_BUFFER_H 17 #define INTERFACES_INNERKITS_SURFACE_SURFACE_BUFFER_H 18 19 #include <functional> 20 21 #include <refbase.h> 22 23 #include "buffer_handle_utils.h" 24 #include "surface_type.h" 25 #include "egl_data.h" 26 27 namespace OHOS { 28 class SurfaceBuffer : public RefBase { 29 public: 30 virtual BufferHandle *GetBufferHandle() const = 0; 31 virtual int32_t GetWidth() const = 0; 32 virtual int32_t GetHeight() const = 0; 33 virtual int32_t GetStride() const = 0; 34 virtual int32_t GetSurfaceBufferWidth() const = 0; 35 virtual int32_t GetSurfaceBufferHeight() const = 0; 36 virtual SurfaceColorGamut GetSurfaceBufferColorGamut() const = 0; 37 virtual GSError SetSurfaceBufferWidth(int32_t width) = 0; 38 virtual GSError SetSurfaceBufferHeight(int32_t height) = 0; 39 virtual GSError SetSurfaceBufferColorGamut(SurfaceColorGamut colorGamut) = 0; 40 virtual int32_t GetFormat() const = 0; 41 virtual int64_t GetUsage() const = 0; 42 virtual uint64_t GetPhyAddr() const = 0; 43 virtual int32_t GetKey() const = 0; 44 virtual void *GetVirAddr() const = 0; 45 virtual int GetFileDescriptor() const = 0; 46 virtual uint32_t GetSize() const = 0; 47 virtual GSError SetInt32(uint32_t key, int32_t value) = 0; 48 virtual GSError GetInt32(uint32_t key, int32_t &value) = 0; 49 virtual GSError SetInt64(uint32_t key, int64_t value) = 0; 50 virtual GSError GetInt64(uint32_t key, int64_t &value) = 0; 51 virtual sptr<EglData> GetEglData() const = 0; 52 53 // support ipc data 54 virtual GSError ExtraGet(std::string key, int32_t &value) const = 0; 55 virtual GSError ExtraGet(std::string key, int64_t &value) const = 0; 56 virtual GSError ExtraGet(std::string key, double &value) const = 0; 57 virtual GSError ExtraGet(std::string key, std::string &value) const = 0; 58 virtual GSError ExtraSet(std::string key, int32_t value) = 0; 59 virtual GSError ExtraSet(std::string key, int64_t value) = 0; 60 virtual GSError ExtraSet(std::string key, double value) = 0; 61 virtual GSError ExtraSet(std::string key, std::string value) = 0; 62 63 protected: SurfaceBuffer()64 SurfaceBuffer(){} ~SurfaceBuffer()65 virtual ~SurfaceBuffer(){} 66 }; 67 68 using OnReleaseFunc = std::function<GSError(sptr<SurfaceBuffer> &)>; 69 } // namespace OHOS 70 71 #endif // INTERFACES_INNERKITS_SURFACE_SURFACE_BUFFER_H 72