1 /* 2 * Copyright (c) 2021-2022 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 #include "surface_reader_handler_impl.h" 17 #include "window_manager_hilog.h" 18 19 namespace OHOS { 20 namespace Rosen { 21 namespace { 22 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "SurfaceReaderHandlerImpl"}; 23 } // namespace OnImageAvalible(sptr<Media::PixelMap> pixleMap)24bool SurfaceReaderHandlerImpl::OnImageAvalible(sptr<Media::PixelMap> pixleMap) 25 { 26 std::lock_guard<std::recursive_mutex> locl(mutex_); 27 if (!flag_) { 28 flag_ = true; 29 pixleMap_ = pixleMap; 30 WLOGFI("Get an Image!"); 31 } 32 return true; 33 } 34 IsImageOk()35bool SurfaceReaderHandlerImpl::IsImageOk() 36 { 37 std::lock_guard<std::recursive_mutex> lock(mutex_); 38 return flag_; 39 } 40 ResetFlag()41void SurfaceReaderHandlerImpl::ResetFlag() 42 { 43 std::lock_guard<std::recursive_mutex> lock(mutex_); 44 if (flag_) { 45 flag_ = false; 46 } 47 } 48 GetPixelMap()49sptr<Media::PixelMap> SurfaceReaderHandlerImpl::GetPixelMap() 50 { 51 return pixleMap_; 52 } 53 } 54 }