/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "../include/context/webgl2_rendering_context_base.h"
#include "../../common/napi/n_func_arg.h"
#include "../../common/napi/n_class.h"
#include "../include/webgl/webgl_active_info.h"
#include "../include/webgl/webgl_shader.h"
#include "../include/webgl/webgl_buffer.h"
#include "../include/webgl/webgl_framebuffer.h"
#include "../include/webgl/webgl_program.h"
#include "../include/webgl/webgl_renderbuffer.h"
#include "../include/webgl/webgl_texture.h"
#include "../include/webgl/webgl_sync.h"
#include "../include/webgl/webgl_sampler.h"
#include "../include/webgl/webgl_query.h"
#include "../include/webgl/webgl_transform_feedback.h"
#include "../include/webgl/webgl_uniform_location.h"
#include "../include/webgl/webgl_vertex_array_object.h"
#include "../include/util/log.h"
#include "../include/util/util.h"
#ifdef __cplusplus
extern "C" {
#endif
namespace OHOS {
namespace Rosen {
namespace {
const int UNIFORM_NAMES_MAX_LENGTH = 1000;
}
using namespace std;
napi_value WebGL2RenderingContextBase::DrawBuffers(napi_env env, napi_callback_info info)
{
NFuncArg funcArg(env, info);
if (!funcArg.InitArgs(NARG_CNT::ONE)) {
return nullptr;
}
LOGI("WebGL2 drawBuffers start");
napi_value array = funcArg[NARG_POS::FIRST];
bool isArray = false;
bool succ = false;
tie(succ, isArray) = NVal(env, array).IsArray();
if (!isArray || !succ) {
return nullptr;
}
uint32_t length;
napi_status lengthStatus = napi_get_array_length(env, array, &length);
if (lengthStatus != napi_ok) {
return nullptr;
}
int64_t drawBuffers[length];
uint32_t i;
for (i = 0; i < length; i++) {
napi_value element;
napi_status eleStatus = napi_get_element(env, array, i, &element);
if (eleStatus != napi_ok) {
return nullptr;
}
int64_t ele;
napi_status intStatus = napi_get_value_int64(env, element, &ele);
if (intStatus != napi_ok) {
return nullptr;
}
drawBuffers[i] = ele;
}
glDrawBuffers(static_cast<GLsizei>(length), reinterpret_cast<GLenum *>(drawBuffers));
LOGI("WebGL2 drawBuffers end");
return nullptr;
}
napi_value WebGL2RenderingContextBase::ClearBufferfv(napi_env env, napi_callback_info info)
{
NFuncArg funcArg(env, info);
if (!funcArg.InitArgs(NARG_CNT::THREE, NARG_CNT::FOUR)) {
return nullptr;
}
LOGI("WebGL2 clearBufferfv start");
bool succ = false;
int64_t buffer;
tie(succ, buffer) = NVal(env, funcArg[NARG_POS::FIRST]).ToInt64();
if (!succ) {
return nullptr;
}
LOGI("WebGL2 WebGL2RenderingContextBase::clearBufferfv buffer = %{public}u", buffer);
int64_t drawbuffer;
tie(succ, drawbuffer) = NVal(env, funcArg[NARG_POS::SECOND]).ToInt64();
if (!succ) {
return nullptr;
}
LOGI("WebGL2 WebGL2RenderingContextBase::clearBufferfv drawbuffer = %{public}u", drawbuffer);
if (funcArg[NARG_POS::THIRD] == nullptr) {
return nullptr;
}
int64_t srcOffset = 0;
if (funcArg[NARG_POS::FOURTH] != nullptr) {
tie(succ, srcOffset) = NVal(env, funcArg[NARG_POS::FOURTH]).ToInt64();
if (!succ) {
return nullptr;
}
LOGI("WebGL2 WebGL2RenderingContextBase::clearBufferfv srcOffset = %{public}u", srcOffset);
}
napi_value array = funcArg[NARG_POS::THIRD];
bool isArray = false;
tie(succ, isArray) = NVal(env, array).IsArray();
if (isArray) {
uint32_t length;
napi_status lengthStatus = napi_get_array_length(env, array, &length);
if (lengthStatus != napi_ok) {
return nullptr;
}
float clearBufferfv[length];
uint32_t i;
for (i = 0; i < length; i++) {
napi_value element;
napi_status eleStatus = napi_get_element(env, array, i, &element);
if (eleStatus != napi_ok) {
return nullptr;
}
double ele;
napi_status doubleStatus = napi_get_value_double(env, element, &ele);
if (doubleStatus != napi_ok) {
return nullptr;
}
clearBufferfv[i] = static_cast<float>(ele);
}
glClearBufferfv(static_cast<GLenum>(buffer), static_cast<GLint>(drawbuffer),
reinterpret_cast<GLfloat *>(clearBufferfv + srcOffset));
LOGI("WebGL2 clearBufferfv array end");
return nullptr;
}
bool isTypedarray = false;
tie(succ, isTypedarray) = NVal(env, array).IsTypeArray();
if (!isTypedarray || !succ) {
return nullptr;
}
void *data = nullptr;
size_t length;
napi_typedarray_type type;
tie(succ, type, data, length) = NVal(env, array).ToTypedArray();
if (!succ) {
return nullptr;
}
if (type == napi_float32_array) {
float inputFloat[INPUTFLOAT_LENGTH] = {0};
errno_t ret = memcpy_s(inputFloat, sizeof(inputFloat), reinterpret_cast<uint8_t*>(data) + srcOffset, length);
if (ret != EOK) {
LOGE("WebGL2 clearBufferfv memcpy_s failed");
return nullptr;
}
glClearBufferfv(static_cast<GLenum>(buffer), static_cast<GLint>(drawbuffer),
reinterpret_cast<GLfloat *>(inputFloat));
}
LOGI("WebGL2 clearBufferfv typeArray end");
return nullptr;
}
napi_value WebGL2RenderingContextBase::ClearBufferiv(napi_env env, napi_callback_info info)
{
NFuncArg funcArg(env, info);
if (!funcArg.InitArgs(NARG_CNT::THREE, NARG_CNT::FOUR)) {
return nullptr;
}
LOGI("WebGL2 clearBufferiv start");
bool succ = false;
int64_t buffer;
tie(succ, buffer) = NVal(env, funcArg[NARG_POS::FIRST]).ToInt64();
if (!succ) {
return nullptr;
}
LOGI("WebGL2 WebGL2RenderingContextBase::clearBufferiv buffer = %{public}u", buffer);
int64_t drawbuffer;
tie(succ, drawbuffer) = NVal(env, funcArg[NARG_POS::SECOND]).ToInt64();
if (!succ) {
return nullptr;
}
LOGI("WebGL2 WebGL2RenderingContextBase::clearBufferiv drawbuffer = %{public}u", drawbuffer);
if (funcArg[NARG_POS::THIRD] == nullptr) {
return nullptr;
}
int64_t srcOffset = 0;
if (funcArg[NARG_POS::FOURTH] != nullptr) {
tie(succ, srcOffset) = NVal(env, funcArg[NARG_POS::FOURTH]).ToInt64();
if (!succ) {
return nullptr;
}
LOGI("WebGL2 WebGL2RenderingContextBase::clearBufferiv srcOffset = %{public}u", srcOffset);
}
napi_value array = funcArg[NARG_POS::THIRD];
bool isArray = false;
tie(succ, isArray) = NVal(env, array).IsArray();
if (isArray) {
uint32_t length;
napi_status lengthStatus = napi_get_array_length(env, array, &length);
if (lengthStatus != napi_ok) {
return nullptr;
}
int64_t clearBufferiv[length];
uint32_t i;
for (i = 0; i < length; i++) {
napi_value element;
napi_status eleStatus = napi_get_element(env, array, i, &element);
if (eleStatus != napi_ok) {
return nullptr;
}
int64_t ele;
napi_status intStatus = napi_get_value_int64(env, element, &ele);
if (intStatus != napi_ok) {
return nullptr;
}
clearBufferiv[i] = ele;
}
没有合适的资源?快使用搜索试试~ 我知道了~
Window manager and compositor - 图形窗口合成器
共2000个文件
cpp:1039个
h:861个
gn:238个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 159 浏览量
2023-05-26
17:20:58
上传
评论
收藏 4.32MB ZIP 举报
温馨提示
Window manager and compositor | 图形窗口合成器。OpenHarmony 图形栈的分层说明如下( 接口层:提供图形的 Native API能力,包括:WebGL、Native Drawing的绘制能力、OpenGL 指令级的绘制能力支撑等);(框架层:分为 Render Service、Drawing、Animation、Effect、显示与内存管理五个模块)。 引擎层(包括 2D 图形库和 3D 图形引擎两个模块。2D 图形库提供 2D 图形绘制底层 API,支持图形绘制与文本绘制底层能力。3D 图形引擎能力尚在构建中)。
资源推荐
资源详情
资源评论
收起资源包目录
Window manager and compositor - 图形窗口合成器 (2000个子文件)
graphic.cfg 1KB
renderservice.cfg 332B
.clang-format 3KB
.clang-format 3KB
webgl2_rendering_context_base.cpp 175KB
webgl_rendering_context_base.cpp 153KB
rs_uni_render_visitor.cpp 132KB
rs_node_test.cpp 91KB
rs_canvas_node_test.cpp 88KB
webgl_rendering_context.cpp 83KB
webgl2_rendering_context_overloads.cpp 76KB
webgl2_rendering_context.cpp 76KB
webgl_rendering_context_overloads.cpp 65KB
rs_main_thread.cpp 65KB
rs_draw_cmd.cpp 64KB
rs_base_render_util.cpp 56KB
rs_modifier_test.cpp 55KB
egl_wrapper_entry_test.cpp 55KB
rs_marshalling_helper.cpp 54KB
swapchain_layer.cpp 53KB
buffer_queue.cpp 40KB
rs_node.cpp 37KB
rs_render_service_visitor_test.cpp 37KB
rs_surface_render_node.cpp 37KB
rs_properties.cpp 37KB
egl_wrapper_entry.cpp 37KB
rs_animation_supplement_test.cpp 35KB
vulkan_loader_unit_test.cpp 34KB
rs_surface_node_test.cpp 34KB
rs_screen_manager.cpp 34KB
rs_render_service_connection_proxy.cpp 33KB
rs_uni_render_composer_adapter.cpp 33KB
rs_composer_adapter.cpp 31KB
rs_properties_painter.cpp 30KB
rs_render_thread_visitor.cpp 29KB
rs_base_render_util_test.cpp 28KB
rs_interfaces_test.cpp 28KB
native_window_test.cpp 28KB
draw_cmd.cpp 28KB
rs_animation_test.cpp 27KB
egl_wrapper_display.cpp 27KB
rs_parallel_render_manager.cpp 27KB
rs_surface_capture_task.cpp 27KB
consumer_surface_test.cpp 26KB
rs_transition_test.cpp 26KB
path_test.cpp 25KB
rs_render_service_connection_stub.cpp 25KB
rs_render_service_connection.cpp 25KB
skia_canvas.cpp 25KB
color_picker_napi.cpp 24KB
typography_impl.cpp 24KB
rs_animation_group_test.cpp 24KB
rs_obj_abs_geometry.cpp 23KB
path_test.cpp 23KB
point_test.cpp 23KB
rs_render_thread_visitor_test.cpp 23KB
producer_surface_test.cpp 22KB
rs_node_animate_supplement_test.cpp 22KB
char_groups_test.cpp 21KB
rs_marshalling_test.cpp 21KB
canvas_test.cpp 21KB
rs_animation_test.cpp 21KB
rs_parallel_render_manager_test.cpp 21KB
rs_node_cost_manager_test.cpp 20KB
rs_border.cpp 20KB
drawing_sample_canvaskit0310.cpp 20KB
rs_parallel_sub_thread.cpp 20KB
rs_recording_canvas.cpp 20KB
drawing_sample_rs.cpp 20KB
rs_window_animation_stub_test.cpp 20KB
rs_render_service_client.cpp 20KB
hdilayerinfo_test.cpp 20KB
recording_path_test.cpp 20KB
rs_screen.cpp 20KB
rs_render_modifier.cpp 19KB
measurer_impl_test.cpp 19KB
event_queue.cpp 19KB
hdi_device_impl.cpp 19KB
buffer_queue_producer.cpp 19KB
rs_main_thread_test.cpp 19KB
rs_implicit_animator.cpp 19KB
test_picture_files.cpp 19KB
render_service_client_transition_demo.cpp 18KB
rsanimation_fuzzer.cpp 18KB
native_image_test.cpp 18KB
rect_test.cpp 18KB
rs_uni_render_visitor_test.cpp 18KB
hdi_layer.cpp 18KB
rosen_converter_txt.cpp 18KB
shader_effect_test.cpp 18KB
rs_path_animation_test.cpp 17KB
skia_rs_framework.cpp 17KB
rs_animation_timing_curve_test.cpp 17KB
rs_render_node.cpp 17KB
rs_render_service.cpp 17KB
pen_test.cpp 17KB
rs_keyframe_animation_test.cpp 17KB
rs_window_animation_controller.cpp 17KB
rs_marshalling_helper.cpp 17KB
rs_marshalling_helper.cpp 17KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
Java程序员-张凯
- 粉丝: 1w+
- 资源: 7361
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功