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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_VIDEO_RESOURCE_TEXTURE_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_VIDEO_RESOURCE_TEXTURE_H 18 19 #include "core/common/platform_res_register.h" 20 #include "core/components/video/resource/resource.h" 21 #include "core/pipeline/pipeline_base.h" 22 23 namespace OHOS::Ace { 24 25 class ACE_EXPORT Texture : public Resource { 26 DECLARE_ACE_TYPE(Texture, Resource); 27 public: 28 using RefreshListener = std::function<void()>; 29 Texture(const WeakPtr<PipelineBase> & context,ErrorCallback && onError)30 Texture(const WeakPtr<PipelineBase>& context, ErrorCallback&& onError) 31 : Resource("texture", context, std::move(onError)) {} 32 ~Texture() override; 33 34 void Create(const std::function<void(int64_t)>& onCreate); 35 void CreateTexture(const std::function<void(int64_t)>& onCreate); 36 void OnSize(int64_t textureId, int32_t textureWidth, int32_t textureHeight); 37 SetRefreshListener(RefreshListener && listener)38 void SetRefreshListener(RefreshListener&& listener) 39 { 40 onRefreshListener_ = std::move(listener); 41 } 42 43 private: 44 void OnRefresh(const std::string& param); 45 RefreshListener onRefreshListener_; 46 }; 47 48 } // namespace OHOS::Ace 49 50 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_VIDEO_RESOURCE_TEXTURE_H 51