Specific embodiment
The present invention will be described in more detail below with reference to accompanying drawings.Although showing the preferred embodiment of the present invention in attached drawing,
However, it is to be appreciated that may be realized in various forms the present invention and should not be limited by the embodiments set forth herein.On the contrary, providing
These embodiments are and the scope of the present disclosure completely can be communicated to ability to keep the disclosure more thorough and complete
The technical staff in domain.
Fig. 1 shows the multizone graphic plotting side according to an embodiment of the invention for intelligent operating system
Method.
The intelligent operating system environment of the present embodiment is Android, supports Open GL.Realize that step can generally divide
For two parts, difference java section and the part Native.Wherein, java section is realized by Java language program, is run on
Android virtual machine;The part Native passes through C/C++ language and realizes, runs on local server.
There are two main features for Open GL tool:
1, it is the software interface unrelated with hardware, can be transplanted between different platforms;
2, it can work in client/server system, that is, there is network function.
The multizone pattern drawing method for intelligent operating system of the present embodiment may comprise steps of:
1) multiple rendering threads that the end Java creates and multiple rendering engine examples that the end Native creates are bound.
Multiple rendering threads can be created simultaneously at the end Java, correspondingly, provide multiple rendering thread rings for the end Native
Border, and generate multiple context environmentals.Multiple render view examples are created at the end Java.
Render view is substantially the controller for the rendering at the end the Java control end Native.Render view class can be with
Including surface view (GLSurfaceView) example and texture view (GLTexureView) example, they are mentioned for the end Native
For rendering thread context.
The end Java generates the context environmental for rendering figure using the library Open GL by Open GL bank interface.
Open GL context environmental, i.e. GLContext, for storing all status informations of Open GL drawing.It is real
The default frame buffer (framebuffer) that rendering order is drawn is represented on border, GLContext is destroyed, and Open GL is not also multiple
In the presence of.
Multiple threads are created, that is, generate multiple context environmentals for Open GL, and a thread can only possess one
Context, correspondingly, a context environmental can only belong to a thread, cannot be shared simultaneously by different threads.
At the end Java, multiple rendering threads of creation are independently of the thread except main thread, this is to guarantee rendering
It can not be influenced by service logic thread.
At the end Native, rendering engine example is created based on multiple rendering thread contexts that the end Java is created.Meanwhile it is logical
Cross the rendering engine example initialization Open GL rendering contexts.
Initializing Open GL rendering contexts is mainly the important attribute that Open GL window is arranged, including pixel format eases up
Punch die formula, color digit and depth digit etc..
Open GL provides two kinds of color modes: RGB (RGBA) mode and color index mode.Own under RGBA mode
The definition of color is indicated with tri- values of RGB, sometimes also plus the Alpha value for indicating transparency.It is every under color index mode
The color of a pixel is indicated with some color index value in color index table.
Open GL can provide Double buffer and carry out drawing image.I.e. simultaneously, backstage caches the image in platform caching before display
Draw the 2nd width image.After completing from the background, the image in the caching of backstage is just shown.Foreground caching original at this time
Start to draw the 3rd width image, loop back and forth like this, to increase the output speed of image.
Correspond to one piece of region of screen by each rendering engine example that the end Native is created.
Rendering engine example is actually accomplished all figure rendering work, i.e., the initialization of completion Open GL rendering contexts,
Texture generation, changes in coordinates, color setting, figure rendering etc..
The rendering engine example initializes Open GL rendering contexts by Open GL bank interface.
Multiple rendering threads that the end Java creates and multiple rendering engine examples that the end Native creates are bound.?
In one illustrative embodiments, by by the multiple rendering engine example merging thread private data (TSD) come carry out with
The binding of the multiple rendering thread.
It is well known that under multi-thread environment, due to data space be it is shared, global variable is also all threads
It is common.One global variable, all threads can use it, change its value, therefore one of thread becomes the overall situation
The modification of amount will affect the access of another thread.Thus it is necessary to provide the overall situations that thread is privately owned in application programming
Variable uses the thread related data structures of address of variable of the same name and different.Surface seems it as global variable, and institute is wired
Journey can use it, and its value individually stores in each thread.Such data structure is referred to as thread
Private data.
Before distributing thread private data, need to create key (key) associated with thread private data, and be arranged
The key value of thread private data.Although the key of thread private data TSD be between the multiple threads it is shared, for every
A thread key value can be different.
At the end Native, rendering engine is externally singleton pattern, but when carrying out multizone graphic plotting, is actually needed
Wanting it is many cases.The many cases mould based on thread is realized by singleton pattern combination thread private data technology in this example
Formula, i.e. thread are different, and the example got by singleton pattern is also different, that is, the example got is corresponding with thread.
Specifically, multiple rendering threads can be created at the end Java, thread private data can be shared between multiple threads
The key of TSD, that is to say, that the access right of thread private data is shared in multiple rendering cross-threads.At the end Native, each
Rendering thread provided by rendering thread context in created rendering engine example respectively, by each rendering engine example merging with
In the TSD of its relevant rendering thread.That is, the key value of the thread private data in each rendering thread indicates it
Associated rendering engine.The binding for realizing rendering thread and rendering engine in this way, the management for rendering example are logical
The rendering thread bound therewith is crossed to complete, and it is also only visible to the thread bound therewith to render example.
The advantages of this mode is that the end Native is designed according to the design pattern of singleton, is eliminated to more
The management of a example.Traditional singleton design is current class externally only one example, is in general externally only connect by one
Mouth provides the example.And by introducing TSD technology, although still using the design pattern of singleton, i.e., externally also only provides one and connect
Mouthful example is obtained, but the example got for the same thread is always identical, and what different threads was got is not
Same example.I.e. in the thread, any one place all gets identical example by same interface.In this side
Under formula, in the same thread, the management to multiple examples is eliminated.
2) one or more figure rendering tasks that Java termination receives are submitted to respectively in different rendering threads, and
And one or more of figure rendering tasks are submitted to the end Native based on corresponding rendering thread.
When Java termination receives multiple figure rendering tasks, different figure rendering tasks is submitted to different renderings
In thread, and the end Native is submitted to based on respective rendering thread.
3) wash with watercolours with rendering thread binding corresponding to one or more of figure rendering tasks is obtained at the end Native
Engine instance is contaminated to carry out figure rendering.
Natvie end group obtains and the rendering thread respectively in the corresponding thread private data of the figure rendering task
The rendering engine example of binding carries out figure rendering.
Rendering engine example carries out figure rendering by Open GL order.
Figure rendering generally includes following several stages:
A) some geometric units such as geometric object, such as point, line, triangle are specified.
B) vertex processing operation.Data received by this stage are the attributive character on each vertex, and output is then
Transformed vertex data.
C) pel assembles.After the processing of vertex, whole attributes on vertex have all been determined, in this stage vertex meeting
Pel is assembled into according to pel rule.
D) pel is handled, and is mainly cut and is disappeared sunken.
E) rasterizing operates.The primitive data passed over by pel processing stage will be broken down into smaller at this stage
Unit and corresponding frame buffer zone each pixel, these units are referred to as piece member.One piece member may comprising the window left side,
The attributes such as depth, color, texture coordinate.
F) piece member is handled.It is managed including upper texture, i.e., corresponding color in texture memory is obtained by texture coordinate;Mist
Change, color is modified to current view point position by piece member distance;Color summarizes: by texture, the color of main definition, the face of atomization
Color, the color that the photostage of secondary color calculates gather.
G) operation of piece member one by one.Including pixel ownership, shearing, Alpha, stencil test, depth test, mixing
Deng these operations finally will affect it in the color value of frame buffer zone.
H) frame buffer operation.After figure rendering is completed, rendering engine is exchanged rendering result by Open GL interface
To display buffer, display is completed.Since each rendering engine example corresponds to one piece of region of screen, the knot of rendering
Fruit will directly display corresponding screen area.
4) rendering that the rendering result of one or more of figure rendering tasks is respectively displayed on and renders is drawn
It holds up in screen area corresponding to example.
Since different rendering engine examples corresponds to the different zones of screen, executed by different rendering engine examples
Figure rendering task rendering result can simultaneously be shown in the different zones of screen.It is thus achieved that intelligent operation
The graphic plotting of the multizone of system.
In the exemplary embodiment, which can further wrap
Include: after the completion of figure rendering task, rendering state is pulled back to the end Java by the end Native.
When the rendering engine at the end Native terminates to render, the rendering that rendering state can be returned to the end Java by rendering engine is regarded
Figure.I.e. the rendering of the notice end Java is completed or renders failure.
The advantages of multizone pattern drawing method for intelligent operating system of the present embodiment, is:
(1) figure rendering task is executed by the rendering engine example at the end Native, therefore is not limited by memory.
(2) rendering thread is not influenced independently of main thread by service logic thread;
(3) it can be rendered simultaneously in the multiple regions of screen simultaneously;
(4) many cases mode based on thread is realized by the singleton pattern of rendering engine+thread private data technology.
According to another embodiment of the present invention, a kind of multizone graphic plotting dress for intelligent operating system is provided
It sets.The apparatus may include: multiple rendering engines of multiple rendering threads and the creation of the end Native for creating the end Java
The unit that example is bound;One or more figure rendering tasks for receiving Java termination are submitted to different respectively
It renders in thread, and one or more of figure rendering tasks is submitted to the end Native based on corresponding rendering thread
Unit;For obtaining the wash with watercolours with rendering thread binding corresponding to one or more of figure rendering tasks at the end Native
Engine instance is contaminated to carry out the unit of figure rendering;And for by the rendering result of one or more of figure rendering tasks
Unit in screen area corresponding to the rendering engine example for being respectively displayed on and being rendered.
In the exemplary embodiment, by by the multiple rendering engine example be placed in thread private data come carry out with
The binding of the multiple rendering thread.
In the exemplary embodiment, Natvie end group is in the corresponding thread private data difference of the figure rendering task
Obtain the rendering engine example with the rendering thread binding.
In the exemplary embodiment, the rendering engine carries out figure rendering by Open GL order.
In the exemplary embodiment, described device further comprises: for making after the completion of figure rendering task
Rendering state is pulled back to the unit at the end Java by the end Native.
The present embodiment is more in conjunction with java section by the singleton design pattern of the part Native and thread private data TSD
The mode of thread, realization manage multiple Open GL context environmentals simultaneously in a process, can be simultaneously more to reach
A region carries out the technical effect of graphic plotting.Advantage independent with thread, not limiting memory and multizone while rendering.
Using example
A concrete application example is given below in the scheme and its effect of the embodiment of the present invention for ease of understanding.This field
It should be understood to the one skilled in the art that the example is only for the purposes of understanding the present invention, any detail is not intended to be limited in any way
The system present invention.
The multizone pattern drawing method and device for intelligent operating system of following example through the invention are in screen
In two regions draw two figures, the picture left above p1, bottom-right graph p2 respectively.In this example, intelligent operating system ring
Border is Android, supports Open GL 2.0.
Specific step is as follows:
1) in the first rendering thread of the end Java creation and the second rendering process.
Specifically, in the first rendering thread of the end Java creation and the second rendering process, the respectively end Native provides rendering
Thread context, and generate two Open GL context environmentals.
2) at the end Native, respectively two render threads provide rendering contexts in create the first rendering engine example and
Second rendering engine example.
3) the first rendering engine example and the second rendering engine example are respectively implanted the first rendering thread and the second rendering
In the TSD of thread, the first rendering engine example and the first rendering thread are bound, and by the second rendering example and the
Two rendering threads are bound.
4) rendering task of p1 is submitted to first rendering engine at the end Native bound with it based on the first rendering thread,
The path of task direction p1;Submit p2's to second rendering engine at the end Native bound with it based on the second rendering thread
Rendering task, the task are directed toward the path of p2.
5) the first rendering engine and the second rendering engine respectively obtain rendering task, and the type for needing to render is all picture,
The first rendering engine and the second rendering engine call Open GL interface to be loaded into memory for p1 and p2 as texture therewith, and lead to
It crosses Open GL interface and the memory cache is exchanged into display buffer, complete each in the first rendering engine and the second rendering engine
The display of self-corresponding screen area.
Due to by multithreading realize, the display of p1 and p2 be while.
It will be understood by those skilled in the art that above to the purpose of the description of the embodiment of the present invention only for illustratively saying
The beneficial effect of bright the embodiment of the present invention is not intended to limit embodiments of the invention to given any example.
The present invention can be device, method and/or computer program product.Computer program product may include computer
Readable storage medium storing program for executing, containing for making processor realize the computer-readable program instructions of various aspects of the invention.
Computer readable storage medium, which can be, can keep and store the tangible of the instruction used by instruction execution equipment
Equipment.Computer readable storage medium for example can be-- but it is not limited to-- storage device electric, magnetic storage apparatus, optical storage
Equipment, electric magnetic storage apparatus, semiconductor memory apparatus or above-mentioned any appropriate combination.Computer readable storage medium
More specific example (non exhaustive list) includes: portable computer diskette, hard disk, random access memory (RAM), read-only deposits
It is reservoir (ROM), erasable programmable read only memory (EPROM or flash memory), static random access memory (SRAM), portable
Compact disk read-only memory (CD-ROM), digital versatile disc (DVD), memory stick, floppy disk, mechanical coding equipment, for example thereon
It is stored with punch card or groove internal projection structure and the above-mentioned any appropriate combination of instruction.Calculating used herein above
Machine readable storage medium storing program for executing is not interpreted that instantaneous signal itself, the electromagnetic wave of such as radio wave or other Free propagations lead to
It crosses the electromagnetic wave (for example, the light pulse for passing through fiber optic cables) of waveguide or the propagation of other transmission mediums or is transmitted by electric wire
Electric signal.
Computer-readable program instructions as described herein can be downloaded to from computer readable storage medium it is each calculate/
Processing equipment, or outer computer or outer is downloaded to by network, such as internet, local area network, wide area network and/or wireless network
Portion stores equipment.Network may include copper transmission cable, optical fiber transmission, wireless transmission, router, firewall, interchanger, gateway
Computer and/or Edge Server.Adapter or network interface in each calculating/processing equipment are received from network to be counted
Calculation machine readable program instructions, and the computer-readable program instructions are forwarded, for the meter being stored in each calculating/processing equipment
In calculation machine readable storage medium storing program for executing.
Computer program instructions for executing operation of the present invention can be assembly instruction, instruction set architecture (ISA) instructs,
Machine instruction, machine-dependent instructions, microcode, firmware instructions, condition setup data or with one or more programming languages
The source code or object code that any combination is write, the programming language include the programming language-of object-oriented such as
Smalltalk, C++ etc., and conventional procedural programming languages-such as " C " language or similar programming language.Computer
Readable program instructions can be executed fully on the user computer, partly execute on the user computer, be only as one
Vertical software package executes, part executes on the remote computer or completely in remote computer on the user computer for part
Or it is executed on server.In situations involving remote computers, remote computer can pass through network-packet of any kind
It includes local area network (LAN) or wide area network (WAN)-is connected to subscriber computer, or, it may be connected to outer computer (such as benefit
It is connected with ISP by internet).In some embodiments, by utilizing computer-readable program instructions
Status information carry out personalized customization electronic circuit, such as programmable logic circuit, field programmable gate array (FPGA) or can
Programmed logic array (PLA) (PLA), the electronic circuit can execute computer-readable program instructions, to realize each side of the invention
Face.
Referring herein to according to the method for the embodiment of the present invention, the flow chart of device (system) and computer program product and/
Or block diagram describes various aspects of the invention.It should be appreciated that flowchart and or block diagram each box and flow chart and/
Or in block diagram each box combination, can be realized by computer-readable program instructions.
These computer-readable program instructions can be supplied to general purpose computer, special purpose computer or other programmable datas
The processor of processing unit, so that a kind of machine is produced, so that these instructions are passing through computer or other programmable datas
When the processor of processing unit executes, function specified in one or more boxes in implementation flow chart and/or block diagram is produced
The device of energy/movement.These computer-readable program instructions can also be stored in a computer-readable storage medium, these refer to
It enables so that computer, programmable data processing unit and/or other equipment work in a specific way, thus, it is stored with instruction
Computer-readable medium then includes a manufacture comprising in one or more boxes in implementation flow chart and/or block diagram
The instruction of the various aspects of defined function action.
Computer-readable program instructions can also be loaded into computer, other programmable data processing units or other
In equipment, so that series of operation steps are executed in computer, other programmable data processing units or other equipment, to produce
Raw computer implemented process, so that executed in computer, other programmable data processing units or other equipment
Instruct function action specified in one or more boxes in implementation flow chart and/or block diagram.
The flow chart and block diagram in the drawings show the system of multiple embodiments according to the present invention, method and computer journeys
The architecture, function and operation in the cards of sequence product.In this regard, each box in flowchart or block diagram can generation
One module of table, program segment or a part of instruction, the module, program segment or a part of instruction include one or more use
The executable instruction of the logic function as defined in realizing.In some implementations as replacements, function marked in the box
It can occur in a different order than that indicated in the drawings.For example, two continuous boxes can actually be held substantially in parallel
Row, they can also be executed in the opposite order sometimes, and this depends on the function involved.It is also noted that block diagram and/or
The combination of each box in flow chart and the box in block diagram and or flow chart, can the function as defined in executing or dynamic
The dedicated hardware based system made is realized, or can be realized using a combination of dedicated hardware and computer instructions.
Various embodiments of the present invention are described above, above description is exemplary, and non-exclusive, and
It is not limited to disclosed each embodiment.Without departing from the scope and spirit of illustrated each embodiment, for this skill
Many modifications and changes are obvious for the those of ordinary skill in art field.The selection of term used herein, purport
In the principle, practical application or improvement to the technology in market for best explaining each embodiment, or make the art
Other those of ordinary skill can understand each embodiment disclosed herein.