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 HOS_IBUFFER_ALLOCATOR_H 17 #define HOS_IBUFFER_ALLOCATOR_H 18 19 #include "camera.h" 20 #include "memory" 21 22 namespace OHOS::Camera { 23 class IBuffer; 24 class IBufferAllocator { 25 public: 26 IBufferAllocator() = default; 27 virtual ~IBufferAllocator() = default; 28 29 // init buffer allocator 30 virtual RetCode Init() = 0; 31 32 // allocate buffer 33 virtual std::shared_ptr<IBuffer> 34 AllocBuffer(const uint32_t width, const uint32_t height, const uint64_t cameraUsage, const uint32_t format) = 0; 35 36 // free the buffer 37 virtual RetCode FreeBuffer(std::shared_ptr<IBuffer>&) = 0; 38 39 // map the buffer 40 virtual RetCode MapBuffer(std::shared_ptr<IBuffer>&) = 0; 41 42 // unmap the buffer 43 virtual RetCode UnmapBuffer(std::shared_ptr<IBuffer>&) = 0; 44 45 // flush data from cache to memory and invalidate the data in cache 46 virtual RetCode FlushCache(std::shared_ptr<IBuffer>&) = 0; 47 48 // invalidate the cache, update cache from memory 49 virtual RetCode InvalidateCache(std::shared_ptr<IBuffer>& buffer) = 0; 50 }; 51 } // namespace OHOS::Camera 52 #endif 53