1 /* 2 * Copyright (C) 2017 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 #ifndef GUEST_HALS_CAMERA_GRALLOCMODULE_H_ 17 #define GUEST_HALS_CAMERA_GRALLOCMODULE_H_ 18 19 #include <hardware/gralloc.h> 20 21 #include <android/hardware/graphics/mapper/3.0/IMapper.h> 22 #include <utils/StrongPointer.h> 23 24 class GrallocModule { 25 public: getInstance()26 static GrallocModule &getInstance() { 27 static GrallocModule instance; 28 return instance; 29 } 30 31 int import(buffer_handle_t handle, buffer_handle_t* imported_handle); 32 33 int release(buffer_handle_t handle); 34 35 int lock(buffer_handle_t handle, int usage, int l, int t, int w, int h, 36 void **vaddr); 37 int lock_ycbcr(buffer_handle_t handle, int usage, int l, int t, int w, int h, 38 struct android_ycbcr *ycbcr); 39 40 int unlock(buffer_handle_t handle); 41 42 private: 43 GrallocModule(); 44 45 const gralloc_module_t *mGralloc0; 46 47 android::sp<android::hardware::graphics::mapper::V3_0::IMapper> mGralloc3; 48 }; 49 50 #endif // GUEST_HALS_CAMERA_GRALLOCMODULE_H_ 51