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> AllocBuffer(const uint32_t width, 34 const uint32_t height, 35 const uint64_t cameraUsage, 36 const uint32_t cameraFormat) = 0; 37 38 // free the buffer 39 virtual RetCode FreeBuffer(std::shared_ptr<IBuffer>&) = 0; 40 41 // map the buffer 42 virtual RetCode MapBuffer(std::shared_ptr<IBuffer>&) = 0; 43 44 // unmap the buffer 45 virtual RetCode UnmapBuffer(std::shared_ptr<IBuffer>&) = 0; 46 47 // flush data from cache to memory and invalidate the data in cache 48 virtual RetCode FlushCache(std::shared_ptr<IBuffer>&) = 0; 49 50 // invalidate the cache, update cache from memory 51 virtual RetCode InvalidateCache(std::shared_ptr<IBuffer>& buffer) = 0; 52 }; 53 } // namespace OHOS::Camera 54 #endif 55