diff options
-rw-r--r-- | drivers/gles3/rasterizer_canvas_gles3.cpp | 67 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_canvas_gles3.h | 2 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_scene_gles3.cpp | 17 | ||||
-rw-r--r-- | editor/filesystem_dock.cpp | 4 | ||||
-rw-r--r-- | editor/import/resource_importer_wav.cpp | 52 | ||||
-rw-r--r-- | main/input_default.cpp | 11 | ||||
-rw-r--r-- | modules/gdscript/gd_functions.cpp | 63 | ||||
-rw-r--r-- | modules/gdscript/gd_functions.h | 1 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 83 | ||||
-rw-r--r-- | servers/visual/rasterizer.h | 2 | ||||
-rw-r--r-- | servers/visual/visual_server_raster.cpp | 31 | ||||
-rw-r--r-- | servers/visual/visual_server_raster.h | 11 | ||||
-rw-r--r-- | servers/visual/visual_server_wrap_mt.h | 6 | ||||
-rw-r--r-- | servers/visual_server.h | 6 |
14 files changed, 293 insertions, 63 deletions
diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index 56d9f2cc47..e6ffa39197 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -941,6 +941,8 @@ void RasterizerGLES2::_canvas_item_setup_shader_params(ShaderMaterial *material, void RasterizerCanvasGLES3::_copy_texscreen(const Rect2 &p_rect) { + glDisable(GL_BLEND); + state.canvas_texscreen_used = true; //blur diffuse into effect mipmaps using separatable convolution //storage->shaders.copy.set_conditional(CopyShaderGLES3::GAUSSIAN_HORIZONTAL,true); @@ -1003,12 +1005,16 @@ void RasterizerCanvasGLES3::_copy_texscreen(const Rect2 &p_rect) { glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->fbo); //back to front glViewport(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height); + state.canvas_shader.bind(); //back to canvas + _bind_canvas_texture(state.current_tex, state.current_normal); if (state.using_texture_rect) { state.using_texture_rect = false; _set_texture_rect_mode(state.using_texture_rect, state.using_ninepatch); } + + glEnable(GL_BLEND); } void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light) { @@ -1595,6 +1601,67 @@ void RasterizerCanvasGLES3::draw_generic_textured_rect(const Rect2 &p_rect, cons glDrawArrays(GL_TRIANGLE_FAN, 0, 4); } +void RasterizerCanvasGLES3::draw_window_margins(int *black_margin, RID *black_image) { + + Vector2 window_size = OS::get_singleton()->get_window_size(); + int window_h = window_size.height; + int window_w = window_size.width; + + glBindFramebuffer(GL_FRAMEBUFFER, storage->system_fbo); + glViewport(0, 0, window_size.width, window_size.height); + canvas_begin(); + + if (black_image[MARGIN_LEFT].is_valid()) { + _bind_canvas_texture(black_image[MARGIN_LEFT], RID()); + Size2 sz(storage->texture_get_width(black_image[MARGIN_LEFT]), storage->texture_get_height(black_image[MARGIN_LEFT])); + draw_generic_textured_rect(Rect2(0, 0, black_margin[MARGIN_LEFT], window_h), Rect2(0, 0, sz.x, sz.y)); + } else if (black_margin[MARGIN_LEFT]) { + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex); + + draw_generic_textured_rect(Rect2(0, 0, black_margin[MARGIN_LEFT], window_h), Rect2(0, 0, 1, 1)); + } + + if (black_image[MARGIN_RIGHT].is_valid()) { + _bind_canvas_texture(black_image[MARGIN_RIGHT], RID()); + Size2 sz(storage->texture_get_width(black_image[MARGIN_RIGHT]), storage->texture_get_height(black_image[MARGIN_RIGHT])); + draw_generic_textured_rect(Rect2(window_w - black_margin[MARGIN_RIGHT], 0, black_margin[MARGIN_RIGHT], window_h), Rect2(0, 0, sz.x, sz.y)); + } else if (black_margin[MARGIN_RIGHT]) { + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex); + + draw_generic_textured_rect(Rect2(window_w - black_margin[MARGIN_RIGHT], 0, black_margin[MARGIN_RIGHT], window_h), Rect2(0, 0, 1, 1)); + } + + if (black_image[MARGIN_TOP].is_valid()) { + _bind_canvas_texture(black_image[MARGIN_TOP], RID()); + + Size2 sz(storage->texture_get_width(black_image[MARGIN_TOP]), storage->texture_get_height(black_image[MARGIN_TOP])); + draw_generic_textured_rect(Rect2(0, 0, window_w, black_margin[MARGIN_TOP]), Rect2(0, 0, sz.x, sz.y)); + + } else if (black_margin[MARGIN_TOP]) { + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex); + + draw_generic_textured_rect(Rect2(0, 0, window_w, black_margin[MARGIN_TOP]), Rect2(0, 0, 1, 1)); + } + + if (black_image[MARGIN_BOTTOM].is_valid()) { + + _bind_canvas_texture(black_image[MARGIN_BOTTOM], RID()); + + Size2 sz(storage->texture_get_width(black_image[MARGIN_BOTTOM]), storage->texture_get_height(black_image[MARGIN_BOTTOM])); + draw_generic_textured_rect(Rect2(0, window_h - black_margin[MARGIN_BOTTOM], window_w, black_margin[MARGIN_BOTTOM]), Rect2(0, 0, sz.x, sz.y)); + + } else if (black_margin[MARGIN_BOTTOM]) { + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex); + + draw_generic_textured_rect(Rect2(0, window_h - black_margin[MARGIN_BOTTOM], window_w, black_margin[MARGIN_BOTTOM]), Rect2(0, 0, 1, 1)); + } +} + void RasterizerCanvasGLES3::initialize() { { diff --git a/drivers/gles3/rasterizer_canvas_gles3.h b/drivers/gles3/rasterizer_canvas_gles3.h index c0af22b5e8..26003f543f 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.h +++ b/drivers/gles3/rasterizer_canvas_gles3.h @@ -138,6 +138,8 @@ public: void initialize(); void finalize(); + virtual void draw_window_margins(int *black_margin, RID *black_image); + RasterizerCanvasGLES3(); }; diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index cd74c450f5..9dd5b32f41 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -1561,7 +1561,7 @@ void RasterizerSceneGLES3::_render_geometry(RenderList::Element *e) { if (!c.normals.empty()) { glEnableVertexAttribArray(VS::ARRAY_NORMAL); - glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vector3) * vertices, c.normals.ptr()); + glBufferSubData(GL_ARRAY_BUFFER, buf_ofs, sizeof(Vector3) * vertices, c.normals.ptr()); glVertexAttribPointer(VS::ARRAY_NORMAL, 3, GL_FLOAT, false, sizeof(Vector3) * vertices, ((uint8_t *)NULL) + buf_ofs); buf_ofs += sizeof(Vector3) * vertices; @@ -1573,7 +1573,7 @@ void RasterizerSceneGLES3::_render_geometry(RenderList::Element *e) { if (!c.tangents.empty()) { glEnableVertexAttribArray(VS::ARRAY_TANGENT); - glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Plane) * vertices, c.tangents.ptr()); + glBufferSubData(GL_ARRAY_BUFFER, buf_ofs, sizeof(Plane) * vertices, c.tangents.ptr()); glVertexAttribPointer(VS::ARRAY_TANGENT, 4, GL_FLOAT, false, sizeof(Plane) * vertices, ((uint8_t *)NULL) + buf_ofs); buf_ofs += sizeof(Plane) * vertices; @@ -1585,7 +1585,7 @@ void RasterizerSceneGLES3::_render_geometry(RenderList::Element *e) { if (!c.colors.empty()) { glEnableVertexAttribArray(VS::ARRAY_COLOR); - glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Color) * vertices, c.colors.ptr()); + glBufferSubData(GL_ARRAY_BUFFER, buf_ofs, sizeof(Color) * vertices, c.colors.ptr()); glVertexAttribPointer(VS::ARRAY_COLOR, 4, GL_FLOAT, false, sizeof(Color), ((uint8_t *)NULL) + buf_ofs); buf_ofs += sizeof(Color) * vertices; @@ -1598,7 +1598,7 @@ void RasterizerSceneGLES3::_render_geometry(RenderList::Element *e) { if (!c.uvs.empty()) { glEnableVertexAttribArray(VS::ARRAY_TEX_UV); - glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vector2) * vertices, c.uvs.ptr()); + glBufferSubData(GL_ARRAY_BUFFER, buf_ofs, sizeof(Vector2) * vertices, c.uvs.ptr()); glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, false, sizeof(Vector2), ((uint8_t *)NULL) + buf_ofs); buf_ofs += sizeof(Vector2) * vertices; @@ -1610,7 +1610,7 @@ void RasterizerSceneGLES3::_render_geometry(RenderList::Element *e) { if (!c.uvs2.empty()) { glEnableVertexAttribArray(VS::ARRAY_TEX_UV2); - glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vector2) * vertices, c.uvs2.ptr()); + glBufferSubData(GL_ARRAY_BUFFER, buf_ofs, sizeof(Vector2) * vertices, c.uvs2.ptr()); glVertexAttribPointer(VS::ARRAY_TEX_UV2, 2, GL_FLOAT, false, sizeof(Vector2), ((uint8_t *)NULL) + buf_ofs); buf_ofs += sizeof(Vector2) * vertices; @@ -1620,7 +1620,7 @@ void RasterizerSceneGLES3::_render_geometry(RenderList::Element *e) { } glEnableVertexAttribArray(VS::ARRAY_VERTEX); - glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vector3) * vertices, c.vertices.ptr()); + glBufferSubData(GL_ARRAY_BUFFER, buf_ofs, sizeof(Vector3) * vertices, c.vertices.ptr()); glVertexAttribPointer(VS::ARRAY_VERTEX, 3, GL_FLOAT, false, sizeof(Vector3), ((uint8_t *)NULL) + buf_ofs); glDrawArrays(gl_primitive[c.primitive], 0, c.vertices.size()); } @@ -3051,6 +3051,11 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p } break; case VS::INSTANCE_IMMEDIATE: { + RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.getptr(inst->base); + ERR_CONTINUE(!immediate); + + _add_geometry(immediate, inst, NULL, -1, p_shadow); + } break; case VS::INSTANCE_PARTICLES: { diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 77ca1a5145..7c5cd48605 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -102,7 +102,7 @@ void FileSystemDock::_notification(int p_what) { case NOTIFICATION_RESIZED: { - bool new_mode = get_size().height < get_viewport_rect().size.height * 3 / 4; + bool new_mode = get_size().height < get_viewport_rect().size.height / 2; if (new_mode != split_mode) { @@ -589,7 +589,7 @@ void FileSystemDock::_go_to_dir(const String &p_dir) { void FileSystemDock::_preview_invalidated(const String &p_path) { - if (p_path.get_base_dir() == path && search_box->get_text() == String() && file_list_vb->is_visible_in_tree()) { + if (display_mode == DISPLAY_THUMBNAILS && p_path.get_base_dir() == path && search_box->get_text() == String() && file_list_vb->is_visible_in_tree()) { for (int i = 0; i < files->get_item_count(); i++) { diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp index 8cb712cb78..07f1f4dd9f 100644 --- a/editor/import/resource_importer_wav.cpp +++ b/editor/import/resource_importer_wav.cpp @@ -123,6 +123,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s int format_channels = 0; AudioStreamSample::LoopMode loop = AudioStreamSample::LOOP_DISABLED; + uint16_t compression_code = 1; bool format_found = false; bool data_found = false; int format_freq = 0; @@ -151,11 +152,10 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s if (chunkID[0] == 'f' && chunkID[1] == 'm' && chunkID[2] == 't' && chunkID[3] == ' ' && !format_found) { /* IS FORMAT CHUNK */ - uint16_t compression_code = file->get_16(); - //Issue: #7755 : Not a bug - usage of other formats (format codes) are unsupported in current importer version. //Consider revision for engine version 3.0 - if (compression_code != 1) { + compression_code = file->get_16(); + if (compression_code != 1 && compression_code != 3) { ERR_PRINT("Format not supported for WAVE file (not PCM). Save WAVE files as uncompressed PCM instead."); break; } @@ -210,33 +210,37 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s data.resize(frames * format_channels); - for (int i = 0; i < frames; i++) { - - for (int c = 0; c < format_channels; c++) { - - if (format_bits == 8) { - // 8 bit samples are UNSIGNED - - uint8_t s = file->get_8(); - s -= 128; - int8_t *sp = (int8_t *)&s; + if (format_bits == 8) { + for (int i = 0; i < frames * format_channels; i++) { + // 8 bit samples are UNSIGNED - data[i * format_channels + c] = float(*sp) / 128.0; + data[i] = int8_t(file->get_8() - 128) / 128.f; + } + } else if (format_bits == 32 && compression_code == 3) { + for (int i = 0; i < frames * format_channels; i++) { + //32 bit IEEE Float - } else { - //16+ bits samples are SIGNED - // if sample is > 16 bits, just read extra bytes + data[i] = file->get_float(); + } + } else if (format_bits == 16) { + for (int i = 0; i < frames * format_channels; i++) { + //16 bit SIGNED - uint32_t s = 0; - for (int b = 0; b < (format_bits >> 3); b++) { + data[i] = int16_t(file->get_16()) / 32768.f; + } + } else { + for (int i = 0; i < frames * format_channels; i++) { + //16+ bits samples are SIGNED + // if sample is > 16 bits, just read extra bytes - s |= ((uint32_t)file->get_8()) << (b * 8); - } - s <<= (32 - format_bits); - int32_t ss = s; + uint32_t s = 0; + for (int b = 0; b < (format_bits >> 3); b++) { - data[i * format_channels + c] = (ss >> 16) / 32768.0; + s |= ((uint32_t)file->get_8()) << (b * 8); } + s <<= (32 - format_bits); + + data[i] = (int32_t(s) >> 16) / 32768.f; } } diff --git a/main/input_default.cpp b/main/input_default.cpp index 3361aa0678..4e2fd6f9d4 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -453,7 +453,8 @@ void InputDefault::set_mouse_position(const Point2 &p_posf) { mouse_speed_track.update(p_posf - mouse_pos); mouse_pos = p_posf; if (custom_cursor.is_valid()) { - VisualServer::get_singleton()->cursor_set_pos(get_mouse_position()); + //removed, please insist that we implement hardware cursors + // VisualServer::get_singleton()->cursor_set_pos(get_mouse_position()); } } @@ -538,6 +539,7 @@ bool InputDefault::is_emulating_touchscreen() const { } void InputDefault::set_custom_mouse_cursor(const RES &p_cursor, const Vector2 &p_hotspot) { + /* no longer supported, leaving this for reference to anyone who might want to implement hardware cursors if (custom_cursor == p_cursor) return; @@ -545,7 +547,8 @@ void InputDefault::set_custom_mouse_cursor(const RES &p_cursor, const Vector2 &p if (p_cursor.is_null()) { set_mouse_mode(MOUSE_MODE_VISIBLE); - VisualServer::get_singleton()->cursor_set_visible(false); + //removed, please insist us to implement hardare cursors + //VisualServer::get_singleton()->cursor_set_visible(false); } else { Ref<AtlasTexture> atex = custom_cursor; Rect2 region = atex.is_valid() ? atex->get_region() : Rect2(); @@ -554,10 +557,11 @@ void InputDefault::set_custom_mouse_cursor(const RES &p_cursor, const Vector2 &p VisualServer::get_singleton()->cursor_set_texture(custom_cursor->get_rid(), p_hotspot, 0, region); VisualServer::get_singleton()->cursor_set_pos(get_mouse_position()); } + */ } void InputDefault::set_mouse_in_window(bool p_in_window) { - + /* no longer supported, leaving this for reference to anyone who might want to implement hardware cursors if (custom_cursor.is_valid()) { if (p_in_window) { @@ -568,6 +572,7 @@ void InputDefault::set_mouse_in_window(bool p_in_window) { VisualServer::get_singleton()->cursor_set_visible(false); } } + */ } // from github.com/gabomdq/SDL_GameControllerDB diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp index 8bc3b24a5e..209bdadd67 100644 --- a/modules/gdscript/gd_functions.cpp +++ b/modules/gdscript/gd_functions.cpp @@ -113,6 +113,7 @@ const char *GDFunctions::get_func_name(Function p_func) { "ColorN", "print_stack", "instance_from_id", + "len", }; return _names[p_func]; @@ -1154,6 +1155,62 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count, r_ret = ObjectDB::get_instance(id); } break; + case LEN: { + + VALIDATE_ARG_COUNT(1); + switch (p_args[0]->get_type()) { + case Variant::DICTIONARY: { + Dictionary d = *p_args[0]; + r_ret = d.size(); + } break; + case Variant::ARRAY: { + Array d = *p_args[0]; + r_ret = d.size(); + } break; + case Variant::POOL_BYTE_ARRAY: { + PoolVector<uint8_t> d = *p_args[0]; + r_ret = d.size(); + + } break; + case Variant::POOL_INT_ARRAY: { + PoolVector<int> d = *p_args[0]; + r_ret = d.size(); + } break; + case Variant::POOL_REAL_ARRAY: { + + PoolVector<real_t> d = *p_args[0]; + r_ret = d.size(); + } break; + case Variant::POOL_STRING_ARRAY: { + PoolVector<String> d = *p_args[0]; + r_ret = d.size(); + + } break; + case Variant::POOL_VECTOR2_ARRAY: { + PoolVector<Vector2> d = *p_args[0]; + r_ret = d.size(); + + } break; + case Variant::POOL_VECTOR3_ARRAY: { + + PoolVector<Vector3> d = *p_args[0]; + r_ret = d.size(); + } break; + case Variant::POOL_COLOR_ARRAY: { + + PoolVector<Color> d = *p_args[0]; + r_ret = d.size(); + } break; + default: { + r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument = 0; + r_error.expected = Variant::OBJECT; + r_ret = Variant(); + r_ret = RTR("Object can't provide a length."); + } + } + + } break; case FUNC_MAX: { ERR_FAIL(); @@ -1210,6 +1267,7 @@ bool GDFunctions::is_deterministic(Function p_func) { case TEXT_CHAR: case TEXT_STR: case COLOR8: + case LEN: // enable for debug only, otherwise not desirable - case GEN_RANGE: return true; default: @@ -1621,6 +1679,11 @@ MethodInfo GDFunctions::get_info(Function p_func) { mi.return_val.type = Variant::OBJECT; return mi; } break; + case LEN: { + MethodInfo mi("len", PropertyInfo(Variant::NIL, "var")); + mi.return_val.type = Variant::INT; + return mi; + } break; case FUNC_MAX: { diff --git a/modules/gdscript/gd_functions.h b/modules/gdscript/gd_functions.h index 4d52abaeab..93cb524118 100644 --- a/modules/gdscript/gd_functions.h +++ b/modules/gdscript/gd_functions.h @@ -105,6 +105,7 @@ public: COLORN, PRINT_STACK, INSTANCE_FROM_ID, + LEN, FUNC_MAX }; diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index e3c136a33f..ee9323ca1d 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -2028,6 +2028,89 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { } } + Ref<InputEventScreenTouch> touch_event = p_event; + if (touch_event.is_valid()) { + + Size2 pos = touch_event->get_position(); + if (touch_event->is_pressed()) { + + Control *over = _gui_find_control(pos); + if (over) { + + if (!gui.modal_stack.empty()) { + + Control *top = gui.modal_stack.back()->get(); + if (over != top && !top->is_a_parent_of(over)) { + + return; + } + } + if (over->can_process()) { + + touch_event = touch_event->xformed_by(Transform2D()); //make a copy + if (over == gui.mouse_focus) { + pos = gui.focus_inv_xform.xform(pos); + } else { + pos = over->get_global_transform_with_canvas().affine_inverse().xform(pos); + } + touch_event->set_position(pos); + _gui_call_input(over, touch_event); + } + get_tree()->set_input_as_handled(); + return; + } + } else if (gui.mouse_focus) { + + if (gui.mouse_focus->can_process()) { + + touch_event = touch_event->xformed_by(Transform2D()); //make a copy + touch_event->set_position(gui.focus_inv_xform.xform(pos)); + + _gui_call_input(gui.mouse_focus, touch_event); + } + get_tree()->set_input_as_handled(); + return; + } + } + + Ref<InputEventScreenDrag> drag_event = p_event; + if (drag_event.is_valid()) { + + Control *over = gui.mouse_focus; + if (!over) { + over = _gui_find_control(drag_event->get_position()); + } + if (over) { + + if (!gui.modal_stack.empty()) { + + Control *top = gui.modal_stack.back()->get(); + if (over != top && !top->is_a_parent_of(over)) { + + return; + } + } + if (over->can_process()) { + + Transform2D localizer = over->get_global_transform_with_canvas().affine_inverse(); + Size2 pos = localizer.xform(drag_event->get_position()); + Vector2 speed = localizer.basis_xform(drag_event->get_speed()); + Vector2 rel = localizer.basis_xform(drag_event->get_relative()); + + drag_event = drag_event->xformed_by(Transform2D()); //make a copy + + drag_event->set_speed(speed); + drag_event->set_relative(rel); + drag_event->set_position(pos); + + _gui_call_input(over, drag_event); + } + + get_tree()->set_input_as_handled(); + return; + } + } + if (mm.is_null() && mb.is_null() && p_event->is_action_type()) { if (gui.key_focus && !gui.key_focus->is_visible_in_tree()) { diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 9c264ead49..9405f6e012 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -1014,6 +1014,8 @@ public: virtual void reset_canvas() = 0; + virtual void draw_window_margins(int *p_margins, RID *p_margin_textures) = 0; + virtual ~RasterizerCanvas() {} }; diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index b5f98dd94c..cc4fe0809d 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -41,23 +41,29 @@ int VisualServerRaster::changes = 0; -/* CURSOR */ -void VisualServerRaster::cursor_set_rotation(float p_rotation, int p_cursor) { -} -void VisualServerRaster::cursor_set_texture(RID p_texture, const Point2 &p_center_offset, int p_cursor, const Rect2 &p_region) { -} -void VisualServerRaster::cursor_set_visible(bool p_visible, int p_cursor) { -} -void VisualServerRaster::cursor_set_pos(const Point2 &p_pos, int p_cursor) { -} - /* BLACK BARS */ void VisualServerRaster::black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom) { + + black_margin[MARGIN_LEFT] = p_left; + black_margin[MARGIN_TOP] = p_top; + black_margin[MARGIN_RIGHT] = p_right; + black_margin[MARGIN_BOTTOM] = p_bottom; } + void VisualServerRaster::black_bars_set_images(RID p_left, RID p_top, RID p_right, RID p_bottom) { + + black_image[MARGIN_LEFT] = p_left; + black_image[MARGIN_TOP] = p_top; + black_image[MARGIN_RIGHT] = p_right; + black_image[MARGIN_BOTTOM] = p_bottom; } +void VisualServerRaster::_draw_margins() { + + VSG::canvas_render->draw_window_margins(black_margin, black_image); +}; + /* FREE */ void VisualServerRaster::free(RID p_rid) { @@ -121,6 +127,8 @@ void VisualServerRaster::draw() { frame_drawn_callbacks.pop_front(); } + + _draw_margins(); } void VisualServerRaster::sync() { } @@ -189,6 +197,9 @@ VisualServerRaster::VisualServerRaster() { VSG::storage = VSG::rasterizer->get_storage(); VSG::canvas_render = VSG::rasterizer->get_canvas(); VSG::scene_render = VSG::rasterizer->get_scene(); + + for (int i = 0; i < 4; i++) + black_margin[i] = 0; } VisualServerRaster::~VisualServerRaster() { diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index 56e4323f7c..596dd5c10e 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -61,6 +61,9 @@ class VisualServerRaster : public VisualServer { bool draw_extra_frame; RID test_cube; + int black_margin[4]; + RID black_image[4]; + struct FrameDrawnCallbacks { ObjectID object; @@ -584,6 +587,8 @@ class VisualServerRaster : public VisualServer { #endif + void _draw_margins(); + public: _FORCE_INLINE_ static void redraw_request() { changes++; } @@ -1110,12 +1115,6 @@ public: BIND2(canvas_occluder_polygon_set_cull_mode, RID, CanvasOccluderPolygonCullMode) - /* CURSOR */ - virtual void cursor_set_rotation(float p_rotation, int p_cursor = 0); // radians - virtual void cursor_set_texture(RID p_texture, const Point2 &p_center_offset = Point2(0, 0), int p_cursor = 0, const Rect2 &p_region = Rect2()); - virtual void cursor_set_visible(bool p_visible, int p_cursor = 0); - virtual void cursor_set_pos(const Point2 &p_pos, int p_cursor = 0); - /* BLACK BARS */ virtual void black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom); diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index 6c98082b98..20223f9651 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -538,12 +538,6 @@ public: FUNC2(canvas_occluder_polygon_set_cull_mode, RID, CanvasOccluderPolygonCullMode) - /* CURSOR */ - FUNC2(cursor_set_rotation, float, int) // radians - FUNC4(cursor_set_texture, RID, const Point2 &, int, const Rect2 &) - FUNC2(cursor_set_visible, bool, int) - FUNC2(cursor_set_pos, const Point2 &, int) - /* BLACK BARS */ FUNC4(black_bars_set_margins, int, int, int, int) diff --git a/servers/visual_server.h b/servers/visual_server.h index e017bd10fc..95a03c1836 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -875,12 +875,6 @@ public: }; virtual void canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon, CanvasOccluderPolygonCullMode p_mode) = 0; - /* CURSOR */ - virtual void cursor_set_rotation(float p_rotation, int p_cursor = 0) = 0; // radians - virtual void cursor_set_texture(RID p_texture, const Point2 &p_center_offset = Point2(0, 0), int p_cursor = 0, const Rect2 &p_region = Rect2()) = 0; - virtual void cursor_set_visible(bool p_visible, int p_cursor = 0) = 0; - virtual void cursor_set_pos(const Point2 &p_pos, int p_cursor = 0) = 0; - /* BLACK BARS */ virtual void black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom) = 0; |