1 /* 2 * Copyright (c) 2024 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 NATIVE_IMAGE_NATIVE_RENDER_H 17 #define NATIVE_IMAGE_NATIVE_RENDER_H 18 #include <native_window/external_window.h> 19 #include <native_buffer/native_buffer.h> 20 #include <sys/mman.h> 21 #include <mutex> 22 23 class OHNativeRender { 24 public: 25 OHNativeRender() = default; 26 ~OHNativeRender(); 27 28 bool SetSurfaceId(uint64_t surfaceId, uint64_t width, uint64_t height); 29 void RenderFrame(); 30 31 private: 32 void DrawGradient(uint32_t* pixel, uint64_t width, uint64_t height); 33 34 OHNativeWindow* nativeWindow_ = nullptr; 35 std::mutex mutex_; 36 uint64_t width_ = 0; 37 uint64_t height_ = 0; 38 }; 39 #endif // NATIVE_IMAGE_NATIVE_RENDER_H 40