1 /* 2 * Copyright (C) 2019 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 #ifndef STAGEFRIGHT_CODEC2_ALLOCATOR_BLOB_H_ 18 #define STAGEFRIGHT_CODEC2_ALLOCATOR_BLOB_H_ 19 20 #include <functional> 21 22 #include <C2AllocatorGralloc.h> 23 #include <C2Buffer.h> 24 25 namespace android { 26 27 class C2AllocatorBlob : public C2Allocator { 28 public: 29 virtual id_t getId() const override; 30 31 virtual C2String getName() const override; 32 33 virtual std::shared_ptr<const Traits> getTraits() const override; 34 35 virtual c2_status_t newLinearAllocation( 36 uint32_t capacity, C2MemoryUsage usage, 37 std::shared_ptr<C2LinearAllocation> *allocation) override; 38 39 virtual c2_status_t priorLinearAllocation( 40 const C2Handle *handle, 41 std::shared_ptr<C2LinearAllocation> *allocation) override; 42 43 C2AllocatorBlob(id_t id); 44 45 virtual ~C2AllocatorBlob() override; 46 checkHandle(const C2Handle * const o)47 virtual bool checkHandle(const C2Handle* const o) const override { return CheckHandle(o); } 48 49 static bool CheckHandle(const C2Handle* const o); 50 51 // deprecated isValid(const C2Handle * const o)52 static bool isValid(const C2Handle* const o) { return CheckHandle(o); } 53 54 private: 55 std::shared_ptr<const Traits> mTraits; 56 // Design as C2AllocatorGralloc-backed to unify Gralloc implementations. 57 std::shared_ptr<C2Allocator> mC2AllocatorGralloc; 58 }; 59 60 } // namespace android 61 62 #endif // STAGEFRIGHT_CODEC2_ALLOCATOR_BLOB_H_ 63