graphic device interfaceread.pudn.com › ... › doc › comm › 726040 › training_gdi.pdf ·...

33
G G raphic raphic D D evice evice I I nterface nterface

Upload: others

Post on 07-Jul-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

GGraphic raphic DDevice evice IInterfacenterface

Page 2: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

What is GDI• GDI is a graphic interface to perform drawings

MMI WAP JAVA

GDI

Pixtel_UI Pixtel_UI Pixtel_UI

2D HW accelerator

HWdecoder

LCD IF

LCM

Page 3: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

GDI Features• Primitive drawing• Image decoding\drawing• Multi-Layer management (6218B\6219...)

• Multi-LCD management• Access LCD interface(BLT and etc.)• Access HW decoder\accelerator.

Page 4: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

GDI vs. Pixtel_UI• Pixtel_UI is old interface

– Do not support multi-layer– Do not have new features such as JPEG,etc

• GDI is new interface– Complete features (except drawing string)

Page 5: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

GDI Overview (1/3)

• GDI use handle– gdi_handle, GDI_HANDLE– Use handles to manipulate GDI object– Ex: a layer, an animation gif, a decoding jpeg, etc

• GDI function will return GDI_RESULT– Use this result to determine if the request action is

succeeded or not– Success : result >= 0– Failed : result < 0

• GDI is thread safe– GDI function is protected by MUTEX

Page 6: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

GDI Overview (2/3)

• GDI Data Type– typedef U16 gdi_color;– typedef S32 gdi_handle;– typedef S32 gdi_result;

– #define GDI_COLOR gdi_color– #define GDI_HANDLE gdi_handle– #define GDI_RESULT gdi_result

Page 7: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

GDI Overview (3/3)

• GDI PRIMITIVE– Draw point, line, rectangle, etc

• GDI IMAGE– Draw gif, bmp, wbmp, jpeg, etc

• GDI FONT– Draw font

• GDI LAYER– Multi-Layer management

• GDI LCD– Multi-LCD management

• GDI UTIL– Some utility functions

Page 8: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

GDI PRIMITVE (1/3)

• Function– Color format transform– Draw pixel– Draw line, style line– Draw rectangle, style rectangle– 2D memory copy

• Files– gdi_primitive.c– gdi_primitive.h (interface)– gdi_2d_engine.c– gdi_2d_engine.h

Page 9: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

GDI PRIMITVE (2/3)

• Color Format Transform (Macro)– GDI_RGB_TO_BUFFER_FORMAT(R,G,B)– GDI_BUFFER_FORMAT_TO_RGB_R(VALUE)– GDI_BUFFER_FORMAT_TO_RGB_G(VALUE)– GDI_BUFFER_FORMAT_TO_RGB_B(VALUE)

– Example

Page 10: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

GDI PRIMITVE (3/3)

• Draw pixel– gdi_draw_point

• Draw line & style line– gdi_draw_line– gdi_draw_line_style

• Draw rectangle & style rectangle – gdi_draw_rect– gdi_draw_solid_rect– gdi_draw_frame_rect– gdi_draw_round_rect– gdi_draw_button_rect– gdi_draw_shadow_rect– gdi_draw_gradient_rect

Page 11: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

GDI IMAGE (1/5)

• Funtions– Draw static gif, draw gif animation– Draw bmp– Draw wbmp– Draw pbm– Draw jpeg– Get image size– Get animation frame count– Source from files or internal resource

• Files– gdi_image.c– gdi_image.h (interface)– gdi_image_xxxx.c– gdi_image_xxxx.h

Page 12: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

GDI IMAGE (2/5)

• API naming rule– Draw type– Source

gdi_image_drawgdi_image_draw_animation_idgdi_image_draw_resized_file

Page 13: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

GDI IMAGE (3/5)

• Decoder Capability– BMP

• 1bit, 4bit, 8bit, 16bit, 24bit, 32bit• Do not support core header of Microsoft

– GIF • GIF87, GIF89a• Static image or animation• Normal and Interlaced mode

– JPEG• Do not support progressive mode

– WBMP• Black&white image

– PBM• MTK property format

Page 14: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

GDI IMAGE (4/5)

• APIs– gdi_image_draw (_id, _file)– gdi_image_draw_resized– gdi_image_draw_animation– gdi_image_draw_animation_once– gdi_image_draw_animation_frames– gdi_image_draw_animation_single_frame

– gdi_image_get_dimension

– gdi_image_stop_animation– gdi_image_stop_animation_all

Page 15: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

GDI IMAGE (5/5)

• No-Blocking Decoder– Decode JPEG in Media Task– Used by file manager to show thumbnail image

• Avoid UI blocked by decoding process

– Files• gdi_image_decoder.c• gdi_image_decoder.h (interface)

– APIs• gdi_image_decoder_create• gdi_image_decoder_free• gdi_image_decoder_decode_file• gdi_image_decoder_decode_file_with_output_clipping• gdi_image_decoder_get_dimension_file• gdi_image_decoder_stop• gdi_image_decoder_stop_all

Page 16: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

GDI Font• Font drawing function• HW accelerator in MT6219 and after

• Use pixtel_UI interface to draw font

Page 17: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

GDI LAYER (1/3)

• MTK chipset all support multi-layer except MT6205 series– MT6218B (4 layers)– MT6217 (4 layers)– MT6219 (4 layers)– …

• Multi-layer allows programmer to design more fancy UI presentation with better performance

• Files– gdi_layer.c– gdi_layer.h

Page 18: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

GDI LAYER (2/3)

• Drawing a submenu with background image– WITHOUT multi-layer– NEED REDRAW EVERYTHING include BACKGROUD

Page 19: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

GDI LAYER (3/3)

• Drawing a submenu with background image– WITH multi-layer– NO NEED TO REDRAW BACKGROUD

Blue is transparentcolor

Page 20: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

What is BLT?• Send Frame buffer data to LCM

Frame Buffer LCM

Drawings

BLT

DrawingsFrame Buffer

LCM

Merge & BLT

Page 21: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

GDI LAYER – Base Layer• There is always one layer exist

– Base Layer– Same size as LCM size– By default – this is the ACTIVE layer– All drawings will draw to ACTIVE layer– There is a base layer for Main LCD and a base layer

for Sub LCD– Use gdi_layer_get_active to get base layer’s handle– Base layer handle

• GDI_LAYER_MAIN_BASE_LAYER_HANDLE• GDI_LAYER_SUB_BASE_LAYER_HANDLE

Page 22: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

HOW TO USE – Init (1/2)

• Start Using Multi-layer– gdi_layer_multi_layer_enable

• Create Multi-layer– gdi_layer_create– gdi_layer_create_using_outside_memory– gdi_layer_create_double– gdi_layer_create_double_using_outside_memory

– You will get a handle when create layer successful

Page 23: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

HOW TO USE – Init (2/2)

• Set The Layer ACTIVE– gdi_layer_push_and_set_active

• gdi_layer_get_active - get previous active layer handle• gdi_layer_set_active – set this layer active

• Set Layer’s Property– gdi_layer_set_source_key

• GDI_COLOR_TRANSPARENCY (0, 0, 255)– gdi_layer_set_opacity

Previous

active layer stack

Page 24: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

HOW TO USE – Drawing• Input

– Screen need to redraw

• Drawing – Draw line, draw images, etc

• BLT to LCM– gdi_layer_blt– Tell which layers and what region will be blt to LCM– gdi_layer_set_blt_layer– gdi_layer_blt_previous Layer 0

Layer 1

Layer 2

Page 25: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

GDI LAYER – DeInit• Restore to Previous ACTIVE Layer

– gdi_layer_pop_and_restore_active• gdi_layer_set_active – set previous active layer active again

• Flatten Layers– gdi_layer_flatten_to_base

• Free Layer– gdi_layer_free

• End Using Multi-layer– gdi_layer_multi_layer_disable

Previous

active layer stack

Page 26: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

OTHER GDI LAYER APIs• Clip Region

– gdi_layer_get_clip– gdi_layer_set_clip– gdi_layer_push_clip– gdi_layer_pop_clip– gdi_layer_reset_clip

– gdi_layer_get_text_clip– gdi_layer_set_text_clip– gdi_layer_reset_text_clip– gdi_layer_push_text_clip– gdi_layer_pop_text_clip

Page 27: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

Rules! (1/3)

• RULE 1– Multi layer only support under chip 6218& 6219

• Define in MMI_feature.h , _GDI_MEMORY_PROFILE_2_

• Number indicate layer buffer count (LCD_WIDTH x LCD_HEIGHT x 2)

• RULE 2– All action will take effect on the layer after you set it active.

• Drawing.• Set clip, transparency, source key.• Move…etc.

• RULE 3– DO restore to base layer after leaving a function.

• This should always work if you use – gdi_layer_push_and_set_active– gdi_layer_pop_and_restore_active.

Page 28: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

Rules! (2/3)

• RULE 4– Some function should be PAIRED!

• gdi_layer_lock_frame_buffer• gdi_layer_unlock_frame_buffer

• gdi_layer_push_clip• gdi_layer_pop_clip

• gdi_layer_push_text_clip• gdi_layer_pop_text_clip

• gdi_layer_push_and_set_active• gdi_layer_pop_and_restore_active

– Be careful when return in the middle of a function.

Page 29: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

Rules! (3/3)

• RULE 5– Each GDI function is protected by recursive mutex.– You should use GDI_LOCK / GDI_UNLOCK to speed

up your application.– Example:

GDI_LOCKgdi_layer_lock_frame_bufferpixtel_UI_reset_clipshow_status_icons….gdi_layer_unlock_frame_buffergdi_layer_blt

GDI_UNLOCK

Page 30: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

WGUI • For backward compatible reason, wgui use

layers with base layer above newly created layer• All old component can only draw on base layer

wgui_base_layer

wgui_layer1Opacity = 40

src_key = GDI_COLOR_TRANSPARENCY

Page 31: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

GUI Multi-layer Interface• GUI add an interface for categories

• Files– Gui_window.h– Gui_window.c

Page 32: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

GDI LCD• Support multiple LCD• Files

– gdi_lcd.c– gdi_lcd.h

• APIs – gdi_lcd_set_active– gdi_lcd_get_active

– UI_set_sub_LCD_graphics_context()– UI_set_main_LCD_graphics_context()

Page 33: Graphic Device Interfaceread.pudn.com › ... › doc › comm › 726040 › Training_GDI.pdf · GDI vs. Pixtel_UI • Pixtel_UI is old interface – Do not support multi-layer –

Q&A