1 /* 2 * Copyright (c) 2025 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 HPAE_RS_HPAE_BUFFER_H 17 #define HPAE_RS_HPAE_BUFFER_H 18 19 #include <string> 20 21 #include "common/rs_common_def.h" 22 #include "image/gpu_context.h" 23 #include "pipeline/render_thread/rs_base_render_engine.h" 24 #include "pipeline/rs_surface_handler.h" 25 26 namespace OHOS::Rosen { 27 28 constexpr uint32_t HPAE_BUFFER_SIZE = 5; 29 30 namespace DrawableV2 { 31 class RSHpaeBuffer { 32 public: 33 RSHpaeBuffer(const std::string& name, const int layerId); 34 ~RSHpaeBuffer(); 35 36 std::unique_ptr<RSRenderFrame> RequestFrame(const BufferRequestConfig& config, bool isHebc); 37 bool FlushFrame(); 38 GSError ForceDropFrame(uint64_t presentWhen = 0); 39 GetSkContext()40 std::shared_ptr<Drawing::GPUContext> GetSkContext() const 41 { 42 return grContext_; 43 } 44 45 void* GetBufferHandle(); GetSurfaceHandler()46 std::shared_ptr<RSSurfaceHandler> GetSurfaceHandler() const { return surfaceHandler_; } 47 48 private: 49 #if defined(ROSEN_OHOS) 50 bool CreateSurface(sptr<IBufferConsumerListener> listener); 51 #endif 52 53 std::shared_ptr<RSSurfaceHandler> surfaceHandler_; 54 bool surfaceCreated_ = false; 55 std::string layerName_; 56 std::shared_ptr<Drawing::GPUContext> grContext_; 57 sptr<Surface> producerSurface_; 58 BufferRequestConfig bufferConfig_; 59 void* bufferHandle_ = nullptr; 60 std::shared_ptr<RSSurfaceOhos> rsSurface_ = nullptr; 61 }; 62 63 } // DrawableV2 64 } // OHOS::Rosen 65 66 #endif