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 <native_image/native_image.h> 21 #include <sys/mman.h> 22 #include <mutex> 23 24 class OHNativeRender { 25 public: 26 OHNativeRender() = default; 27 ~OHNativeRender(); 28 29 bool SetSurfaceWidthAndHeight(OH_NativeImage* image, uint64_t surfaceId, uint64_t width, uint64_t height); 30 void RenderFrame(); 31 32 private: 33 void DrawGradient(uint32_t* pixel, uint64_t width, uint64_t height); 34 35 OHNativeWindow* nativeWindow_ = nullptr; 36 std::mutex mutex_; 37 uint64_t width_ = 0; 38 uint64_t height_ = 0; 39 }; 40 #endif // NATIVE_IMAGE_NATIVE_RENDER_H 41