CN100468346C - Drawing resource management method and system - Google Patents
Drawing resource management method and system Download PDFInfo
- Publication number
- CN100468346C CN100468346C CNB2007100737978A CN200710073797A CN100468346C CN 100468346 C CN100468346 C CN 100468346C CN B2007100737978 A CNB2007100737978 A CN B2007100737978A CN 200710073797 A CN200710073797 A CN 200710073797A CN 100468346 C CN100468346 C CN 100468346C
- Authority
- CN
- China
- Prior art keywords
- drawing resource
- resources
- resource object
- graphics
- key word
- 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
Landscapes
- Image Generation (AREA)
- Processing Or Creating Images (AREA)
Abstract
The invention applied to the field of computer application provides graphics resource management methods and systems. Including the following steps: Statement graphics resources object mapping resources and set targets the creation of parameters, in accordance with the creation of graphics resources object parameters unique identifier generated graphics resources referred to the object mapping resources keyword; keyword resources, in accordance with graphics drawing resources from the pool of resources mapping out above target. Mentioned include: graphics resource pool, drawing resources Objects unit, mapping resources to create object parameter settings unit, keyword mapping resources generated graphics modules as well as access to resources unit. In the implementation, in accordance with the parameter mapping resources to create unique identifier generated graphics resource mapping resources targeted keywords, graphics resources will minimize duplication of occupation. At the same time drawing on the resources used graphics object cache resources and the release mechanism, and reduce the frequency mapping resources to create risk and improve the performance of the procedure.
Description
Technical field
The invention belongs to computer application field, relate in particular to a kind of management method and system of drawing resource.
Background technology
In based on Windows operating system desktop process of application development, because Graphics Device Interface (the Graphic Device Interface that system provides, GDI) resource (being also referred to as drawing resource) is limited, need after drawing resource is used to be released immediately, otherwise system can occur unusually when too high when drawing resource occupies.In order to prevent the drawing resource leakage, generally use class encapsulation drawing resource, when the life cycle of class finishes, call destructor function and discharge drawing resource.But when needing to create much same drawing resource, the drawing resource of a lot of repetitions will be taken.As will draw a white background time to window, create a drawing resource, when creating a lot of such windows, will create a lot of same drawing resources.The repeating to create of drawing resource has a significant impact program operation speed, and be special, and (Input/Output, in the time of I/O), frequently repeating to create drawing resource can have a significant impact program operation speed when the establishment of drawing resource relates to the disk I/O.
Drawing resource repeats to take and the frequent problem of creating of drawing resource in order to solve.The most common mode is to create this drawing resource before using drawing resource, gives this drawing resource name, when using these drawing resources, takes out by name then.This requires drawing resource just not to be created when also not being used, and for reducing developer's programming burden, has only definite drawing resource that can be in daily use just can name, and be used in suitable place.This will increase developer's burden, the problem that can not avoid drawing resource to repeat to take fully simultaneously.
Summary of the invention
The purpose of the embodiment of the invention is to provide a kind of management method and system of drawing resource, is intended to solve that drawing resource in the prior art frequently repeats to create, drawing resource discharges untimely problem.
The embodiment of the invention is achieved in that a kind of management method of drawing resource, and described method comprises the steps:
Statement drawing resource object also is provided with the establishment parameter of drawing resource object;
Generate the drawing resource key word of the described drawing resource object of unique identification according to the establishment parameter of described drawing resource object;
From the drawing resource pond, take out described drawing resource object according to described drawing resource key word.
Another purpose of the embodiment of the invention is to provide a kind of management system of drawing resource, and described system comprises:
The drawing resource pond is used to store the drawing resource object;
Drawing resource object statement unit is used to state the drawing resource object;
Drawing resource Object Creation parameter set unit is used to be provided with the establishment parameter of drawing resource object;
Drawing resource key word generation unit is used for the drawing resource key word according to the described drawing resource object of establishment parameter generation unique identification of described drawing resource object; And
The drawing resource access unit is used for taking out described drawing resource object from the drawing resource pond and the drawing resource object of creating being deposited described drawing resource pond according to described drawing resource key word.
In embodiments of the present invention, generate the drawing key word of the identical drawing resource of unique identification by the establishment parameter of the drawing resource object that is provided with according to the user, avoided that drawing resource repeats to take up room in the drawing resource pond, thereby taking of drawing resource minimized.
Description of drawings
Fig. 1 is the realization flow figure of the optimization drawing resource management method that provides of the embodiment of the invention;
Fig. 2 is the structural drawing of the optimization drawing resource management system that provides of the embodiment of the invention.
Embodiment
In order to make purpose of the present invention, technical scheme and advantage clearer,, the present invention is further elaborated below in conjunction with drawings and Examples.Should be appreciated that specific embodiment described herein only in order to explanation the present invention, and be not used in qualification the present invention.
In embodiments of the present invention, generate the unique key word of resource according to the asset creation parameter and indicate identical drawing resource, avoided the repetition of drawing resource, thereby dropped to taking of drawing resource minimum, reduce the creation-time of drawing resource, improved the performance of program.When the simultaneous graphic system resource pool carries out unified management to drawing resource, adopt caching mechanism and releasing mechanism further to reduce the establishment repeatedly of drawing resource, reaching more, dominance can show.
Fig. 1 shows the steps flow chart of the optimization drawing resource management method that the embodiment of the invention provides.
In step S101, the drawing resource object that the user need use is stated.Be example in embodiments of the present invention with the paintbrush, then the user states a paintbrush object before using paintbrush.This paintbrush object has a plurality of description attributes, as color, thickness, linear etc.
In step S102, the user is provided with the establishment parameter of declared drawing resource object according to actual needs.It creates the parameter difference dissimilar drawing resources, and the user is provided with the establishment parameter of object according to actual needs, and this creates parameter is that expression has the paintbrush of different-effect at the concrete value of the descriptive attributes setting of paintbrush.The establishment parameter that the paintbrush drawing resource for example is set is as described below:
m_crBrush=RGB(0,0,0);
m_uBrushStyle=BS_SOLID;
m_nHatch=HS_HORIZONTAL;
Wherein m_crBrush represents the color of paintbrush, and m_uBrushStyle represents the pattern of paintbrush, and m_nHatch represents the style of paintbrush.
In step S103, the establishment parameter of the drawing resource object that is provided with according to the user generates drawing resource key word (Key), and judges whether there is this drawing resource object in the drawing resource pond according to the drawing resource key word.Because it creates different drawing resource objects parameter and distinguish to some extent, this drawing resource object of sign that the drawing resource key word that generates according to the establishment parameter of drawing resource object can be unique is used to distinguish other drawing resource object.Because the drawing descriptive attributes difference of dissimilar drawing resources, therefore at different drawing resources, the method that generates the drawing resource key word is also different.Wherein drawing resource is meant the drawing object that desktop is drawn and used, as paintbrush, paintbrush, picture, font etc.In embodiments of the present invention, be example with the paintbrush, the process that generates the drawing resource key word according to the establishment parameter of drawing resource object is described.The establishment parameter of the paintbrush that user among the step S102 is provided with is formed a character string, and promptly the key word of the paintbrush that generates according to the establishment parameter of paintbrush is the character string of being made up of the establishment parameter of paintbrush.Because different paintbrush has different establishment parameters, is also had any different sign paintbrush drawing resource that can be unique by the character string that the establishment parameter of each paintbrush is formed.For example code can be for as described below:
///the generate unique Key of paintbrush
CString?TDrawElmInfo<WTL::CBrush>::ToKey()
{
CString?strKey=_T("");
COLORREF?crBrush=m_crBrush;
UINT?uStyle=m_uBrushStyle;
LONG nHatch=m_nHatch; ///more than the establishment parameter of paintbrush is set
StrKey.Format (_ T (" Brush:%x:%x:%x "), crBrush, uStyle, nHatch); ///pass through
The calling system function generates the paintbrush key word
returnstrKey;
}
Whether retrieval exists the drawing resource key word of above-mentioned generation to judge whether there is this drawing resource object in the drawing resource pond in the drawing resource pond.If there is no, then change step S104.Otherwise change step S105.
In step S104, create this drawing resource object and the drawing resource object of creating is saved in the drawing resource pond according to the establishment parameter of drawing resource object.Because the descriptive attributes difference of dissimilar drawing resources, therefore at different drawing resources, the method for creating drawing resource is also different.In embodiments of the present invention, be example with the paintbrush, the process of creating drawing resource according to the establishment parameter of drawing resource object is described.
///create paintbrush resource
BOOL?TDrawElmInfo<WTL::CBrush>::CreateElement(TObjectHandle<WT
L::CBrush>hBrush)
{
LOGBRUSH?logBrush;
LogBrush.1bColor=m_crBrush; The color of ///be provided with paintbrush is m_crBrush
LogBrush.1bHatch=m_nHatch; The pattern of ///be provided with paintbrush is m_nHatch
LogBrush.1bStyle=m_uBrushStyle; The style of ///be provided with paintbrush is m_uBrushStyle
The m_crBrush of ///wherein, m_nHatch, m_uBrushStyle parameter value user are provided with in step S102
HBrush-〉CreateBrushIndirect (﹠amp; LogBrush); ///create paintbrush resource
return?TRUE;
}
The drawing resource object that the drawing resource pond is mainly used in creating carries out buffer memory, avoid drawing resource frequently repeat create.In the drawing resource pond, each drawing resource object all with a reference counter combination, the current number of times that is used of reference counter indication drawing resource object.When the count value of reference counter was 0, this drawing resource object can be deleted in notice drawing resource pond, to discharge the storage space in its drawing resource pond that takies.In the drawing resource pond, the release strategy user of drawing resource object can be self-defined.Discharge algorithm earlier as adopting not use the latest, also can adopt other to discharge algorithm.
In the drawing resource pond, the drawing resource object has been adopted drawing resource buffer memory and releasing mechanism, reduced the frequent probability of creating of drawing resource, improved the performance of program.
In step S105, from the drawing resource pond, take out the drawing resource object according to the drawing resource key word.
Fig. 2 shows the structure of the management system of the drawing resource that the embodiment of the invention provides and forms.
The drawing resource object of the 11 pairs of establishments in drawing resource pond carries out buffer memory, creates to avoid frequently repeating when drawing resource is reused.In the drawing resource pond, the all corresponding reference counter 12 of each drawing resource object, the current access times of reference counter 12 indication drawing resource objects, when the count value of reference counter 12 is 0, can delete drawing resource object corresponding in the drawing resource pond, to discharge drawing resource object occupation space with reference counter.In the drawing resource pond, the release strategy user of drawing resource object can be self-defined.For example when the count value of reference counter 12 is 0, and the space in drawing resource pond is full, then deletes the drawing resource object; When the count value of reference counter 12 is 0, but the space in drawing resource pond less than, can temporarily not delete the drawing resource object, when needing to use later on, do not need to repeat to create.
The drawing resource object that the user need use by 13 statements of drawing object statement unit, wherein drawing resource is meant the drawing object that desktop is drawn and used, as paintbrush, paintbrush, picture, font etc.At concrete application, the establishment parameter of suitable drawing resource object is set by drawing resource Object Creation parameter set unit 14.Drawing resource key word generation unit 15 generates the drawing resource key word according to the establishment parameter of the drawing resource of user's setting according to above-mentioned drawing resource key word generation method.This drawing resource key word can be unique sign drawing resource object.At different drawing resources, its method that generates key word is distinguished to some extent, and the user can expand the method that generates key word as required, to support to optimize the application of drawing resource management system at the platform of supporting various types of drawing resources.
Drawing resource object judging unit 16 is retrieved the drawing resource key word that whether exists drawing resource key word generation unit 15 to generate in drawing resource pond 11.If there is no, drawing resource Object Creation unit 17 is created this drawing resource object according to the drawing resource Object Creation parameter of user's drawing resource Object Creation parameter set unit 14 settings and is saved in the drawing resource pond 11.At different drawing resources, its creation method is distinguished to some extent, and the user can expand or self-defined drawing resource creation method as required, to support to optimize the application of drawing resource management system at the platform of supporting various types of drawing resources.The creation method of drawing resource object does not repeat them here as mentioned above.If there is this drawing resource object, then takes out this drawing resource object and finish corresponding function.
In sum, generate the method for the identical drawing resource of unique identification, can avoid that drawing resource repeats to take up room in the drawing resource pond, thereby taking of drawing resource minimized by the establishment parameter of the drawing resource object that is provided with according to the user.In the drawing resource pond, adopt drawing resource buffer memory and releasing mechanism simultaneously, reduced the frequent probability of creating of drawing resource, improved the performance of program.
The above only is preferred embodiment of the present invention, not in order to restriction the present invention, all any modifications of being done within the spirit and principles in the present invention, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.
Claims (8)
1, a kind of management method of drawing resource is characterized in that, described method comprises the steps:
Statement drawing resource object also is provided with the establishment parameter of drawing resource object;
Generate the drawing resource key word of the described drawing resource object of unique identification according to the establishment parameter of described drawing resource object;
From the drawing resource pond, take out described drawing resource object according to described drawing resource key word.
2, the management method of drawing resource as claimed in claim 1 is characterized in that, also comprises the steps: before described step of taking out described drawing resource object according to described drawing resource key word
Judge whether there is described drawing resource object in the drawing resource pond according to described drawing resource key word.
3, the management method of drawing resource as claimed in claim 2 is characterized in that, described judged result is not for the time, and described method also comprises the steps:
Create described drawing resource object according to the establishment parameter of described drawing resource object, the drawing resource object of described establishment is corresponding to a reference counter, and described reference counter is indicated the current access times of described drawing resource object.
4, the management method of drawing resource as claimed in claim 3 is characterized in that, when the counting of described reference counter is 0, deletes described drawing resource object.
5, a kind of management system of drawing resource is characterized in that, described system comprises:
The drawing resource pond is used to store the drawing resource object;
Drawing resource object statement unit is used to state the drawing resource object;
Drawing resource Object Creation parameter set unit is used to be provided with the establishment parameter of drawing resource object;
Drawing resource key word generation unit is used for the drawing resource key word according to the described drawing resource object of establishment parameter generation unique identification of described drawing resource object; And
The drawing resource access unit is used for taking out described drawing resource object from the drawing resource pond and the drawing resource object of creating being deposited described drawing resource pond according to described drawing resource key word.
6, the system of optimization drawing resource management as claimed in claim 5 is characterized in that described system also comprises:
Drawing resource object judging unit is used for whether having described drawing resource object according to the described drawing resource of the drawing resource key search pond that described drawing resource key word generation unit generates.
7, the management system of drawing resource as claimed in claim 5 is characterized in that, described system also comprises:
Reference counter is used to indicate the current access times of described drawing resource object.
8, the system of optimization drawing resource management as claimed in claim 6 is characterized in that described system also comprises:
Drawing resource Object Creation unit, be used for when the judged result of described drawing resource object judging unit for not the time, create described drawing resource object according to the establishment parameter of described drawing resource object.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2007100737978A CN100468346C (en) | 2007-03-30 | 2007-03-30 | Drawing resource management method and system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2007100737978A CN100468346C (en) | 2007-03-30 | 2007-03-30 | Drawing resource management method and system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN101071390A CN101071390A (en) | 2007-11-14 |
CN100468346C true CN100468346C (en) | 2009-03-11 |
Family
ID=38898624
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CNB2007100737978A Active CN100468346C (en) | 2007-03-30 | 2007-03-30 | Drawing resource management method and system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN100468346C (en) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102999518B (en) * | 2011-09-15 | 2016-11-09 | 腾讯科技(深圳)有限公司 | A kind of Graphics Device Interface method for managing resource and device |
CN107291554A (en) * | 2013-12-18 | 2017-10-24 | 深圳市道通科技股份有限公司 | The implementation method and device of hardware resource dynamically distributes |
CN105608017A (en) * | 2015-12-11 | 2016-05-25 | 中国航空工业集团公司西安航空计算技术研究所 | Control circuit and method for memory |
CN106708623B (en) * | 2016-11-23 | 2021-04-27 | 腾讯科技(深圳)有限公司 | Object resource processing method, device and system |
CN107360317B (en) * | 2017-06-29 | 2020-12-01 | 湖南胜云光电科技有限公司 | Application program resource leakage detection method, mobile terminal and storage medium |
-
2007
- 2007-03-30 CN CNB2007100737978A patent/CN100468346C/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN101071390A (en) | 2007-11-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN102103497B (en) | Finite state machine actuating device and method, and method for establishing and using finite state machine | |
CN100487658C (en) | Method for detecting memory accessing outside | |
CN110147204B (en) | Metadata disk-dropping method, device and system and computer-readable storage medium | |
CN100468346C (en) | Drawing resource management method and system | |
US20060161583A1 (en) | Method, system and program product for interning invariant data objects in dynamic space constrained systems | |
JP2006235960A (en) | Method for increasing speed of garbage collection | |
CN106156301B (en) | A kind of processing method and processing device of big field data | |
CN1996258A (en) | Method for implementing dynamic memory pool | |
CN101840352A (en) | Method and device for monitoring database connection pool | |
US7676484B2 (en) | System and method of performing an inverse schema mapping | |
US6941309B2 (en) | Object integrated management system | |
US20050091026A1 (en) | Modelling and simulation method | |
CN107704573A (en) | A kind of intelligent buffer method coupled with business | |
CN105469173A (en) | Method of optimal management on static memory | |
CN103309696B (en) | Method and device for updating Java card extended library, and Java card | |
CN106250242A (en) | Internal memory multiplexing method based on operating system and device | |
CN107408054A (en) | Flow control for the language embedded programming in general-purpose computations graphics processing unit | |
CN109165712A (en) | Distributed generation method, device and computer storage medium by stages number | |
CN113312386A (en) | Batch warehousing method based on distributed messages | |
CN116304079A (en) | Timing-based profile data management method, apparatus, and readable storage medium | |
US6691121B1 (en) | Method and apparatus for online and dynamic extension of IMS data entry databases | |
CN108563507A (en) | A kind of EMS memory management process, device, equipment and readable storage medium storing program for executing | |
US6092092A (en) | Gap-based style-run array mechanism | |
JP2003050740A (en) | Device and method of garbage collection | |
CN100363905C (en) | Object reuse test of operation system based on absolute coordinate system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
C41 | Transfer of patent application or patent right or utility model | ||
TR01 | Transfer of patent right |
Effective date of registration: 20151221 Address after: The South Road in Guangdong province Shenzhen city Fiyta building 518057 floor 5-10 Nanshan District high tech Zone Patentee after: Shenzhen Tencent Computer System Co., Ltd. Address before: Shenzhen Futian District City, Guangdong province 518057 Zhenxing Road, SEG Science Park 2 East Room 403 Patentee before: Tencent Technology (Shenzhen) Co., Ltd. |