Specific embodiment
The present invention is more fully described below with reference to accompanying drawings.Although the preferred embodiments of the present invention are shown in accompanying drawing,
However, it is to be appreciated that may be realized in various forms the present invention and should not be limited by embodiments set forth here.On the contrary, there is provided
These embodiments are in order that the disclosure is more thorough and complete, and the scope of the present disclosure intactly can be conveyed to ability
The technical staff in domain.
Fig. 1 shows the multizone graphic plotting side for intelligent operating system according to an embodiment of the invention
Method.
The intelligent operating system environment of the present embodiment is Android, supports Open GL.Realize that step can generally be divided
For two parts, difference java section and Native parts.Wherein, java section is realized by Java language program, is run on
Android virtual machines;Native part realized by C/C++ language, run on home server.
Open GL have two main features:
1st, it is the software interface unrelated with hardware, can be transplanted between different platforms;
2nd, 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 threads that render that Java ends create are bound with multiple rendering engine examples that Native ends create.
Java ends can create simultaneously multiple render thread, correspondingly, provide for Native ends and multiple render thread ring
Border, and generate multiple context environmentals.Multiple render view examples are created at Java ends.
Render view is substantially to be used for controlling the controller for rendering at Native ends at Java ends.Render view class can be with
Including surface view (GLSurfaceView) example and texture view (GLTexureView) example, they are carried for Native ends
For rendering thread context.
Java ends are generated for being rendered the context environmental of figure using Open GL storehouses by Open GL bank interfaces.
Open GL context environmentals, i.e. GLContext, for storing all status informations of Open GL drawing.It is real
The acquiescence frame buffer (framebuffer) for rendering order drawing is represented on border, GLContext is destroyed, Open GL are not multiple yet
Exist.
Multiple threads are created, that is, is generated multiple context environmentals for Open GL, and a thread can only be had one
Context, correspondingly, a context environmental can only belong to a thread, it is impossible to simultaneously shared by different threads.
In multiple threads rendered outside thread is independently of main thread that Java ends create, this is to ensure that rendering
Can not be affected by service logic thread.
At Native ends, rendering engine example is created based on multiple thread contexts that render that Java ends are created.Meanwhile, lead to
Cross the rendering engine example initialization Open GL rendering contexts.
Initialization Open GL rendering contexts mainly arrange the important attribute of Open GL windows, gentle including pixel format
Punch die formula, color digit and depth digit etc..
Open GL provide two kinds of color modes:RGB (RGBA) patterns and color index mode.Own under RGBA patterns
The definition of color is represented with tri- values of RGB, sometimes also plus the Alpha values for representing transparency.Every under color index mode
The color of individual pixel is represented with certain the color index value in color index table.
Open GL can provide Double buffer and carry out drawing image.Simultaneously, backstage caches image i.e. before display in platform caching
Draw the 2nd width image.After backstage is completed, the image in the caching of backstage just shows.Now original foreground caching
Start to draw the 3rd width image, so move in circles, to increase the output speed of image.
One piece region of each the rendering engine example created by Native ends corresponding to screen.
Rendering engine example is actually accomplished all of figure and renders work, that is, complete Open GL rendering contexts initialization,
Texture generation, changes in coordinates, color setting, figure are rendered.
The rendering engine example initializes Open GL rendering contexts by Open GL bank interfaces.
Multiple threads that render that Java ends create are bound with multiple rendering engine examples that Native ends create.?
In one illustrative embodiments, by by the plurality of rendering engine example insert thread private data (TSD) come carry out with
The plurality of binding for rendering thread.
It is well known that under multi-thread environment, as data space is shared, therefore global variable is also all threads
Common.One global variable, all threads can use it, change its value, and therefore one of thread is to global change
The modification of amount will have influence on the access of another thread.Thus be necessary to provide thread the privately owned overall situation in application programming
Variable, its use the thread related data structures of address of variable of the same name and different.Surface seems which is global variable, and institute is wired
Journey can use it, and its value is individually storage in each thread.Such data structure is referred to as thread
Private data.
Before distribution thread private data, need to create the key (key) being associated with thread private data, and arrange
The key values of thread private data.Although the key of thread private data TSD is shared between the multiple threads, but for every
The individual thread key values can be different.
At Native ends, rendering engine is externally singleton pattern, but when multizone graphic plotting is carried out, actually needs
It is many cases to want it.The many cases mould based on thread is realized by singleton pattern with reference to thread private data technology in this example
Formula, i.e. thread are different, and the example that is got by singleton pattern is also different, that is, example and the thread got are corresponding.
Specifically, Java ends can create multiple render thread, 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 cross-threads that render.At Native ends, at each
Rendering of rendering that thread provided has distinguished in thread context rendering engine example newly-built, by each rendering engine example insert with
In the TSD for rendering thread of its correlation.That is, representing which in each key value for rendering the thread private data in thread
Associated rendering engine.The binding that render thread and rendering engine is achieved in this way, and the management for rendering example is led to
Cross the thread that renders that binds therewith to complete, and it is also only visible to the thread that binds therewith to render example.
The advantage of this mode is so that Native ends can be designed according to the design pattern of singleton, eliminates to many
The management of individual example.Traditional singleton design is the external only one of which example of current class, is in general externally only connect by one
Mouth provides the example.And pass through to introduce TSD technology, although still using the design pattern of singleton, i.e., externally also provide only one and connect
Mouthful example is obtained, but the example got by same thread always identical, got for different threads 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 same thread, the management to multiple examples is eliminated.
2) by Java one or more figure rendering tasks for receiving of termination be submitted to respectively different render in thread, and
And one or more of figure rendering tasks are submitted to Native ends based on the corresponding thread that renders.
When Java terminations receive multiple figure rendering tasks, different figure rendering tasks is submitted to different rendering
In thread, and Native ends are submitted to based on the respective thread that renders.
3) obtain and the wash with watercolours for rendering thread binding corresponding to one or more of figure rendering tasks at Native ends
Dye engine instance is rendered with carrying out figure.
Natvie end groups are obtained in the corresponding thread private data of the figure rendering task respectively and render thread with described
The rendering engine example of binding, carries out figure and renders.
Rendering engine example carries out figure by Open GL orders and renders.
Figure is rendered and generally includes following several stages:
A) geometric object, such as some geometric units such as point, line, triangle are specified.
B) vertex processing operation.Data received by this stage are the attributive character on each summit, and output is then
Vertex data after conversion.
C) pel assembling.After summit is processed, whole attributes on summit have all been determined, in this stage summit meeting
Pel is assembled into according to pel rule.
D) pel is processed, and mainly cutting and is disappeared sunken.
E) rasterizing operation.The primitive data passed over by pel processing stage will be broken down into less in the stage
Unit and corresponding each pixel of frame buffer zone, these units are referred to as piece unit.One piece unit may include the window left side,
The attributes such as depth, color, texture coordinate.
F) piece unit is processed.Manage including upper texture, i.e., corresponding color in texture memory is obtained by texture coordinate;Mist
Change, color is changed to current view point position by piece unit distance;Color collects:By texture, the color of main definition, the face being atomized
The color that color, the photostage of secondary color calculate gathers.
G) the first operation of piece one by one.Including pixel ownership, shearing, Alpha, stencil test, depth test, mixing
Deng these operations eventually affect which in the color value of frame buffer zone.
H) frame buffer operation.After figure is rendered and completed, rendering result is exchanged by rendering engine by Open GL interfaces
To display buffer, complete to show.As each rendering engine example is corresponding to one piece of region of screen, the knot for therefore rendering
Fruit will directly display corresponding screen area.
4) rendering result of one or more of figure rendering tasks is respectively displayed on and rendering of being rendered is drawn
Hold up in the screen area corresponding to example.
As different rendering engine examples is corresponding to the zones of different of screen, therefore executed by different rendering engine examples
The rendering result of figure rendering task simultaneously can be shown in the zones of different of screen.Thus achieve intelligent operation
The graphic plotting of the multizone of system.
In the exemplary embodiment, the multizone pattern drawing method for being used for intelligent operating system further can be wrapped
Include:After figure rendering task is completed, rendering state is pulled back to Java ends by Native ends.
When the rendering engine at Native ends terminates to render, rendering state can be returned rendering for Java ends and be regarded by rendering engine
Figure.Notify Java ends to render complete or render failure.
The advantage of the 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 Native ends, is not therefore limited by internal memory.
(2) thread is rendered independently of main thread, do not affected by service logic thread;
(3) can be rendered in multiple regions of screen simultaneously simultaneously;
(4) many cases pattern based on thread is realized by the singleton pattern of rendering engine+thread private data technology.
According to another embodiment of the present invention, there is provided a kind of multizone graphic plotting for intelligent operating system is filled
Put.The device can include:For the multiple multiple rendering engines for rendering thread and the establishment of Native ends for creating Java ends
The unit bound by example;Different for being submitted to one or more figure rendering tasks that Java terminations are received respectively
Render in thread, and one or more of figure rendering tasks are submitted to Native ends based on the corresponding thread that renders
Unit;For obtaining and the wash with watercolours for rendering thread binding corresponding to one or more of figure rendering tasks at Native ends
Contaminate engine instance to carry out the unit that figure is rendered;And for by the rendering result of one or more of figure rendering tasks
Unit in the screen area corresponding to rendering engine example for being respectively displayed on and being rendered.
In the exemplary embodiment, by by the plurality of rendering engine example insert thread private data come carry out with
The plurality of binding for rendering thread.
In the exemplary embodiment, Natvie end groups are in the corresponding thread private data difference of the figure rendering task
Obtain and the rendering engine example for rendering thread binding.
In the exemplary embodiment, the rendering engine carries out figure by Open GL orders and renders.
In the exemplary embodiment, described device is further included:After completing in figure rendering task, make
Rendering state is pulled back to the unit at Java ends at Native ends.
The present embodiment designs pattern and thread private data TSD by the singleton of Native parts, many in conjunction with java section
The mode of thread, realizes managing multiple Open GL context environmentals simultaneously in a process, can be while many so as to reach
Individual region carries out the technique effect of graphic plotting.There is thread independence, do not limit internal memory and multizone the advantage while rendering.
Application example
For ease of understanding the scheme and its effect of the embodiment of the present invention, a concrete application example given below.This area
It should be understood to the one skilled in the art that the example is not intended to limit by any way only for the purposes of understanding the present invention, its any detail
The system present invention.
The example below is by the multizone pattern drawing method and device for intelligent operating system of the present invention in screen
In two regions draw two figures respectively, the picture left above is p1, and bottom-right graph is p2.In this example, intelligent operating system ring
Border is Android, supports Open GL 2.0.
Comprise the following steps that:
1) thread and second is rendered in Java ends establishment first render process.
Specifically, thread and second being rendered in Java ends establishment first and rendering process, respectively Native ends provide and render
Thread context, and generate two Open GL context environmentals.
2) at Native ends, respectively two render thread offer 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 first render thread and second and render
In the TSD of thread, the first rendering engine example is rendered thread with first and is bound, and example and is rendered by second
Two render thread is bound.
4) rendering task that thread submits p1 to first rendering engine at the Native ends that binds with it is rendered based on first,
The task points to the path of p1;Thread is rendered based on second and submits p2's to second rendering engine at the Native ends that binds with it
Rendering task, the task point to the path of p2.
5) the first rendering engine and the second rendering engine respectively obtain rendering task, need the type for rendering to be all picture,
First rendering engine and the second rendering engine call Open GL interfaces that p1 and p2 is loaded into internal memory as texture therewith, and lead to
Cross Open GL interfaces and the memory cache is exchanged to display buffer, complete each in the first rendering engine and the second rendering engine
The display of self-corresponding screen area.
Due to being realized by multithreading, therefore the display of p1 and p2 be while.
It will be understood by those skilled in the art that above the purpose to the description of embodiments of the invention is only for exemplarily saying
The beneficial effect of bright embodiments of the 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.Computer program can include computer
Readable storage medium storing program for executing, containing the computer-readable program instructions for being used for making processor realize various aspects of the invention.
Computer-readable recording medium can be kept and store by the tangible of the instruction instruction that uses of execution equipment
Equipment.Computer-readable recording medium for example may be-but not limited to-storage device electric, magnetic storage apparatus, optical storage
Equipment, electromagnetism storage device, semiconductor memory apparatus or above-mentioned any appropriate combination.Computer-readable recording medium
More specifically example (non exhaustive list) includes:Portable computer diskette, hard disk, random access memory (RAM), read-only deposit
Reservoir (ROM), erasable programmable read only memory (EPROM or flash memory), static RAM (SRAM), portable
Compact disk read-only storage (CD-ROM), digital versatile disc (DVD), memory stick, floppy disk, mechanical coding equipment, for example thereon
Be stored with instruction punch card or groove internal projection structure and above-mentioned any appropriate combination.Calculating used herein above
Machine readable storage medium storing program for executing is not construed as instantaneous signal itself, the electromagnetic wave of such as radio wave or other Free propagations, logical
Cross the electromagnetic wave (for example, by the light pulse of fiber optic cables) of waveguide or the propagation of other transmission mediums or pass through wire transfer
Electric signal.
Computer-readable program instructions as described herein can from computer-readable recording medium download to each calculating/
Processing equipment, or outer computer or outer is downloaded to by network, such as internet, LAN, wide area network and/or wireless network
Portion's storage device.Network can include copper transmission cable, Optical Fiber Transmission, be wirelessly transferred, router, fire wall, switch, gateway
Computer and/or Edge Server.Adapter or network interface in each calculating/processing equipment receives meter from network
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.
For execute the present invention operation computer program instructions can be assembly instruction, instruction set architecture (ISA) instruction,
Machine instruction, machine-dependent instructions, microcode, firmware instructions, condition setup data or with one or more programming language
Source code or object code that any combination is write, the programming language include OO programming language such as
Smalltalk, C++ etc., and the procedural programming languages of routine such as " C " language or similar programming language.Computer
Readable program instructions fully can be executed on the user computer, partly execute on the user computer, as one solely
Vertical software kit is executed, part executes on the remote computer or completely in remote computer on the user computer for part
Or execute on server.In the situation of remote computer is related to, remote computer can pass through the network bag of any kind
Include LAN (LAN) or wide area network (WAN) is connected to subscriber computer, or, it may be connected to outer computer (such as profit
With ISP come by Internet connection).In certain embodiments, by using computer-readable program instructions
Status information carry out personalized customization electronic circuit, such as PLD, field programmable gate array (FPGA) can
Programmed logic array (PLA) (PLA), the electronic circuit can execute computer-readable program instructions, so as to realize each side of the present invention
Face.
Referring herein to method according to embodiments of the present invention, device (system) and computer program flow chart and/
Or block diagram describes various aspects of the invention.It should be appreciated that each square frame and flow chart of flow chart and/or block diagram and/
Or in block diagram each square frame combination, can be realized by computer-readable program instructions.
These computer-readable program instructions can be supplied to all-purpose computer, special-purpose computer or other programmable datas
The processor of processing meanss, so that produce a kind of machine so that these instructions are by computer or other programmable datas
During the computing device of processing meanss, flowchart is generated and/or work(specified in the one or more square frames in block diagram
The device of energy/action.These computer-readable program instructions can also be stored in a computer-readable storage medium, these refer to
Order causes computer, programmable data processing unit and/or other equipment to work in a specific way, so as to be stored with instruction
Computer-readable medium then includes a manufacture, and which is included in flowchart and/or the one or more square frames in block diagram
The instruction of the various aspects of the function/action of regulation.
Can also computer-readable program instructions be loaded into computer, other programmable data processing units or other
On equipment so that execute series of operation steps on computer, other programmable data processing units or miscellaneous equipment, to produce
The computer implemented process of life, so that execute on computer, other programmable data processing units or miscellaneous equipment
Function/action specified in one or more square frames in instruction flowchart and/or block diagram.
Flow chart and block diagram in accompanying drawing shows system, method and the computer journey of the multiple embodiments according to the present invention
The architectural framework in the cards of sequence product, function and operation.At this point, each square frame in flow chart or block diagram can generation
A part for table one module, program segment or instruction, a part for the module, program segment or instruction include one or more use
Executable instruction in the logic function for realizing regulation.In some are as the realizations that replaces, the function that marked in square frame
Can occur with the order for being different from marked in accompanying drawing.For example, two continuous square frames can essentially be held substantially in parallel
OK, they can also be executed sometimes in the opposite order, and this is depending on involved function.It is also noted that block diagram and/or
The combination of each square frame and block diagram and/or the square frame in flow chart in flow chart, can use the function or dynamic of executing regulation
The special hardware based system that makees is realizing, or can combine to realize with specialized hardware and computer instruction.
It is described above various embodiments of the present invention, described above is exemplary, and non-exclusive, and
It is not limited to disclosed each embodiment.In the case of the scope and spirit without departing from illustrated each embodiment, for this skill
For the those of ordinary skill in art field, many modifications and changes will be apparent from.The selection of term used herein, purport
Best explain the principle of each embodiment, practical application or to market in technology improvement, or make the art
Other those of ordinary skill are understood that each embodiment disclosed herein.