CN109375980B - Touch drawing method based on Andriod system - Google Patents
Touch drawing method based on Andriod system Download PDFInfo
- Publication number
- CN109375980B CN109375980B CN201811282265.XA CN201811282265A CN109375980B CN 109375980 B CN109375980 B CN 109375980B CN 201811282265 A CN201811282265 A CN 201811282265A CN 109375980 B CN109375980 B CN 109375980B
- Authority
- CN
- China
- Prior art keywords
- touch
- current
- canvas
- graphic
- event
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T11/00—2D [Two Dimensional] image generation
- G06T11/20—Drawing from basic elements, e.g. lines or circles
- G06T11/206—Drawing of charts or graphs
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/451—Execution arrangements for user interfaces
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Human Computer Interaction (AREA)
- General Engineering & Computer Science (AREA)
- Processing Or Creating Images (AREA)
- Controls And Circuits For Display Device (AREA)
Abstract
The invention relates to the field of software development, and provides a touch drawing method based on an Andriod system aiming at the problem of drawing delay caused by the existing touch drawing method, which comprises the following steps: when an input event is captured, touch data corresponding to the input event is collected and stored in real time, if the input event is a touch pressing event or a touch moving event, a current drawing area and a current drawing path are calculated according to the current touch data and corresponding touch data close to the current touch data, the current drawing path is drawn on a dynamic canvas, and graphic data on the dynamic canvas are copied to a graphic hardware frame buffer area to display a current graphic; if the input event is a touch lifting event, calculating a complete drawing area and a complete drawing path according to the stored touch data, drawing the complete drawing path on the static canvas, and calling a refreshing method to copy the graphic data in the static canvas to a graphic hardware frame buffer area to display the complete graphic. The method is suitable for Android equipment capable of directly operating the graphic hardware frame buffer area.
Description
Technical Field
The invention relates to the field of software development, in particular to a touch drawing method.
Background
The intelligent interactive large screen is a liquid crystal display device with an Android operating system and a touch interactive system, and human-computer interaction is realized through the touch system. The interactive large screen can be internally provided with a plug-in OPS computer (standard X86 architecture) or a cloud-end virtual desktop, so that the interactive large screen has the characteristics of Android and Windows dual operating systems. The operating systems can be switched, and corresponding software is run on each system, so that the application requirements of occasions such as education teaching and commercial conferences are met.
The most basic function of a large screen with a touch interactive system is that characters can be written and displayed on the screen directly by fingers or other objects, and an application program for realizing the functions is whiteboard software. With the popularization of the Android system, the application of intelligent interactive large-screen equipment is more and more common. Writing is taken as a core function of the intelligent interactive large screen, and the writing experience of the intelligent interactive large screen is increasingly valued by users, which comprises the response speed of writing, the fluency of handwriting and the like.
The existing drawing work mechanism based on the native Android graph drawing system is as follows: the system triggers redrawing after receiving an input event, redrawing needs to remeasure a drawing area and generate a drawing path, then the drawing path and the drawing area are handed to a surfaceFlinger to call an OpenGL library to mix and render layers to obtain a drawing graph, finally the drawing graph is copied to a hardware frame buffer area, namely a FrameBuffer, and then refreshing display is carried out when a hardware frame buffer area refreshing cycle signal of the graph arrives, for an Android graph system, the frequency of the refreshing cycle signal is usually 60Hz, namely the refreshing cycle signal is generated once every 16ms, as the drawing area and the drawing path are respectively a complete area and a complete path, refreshing of the native Android graph system is based on refreshing of the drawing path, the size of the area refreshed by the drawing path can be increased along with the increase of the writing event, so that the drawing complexity of the path is increased, the calculation amount is increased, and the mixing and rendering of the layers also take a very long event, several refreshing periods are needed to make the drawing graph reach the hardware frame buffer area, and the drawing delay reaches more than 100 ms. In addition, due to the fact that the native Android graph drawing system generates a refreshing request when an intelligent interactive large screen inputs an event every time, and the touch input frequency of the intelligent interactive large screen is high and generally ranges from 100Hz to 150Hz, scheduling of the Android graph system is blocked.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: the touch drawing method based on the Andriod system is provided to overcome the problem of drawing delay caused by the existing touch drawing method.
The invention solves the technical problems and adopts the technical scheme that:
the touch drawing method based on the Andriod system comprises the following steps:
when an input event is captured, touch data corresponding to a touch point of the input event is collected and stored in real time, wherein the input event comprises a touch pressing event, a touch moving event and a touch lifting event;
if the input event is a touch pressing event or a touch moving event, calculating a current drawing area and a current drawing path according to touch data corresponding to the current touch point and touch data corresponding to a touch point close to the current touch point, drawing the current drawing path of the current drawing area on a dynamic canvas, copying graphic data corresponding to the current drawing area on the dynamic canvas to a graphic hardware frame buffer area, and displaying a current graphic;
if the input event is a touch lifting event, calculating a complete drawing area and a complete drawing path according to all stored touch data, drawing the complete drawing path of the complete drawing area on a static canvas, and calling a refreshing method to copy graphic data corresponding to the complete drawing area in the static canvas to a graphic hardware frame buffer area to display a complete graphic.
Preferably, the step of drawing the current drawing path of the current drawing area on the dynamic canvas is to adopt an Android local layer skea graphic library or an OpenGL drawing engine to realize drawing of the graphic.
Preferably, the step of drawing the complete drawing path of the complete drawing area on the static Canvas is to adopt a native Canvas class or a native surface view class of an Android application layer to realize drawing of the graph.
Preferably, the touch point close to the current touch point includes: the touch control point is closest to the current touch control point, the touch control point is second closest to the current touch control point, and the touch control point is third closest to the current touch control point.
Preferably, a bezier curve algorithm is used to calculate the current drawing path according to the current touch data and the touch data corresponding to the touch point close to the current touch point.
Further, when there are a plurality of graphics hardware frame buffer areas, the copying of the graphics data corresponding to the current rendering area on the dynamic canvas to the graphics hardware frame buffer area is: and copying the graphic data corresponding to the current drawing area on the dynamic canvas to all graphic hardware frame buffer areas.
Preferably, the input event includes a touch down event and/or a touch move event.
Further, when the content in the static canvas is updated, the content of the static canvas is synchronously updated into the dynamic canvas.
The invention has the beneficial effects that:
the dynamic canvas and the static canvas are combined, in the drawing process, after the dynamic canvas finishes the drawing of the current drawing graph, the current drawing graph needing to be refreshed is directly submitted to a graph hardware frame buffer area, the mixing of layers is not needed, the limitation of an Android graph frame is bypassed, the current drawing graph can be mapped to a screen in real time, and the drawing delay is greatly improved; on the drawing area, the size of the drawing area is reduced from the complete drawing area to the current drawing area determined according to the current touch data and the touch points adjacent to the current touch points, so that the size of the drawing area cannot increase along with the increase of writing events, and only the current drawing graph of the current drawing area is transmitted into a graph hardware frame buffer area at each time, the drawing efficiency is greatly improved, and when the scheme is applied to an intelligent interactive large-screen terminal, the drawing delay can be reduced to about 40ms from more than 100 ms.
Drawings
FIG. 1 is a flow chart of a method according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in further detail with reference to the accompanying drawings and embodiments.
The touch drawing method based on the Andriod system comprises the following steps:
when an input event is captured, touch data corresponding to a touch point of the input event is collected and stored in real time, wherein the input event comprises a touch pressing event, a touch moving event and a touch lifting event;
if the input event is a touch pressing event or a touch moving event, calculating a current drawing area and a current drawing path according to touch data corresponding to the current touch point and touch data corresponding to a touch point close to the current touch point, drawing the current drawing path of the current drawing area on the dynamic canvas, copying graphic data corresponding to the current drawing area on the dynamic canvas to a graphic hardware frame buffer area, and displaying the current graphic.
The dynamic canvas is used for drawing the graph in real time, and the method for drawing the current drawing path of the current drawing area on the dynamic canvas is a drawing method which can adopt the dynamic canvas, and the drawing method is not limited to the Skia graph library of the local Android layer or the local OpenGL drawing engine to realize the drawing of the graph.
Because the Android system can automatically adopt a mechanism of alternately refreshing a plurality of graphic hardware frame buffer areas to display graphics, in order to ensure real-time display of the current drawn image, when the number of the graphic hardware frame buffer areas is multiple, copying graphic data corresponding to the current drawn area on the dynamic canvas to the graphic hardware frame buffer areas is as follows: and copying the graphic data corresponding to the current drawing area on the dynamic canvas to all graphic hardware frame buffer areas.
In order to ensure the continuity of the current drawing path, the touch points close to the current touch point include: the touch control point is closest to the current touch control point, the touch control point is second closest to the current touch control point, and the touch control point is third closest to the current touch control point. The touch points close to the current touch point can be obtained by searching and comparing the stored touch data. Of course, the number of the adjacent touch points may not be limited to three, and may be selected according to the requirement of the algorithm actually used for the current drawing path.
Specifically, a bezier curve algorithm may be used to calculate the current drawing path from the current touch data and the touch data corresponding to the touch point close to the current touch point.
If the input event is a touch pressing event or a touch moving event, calculating a current drawing area and a current drawing path according to touch data corresponding to the current touch point and touch data corresponding to a touch point close to the current touch point, drawing the current drawing path of the current drawing area on the dynamic canvas, copying graphic data corresponding to the current drawing area on the dynamic canvas to a graphic hardware frame buffer area, and displaying the current graphic.
The refreshing method is an Android native refreshing method.
The drawing of the complete drawing path of the complete drawing area on the static Canvas can adopt a drawing method of the static Canvas, namely, the drawing of the graph is realized by adopting a native Canvas class or a native surface View class of an Android application layer.
Since the dynamic canvas is only responsible for real-time rendering of the current graphics, the static canvas may include, but is not limited to, static rendering of the complete graphics, and may also handle other functions such as blending, erasing, moving, zooming in and out of the rendered graphics, and in order to ensure that any update of the static canvas caused by UI operations is synchronized to the dynamic canvas, when the content in the static canvas is updated, the content of the static canvas is updated to the dynamic canvas synchronously.
It should be noted that the touch drawing method can be applied to an intelligent interactive large-screen terminal, a smart phone, a tablet computer or some other intelligent devices with an Android system.
Examples
As shown in fig. 1, the touch drawing method based on Andriod system includes the following steps:
s1, applying for a dynamic canvas and a static canvas;
at which time the user's input may be awaited.
S2, when a touch down event or a touch moving event is captured, drawing a current graph by adopting a drawing method of a dynamic canvas, and copying graph data corresponding to a current drawing area on the dynamic canvas to a graph hardware frame buffer area;
the step S2 specifically includes the following steps:
s201, collecting and storing touch data corresponding to a touch point of an input event in real time, acquiring a touch point closest to a current touch point, a touch point second closest to the current touch point and a touch point third closest to the current touch point, obtaining a current drawing area according to the current touch data and the touch data corresponding to the touch point, and calculating a current drawing path by adopting a Bezier curve algorithm;
s202, the dynamic canvas calls Skia or OpenGL drawing engine to draw the current drawing path of the current drawing area on the dynamic canvas, and the graphic data corresponding to the current drawing area on the dynamic canvas is copied to a graphic hardware frame buffer area;
s203, the Android system automatically refreshes and displays the graphic data corresponding to the current area, namely displays the current graphic;
and S3, when the touch lifting event is captured, drawing the complete graph by adopting the static canvas, and refreshing and displaying the complete graph.
The step S3 includes the following steps:
s301, calculating a complete drawing area according to all stored touch data and calculating by adopting a Bezier curve algorithm to obtain a complete drawing path;
s302, calling an Android native Canvas class by the static Canvas to draw the complete drawing path to obtain a complete graph, wherein the draw method can adopt DrawPath/DrawLine and the like, and calling an Android native refreshing method to copy the complete graph to a graph hardware frame buffer area;
and S303, automatically refreshing and displaying the complete graph in the hardware frame buffer area of the graph by the Android system.
Although the drawing contents of the dynamic canvas and the static canvas are consistent, the static canvas drawing is a drawing method of Android native, the hardware frame buffer area is called to refresh the image finally, the dynamic canvas is copied to the data coverage of the hardware frame buffer area during refreshing, and a user can not feel the change of switching from the dynamic canvas to the static canvas display, can conveniently erase, undo, redo and other operations on the contact data and can display the contact data to the user in real time.
Those skilled in the art can understand that the method for drawing and copying the local drawing library and the drawing engine to the hardware frame buffer and synchronizing the drawing to the static canvas, which is provided by the embodiment of the invention, is suitable for all devices which have an Android system and can directly operate the hardware frame buffer.
Claims (5)
1. The touch drawing method based on the Andriod system is characterized by comprising the following steps of:
when an input event is captured, touch data corresponding to a touch point of the input event is collected and stored in real time, wherein the input event comprises a touch pressing event, a touch moving event and a touch lifting event;
if the input event is a touch pressing event or a touch moving event, calculating a current drawing area and a current drawing path according to touch data corresponding to the current touch point and touch data corresponding to a touch point close to the current touch point, drawing the current drawing path of the current drawing area on a dynamic canvas, copying graphic data corresponding to the current drawing area on the dynamic canvas to a graphic hardware frame buffer area, and displaying a current graphic; when the number of the graphic hardware frame buffer areas is multiple, copying the graphic data corresponding to the current drawing area on the dynamic canvas to the graphic hardware frame buffer area: copying the graphic data corresponding to the current drawing area on the dynamic canvas to all graphic hardware frame buffer areas;
if the input event is a touch lifting event, calculating a complete drawing area and a complete drawing path according to all stored touch data, drawing the complete drawing path of the complete drawing area on a static canvas, and calling a refreshing method to copy graphic data corresponding to the complete drawing area in the static canvas to a graphic hardware frame buffer area for displaying a complete graphic; when the content in the static canvas is updated, the content of the static canvas is synchronously updated into the dynamic canvas.
2. The Andriod system-based touch drawing method according to claim 1, wherein the drawing of the current drawing path of the current drawing area onto the dynamic canvas is performed by using an Android native layer Skia graphics library or an OpenGL drawing engine.
3. The Android-system-based touch drawing method as recited in claim 1, wherein the drawing of the complete drawing path of the complete drawing area onto the static Canvas is implemented by using a Canvas class or a surfaview class native to an Android application layer.
4. The Andriod system-based touch drawing method according to claim 1, wherein the touch points close to the current touch point comprise: the touch control point is closest to the current touch control point, the touch control point is second closest to the current touch control point, and the touch control point is third closest to the current touch control point.
5. The Andriod system-based touch drawing method according to claim 1, wherein a bezier curve algorithm is used to calculate a current drawing path according to touch data corresponding to a current touch point and touch data corresponding to a touch point close to the current touch point.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811282265.XA CN109375980B (en) | 2018-10-29 | 2018-10-29 | Touch drawing method based on Andriod system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811282265.XA CN109375980B (en) | 2018-10-29 | 2018-10-29 | Touch drawing method based on Andriod system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109375980A CN109375980A (en) | 2019-02-22 |
CN109375980B true CN109375980B (en) | 2021-10-15 |
Family
ID=65391017
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811282265.XA Active CN109375980B (en) | 2018-10-29 | 2018-10-29 | Touch drawing method based on Andriod system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109375980B (en) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113495665A (en) * | 2020-03-19 | 2021-10-12 | 斑马智行网络(香港)有限公司 | Image display method, image display device, electronic equipment and computer readable storage medium |
CN112433666B (en) * | 2020-12-14 | 2022-04-05 | 四川长虹电器股份有限公司 | Method for drawing curve by touch based on browser kernel |
CN112799583B (en) * | 2021-04-13 | 2021-08-24 | 北京三维天地科技股份有限公司 | Point location schematic drawing system based on android platform |
CN113986107A (en) * | 2021-10-22 | 2022-01-28 | 北京鲸鲮信息系统技术有限公司 | Touch processing method and device based on graphic display system, electronic equipment and storage medium |
CN114442845A (en) * | 2021-12-24 | 2022-05-06 | 锐捷网络股份有限公司 | Writing track rendering method and device, writing screen equipment and storage medium |
CN114489910B (en) * | 2022-02-10 | 2024-05-17 | 北京字跳网络技术有限公司 | Video conference data display method, device, equipment and medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101078982A (en) * | 2006-05-24 | 2007-11-28 | 北京壁虎科技有限公司 | Screen display method based on drawing engine |
CN104536743A (en) * | 2014-12-19 | 2015-04-22 | 中国电子科技集团公司第十五研究所 | Map plotting method and system based on Android operating system |
CN105677107A (en) * | 2016-01-11 | 2016-06-15 | 福州瑞芯微电子股份有限公司 | Method and system for optimizing screen handwriting following performance |
CN107678825A (en) * | 2017-10-16 | 2018-02-09 | 青岛海信电器股份有限公司 | A kind of rendering intent and electronic whiteboard applied to electronic whiteboard |
Family Cites Families (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8949726B2 (en) * | 2010-12-10 | 2015-02-03 | Wyse Technology L.L.C. | Methods and systems for conducting a remote desktop session via HTML that supports a 2D canvas and dynamic drawing |
US20130298140A1 (en) * | 2012-05-02 | 2013-11-07 | Motorola Mobility, Inc. | Method and Apparatus for Displaying Data from a Plurality of Concurrent Operating System Environments |
CN103034729B (en) * | 2012-12-20 | 2016-09-21 | 深圳Tcl新技术有限公司 | web page rendering system and method |
US8698824B1 (en) * | 2013-04-12 | 2014-04-15 | Google Inc. | Computing systems, devices and methods for rendering maps remote from a host application |
CN103268620A (en) * | 2013-04-28 | 2013-08-28 | 华为技术有限公司 | Graphic processing method, graphic processing device and terminal device |
CN103336816B (en) * | 2013-06-28 | 2017-02-08 | 广州市动景计算机科技有限公司 | Canvas element rendering method and device realized on Android system based on GPU (Graphic Processing Unit) |
CN105279253B (en) * | 2015-10-13 | 2018-12-14 | 上海联彤网络通讯技术有限公司 | Promote the system and method for webpage painting canvas rendering speed |
CN107818588B (en) * | 2016-09-12 | 2021-12-28 | 深圳市鸿合创新信息技术有限责任公司 | Device and method for calling Qt drawing based on JNI multithreading in Android system |
-
2018
- 2018-10-29 CN CN201811282265.XA patent/CN109375980B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101078982A (en) * | 2006-05-24 | 2007-11-28 | 北京壁虎科技有限公司 | Screen display method based on drawing engine |
CN104536743A (en) * | 2014-12-19 | 2015-04-22 | 中国电子科技集团公司第十五研究所 | Map plotting method and system based on Android operating system |
CN105677107A (en) * | 2016-01-11 | 2016-06-15 | 福州瑞芯微电子股份有限公司 | Method and system for optimizing screen handwriting following performance |
CN107678825A (en) * | 2017-10-16 | 2018-02-09 | 青岛海信电器股份有限公司 | A kind of rendering intent and electronic whiteboard applied to electronic whiteboard |
Also Published As
Publication number | Publication date |
---|---|
CN109375980A (en) | 2019-02-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109375980B (en) | Touch drawing method based on Andriod system | |
CN104461242B (en) | A kind of multi-window interface implementation method based on Android operation system | |
CN110347317B (en) | Window switching method and device, storage medium and interactive intelligent panel | |
CN110597444B (en) | Handwriting display method and device, terminal device and storage medium | |
CN111651079B (en) | Handwriting display method, device, equipment and computer storage medium | |
CN110928459B (en) | Writing operation method, device, equipment and storage medium of intelligent interactive tablet | |
CN109614178A (en) | Comment display method, device, equipment and storage medium | |
CN103455292B (en) | Business datum display processing method and device, subscriber equipment | |
KR20100108417A (en) | Method of managing applications in a multi-monitor computer system and multi-monitor computer system employing the method | |
JPS6310470B2 (en) | ||
CN114020233B (en) | Meeting whiteboard window mode writing adaptation method, system, device and medium | |
CN103425431A (en) | Mobile terminal and method for achieving multi-window operation | |
US20160378272A1 (en) | Systems and methods for providing multi-focus to applications for collaboration | |
EP2897032A1 (en) | Mobile terminal-based method for side-by-side input of information and mobile terminal | |
CN103076984A (en) | Touch screen interaction method and system | |
CN102637125A (en) | Display method and mobile terminal of grid interface | |
CN114237482A (en) | Handwriting display processing method, device, system, equipment and storage medium | |
CN103164142B (en) | The method of adjustment of a kind of screen touch point position of picture-in-picture interface and electronic equipment | |
CN112783595A (en) | Display method and device for interactive writing and electronic equipment | |
CN112462989A (en) | Operation method and device of intelligent interaction panel, intelligent interaction panel and medium | |
WO2022217433A1 (en) | Multi-terminal collaborative display update method and apparatus | |
CN112433666B (en) | Method for drawing curve by touch based on browser kernel | |
CN112001995B (en) | Rendering apparatus, method, electronic device, and readable storage medium | |
CN109960562B (en) | Information display method and device and computer readable storage medium | |
CN103853470A (en) | Data processing and displaying method, device and system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |