MPLABĀ® Harmony Graphics Suite
legato_imagedecoder_raw.h
1 // DOM-IGNORE-BEGIN
2 /*******************************************************************************
3 * Copyright (C) 2020 Microchip Technology Inc. and its subsidiaries.
4 *
5 * Subject to your compliance with these terms, you may use Microchip software
6 * and any derivatives exclusively with Microchip products. It is your
7 * responsibility to comply with third party license terms applicable to your
8 * use of third party software (including open source software) that may
9 * accompany Microchip software.
10 *
11 * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
12 * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
13 * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
14 * PARTICULAR PURPOSE.
15 *
16 * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
17 * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
18 * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
19 * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
20 * FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
21 * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
22 * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
23 *******************************************************************************/
24 // DOM-IGNORE-END
25 
26 /*******************************************************************************
27  Module for Microchip Graphics Library - Legato User Interface Library
28 
29  Company:
30  Microchip Technology Inc.
31 
32  File Name:
33  legato_imagedecoder_raw.h
34 
35  Summary:
36  Image decoder
37 
38  Description:
39  Internal library use only
40 *******************************************************************************/
41 
42 // DOM-IGNORE-BEGIN
43 
44 #ifndef LE_IMAGEDECODER_RAW_H
45 #define LE_IMAGEDECODER_RAW_H
46 
49 
50 #define LE_IMAGEDECODER_RAW_MAX_STAGES 16
51 #define LE_IMAGEDECODER_BLOCK_READ_SIZE 4
52 
53 #if LE_STREAMING_ENABLED == 1
54 #ifndef LE_ASSET_DECODER_CACHE_SIZE
55 #define LE_ASSET_DECODER_CACHE_SIZE 128
56 #endif
57 
58 #if LE_ASSET_DECODER_USE_PIXEL_CACHE == 1
59 // the cache used for streaming image source data
60 extern uint8_t leRawImageDecoderScratchBuffer[LE_ASSET_DECODER_CACHE_SIZE];
61 #endif
62 
63 #if LE_ASSET_DECODER_USE_MASK_CACHE == 1
64 // the cache used for streaming mask lookup data
65 extern uint8_t leRawImageDecoderMaskScratchBuffer[LE_ASSET_DECODER_CACHE_SIZE];
66 #endif
67 
68 #if LE_ASSET_DECODER_USE_PALETTE_CACHE == 1
69 // the cache used for streaming palette lookup data
70 extern uint8_t leRawImageDecoderPaletteScratchBuffer[LE_ASSET_DECODER_CACHE_SIZE];
71 #endif
72 
73 #if LE_ASSET_DECODER_USE_BLEND_CACHE == 1
74 // the cache used for streaming blend mask lookup data
75 extern uint8_t leRawImageDecoderBlendBuffer[LE_ASSET_DECODER_CACHE_SIZE];
76 #endif
77 
78 #endif
79 
80 // *****************************************************************************
81 /* Enumeration:
82  enum leRawDecoderMode
83 
84  Summary:
85  Indicates the current mode of the raw image decoder
86 */
87 enum leRawDecoderMode
88 {
89  LE_RAW_MODE_NONE,
90  LE_RAW_MODE_DRAW,
91  LE_RAW_MODE_COPY,
92  LE_RAW_MODE_RESIZE,
93  LE_RAW_MODE_RESIZEDRAW,
94  LE_RAW_MODE_RENDER,
95  LE_RAW_MODE_ROTATE,
96  LE_RAW_MODE_ROTATEDRAW
97 };
98 
99 struct leRawDecodeState;
100 
101 // *****************************************************************************
102 /* Structure:
103  struct leRawDecodeStage
104 
105  Summary:
106  Structure defining an individual raw image decoding stage
107 
108  struct leRawDecodeState* state - pointer to the decoder state
109 
110  exec - function that runs this stage
111  cleanup - function that cleans up this stage
112 */
113 typedef struct leRawDecodeStage
114 {
115  struct leRawDecodeState* state;
116 
117  leResult (*exec)(struct leRawDecodeStage* stage);
118  void (*cleanup)(struct leRawDecodeStage* stage);
120 
122 {
123  uint32_t x;
124  uint32_t y;
125  uint32_t bufferIndex;
126  leColor data;
128 
129 // *****************************************************************************
130 /* Structure:
131  struct leRawDecodeState
132 
133  Summary:
134  Structure defining the state of the raw image decoder
135 */
136 typedef struct leRawDecodeState
137 {
138 #if LE_STREAMING_ENABLED == 1
139  leStreamManager manager; // so this decoder can act as a streaming manager
140  // if necessary
141 #endif
142 
143  const leImage* source; // the source image
144  leImage* target; // destination image for copy/decompress mode
145 
146  enum leRawDecoderMode mode; // the current mode of the decoder
147 
148  leColorMode targetMode;
149  leBool randomRLE; // hint to the decoder that RLE decodes will be random
150 
151  leRect sourceRect; // the image source rectangle
152  leRect destRect; // the target rectangle dimensions
153 
154  int32_t targetX; // the current target X position
155  int32_t targetY; // the current target Y position
156 
157  int32_t referenceX; // the current target X position
158  int32_t referenceY; // the current target Y position
159 
160  uint32_t sizeX; // the size in X of the new data
161  uint32_t sizeY; // the size in Y of the new data
162 
163  int32_t angle; // rotation angle
164  lePoint sourceOrigin; // rotation origin
165  lePoint targetOrigin; // rotation origin
166 
167  uint32_t rowIterator; // the row iterator
168  uint32_t colIterator; // the column iterator
169 
170  leRawSourceReadOperation readOperation[LE_IMAGEDECODER_BLOCK_READ_SIZE]; // source data read requests
171  uint32_t readCount;
172  uint32_t readIndex;
173 
174  leColor writeColor;
175 
176  uint32_t globalAlpha; // a global alpha state
177  uint32_t pixelAlpha; // a pixel alpha state (not used yet)
178 
179  const lePixelBuffer* palette; // pointer to a lookup table if needed
180 
181  leImageFilterMode filterMode; // resize filter mode
182 
183  leBool needToLookupMaskColor;
184 
185  leRawDecodeStage* stages[LE_IMAGEDECODER_RAW_MAX_STAGES];
186  int32_t currentStage;
187  int32_t done;
188 
190 
191 #endif /* LE_IMAGEDECODER_RAW_H */
legato_math.h
Defines common math functions for general use.
leResult
leResult
This enum represents function call results.
Definition: legato_common.h:134
leImageDecoder
This struct represents an image decoder.
Definition: legato_image.h:347
leColorMode
leColorMode
This enum represents the supported RGB color formats.
Definition: legato_color.h:146
leRect
This struct represents a rectangle.
Definition: legato_common.h:405
legato_image.h
Image functions and defintions.
legato_pixelbuffer.h
Pixel Buffer functions and definitions.
legato_memory.h
Memory functions and definitions.
leRawDecodeState
Definition: legato_imagedecoder_raw.h:137
leImage
Definition: legato_image.h:180
legato_renderer.h
leSize::width
int32_t width
Definition: legato_common.h:382
leStreamDescriptor::location
uint32_t location
Definition: legato_stream.h:58
leRectIntersects
LIB_EXPORT leBool leRectIntersects(const leRect *l_rect, const leRect *r_rect)
Determines if two rectangles are intersecting.
Definition: legato_rect.c:51
_draw
virtual leResult _draw(const leString *_this, int32_t x, int32_t y, leHAlignment align, leColor clr, uint32_t a)
Draw.
LE_STREAM_LOCATION_ID_INTERNAL
#define LE_STREAM_LOCATION_ID_INTERNAL
leEventResult
Definition: legato_stream.h:67
leBool
leBool
This enum represents booleans.
Definition: legato_common.h:157
legato_stream.h
Defines a common header for all stream operations.
legato_gpu.h
Defines wrapper for interfacing with Harmony GPU interface.
leRawSourceReadOperation
Definition: legato_imagedecoder_raw.h:122
leRawDecodeStage
Definition: legato_imagedecoder_raw.h:114
leRectClipAdj
LIB_EXPORT leRect leRectClipAdj(const leRect *l_rect, const leRect *r_rect, leRect *adj)
Clips a rectangle to the space of another rectangle.
Definition: legato_rect.c:75
LE_FALSE
@ LE_FALSE
Definition: legato_common.h:158
leRotatedRectBounds
leRect leRotatedRectBounds(leRect rect, int32_t ang)
Calculate bounding rectangle.
Definition: legato_math.c:475
leImageFilterMode
leImageFilterMode
This enum represents image filter modes.
Definition: legato_image.h:109
leRectClip
LIB_EXPORT void leRectClip(const leRect *l_rect, const leRect *r_rect, leRect *result)
Clips a rectangle to the space of another rectangle.
Definition: legato_rect.c:122
lePixelBufferAreaFill_Unsafe
LIB_EXPORT leResult lePixelBufferAreaFill_Unsafe(const lePixelBuffer *const buffer, uint32_t x, uint32_t y, uint32_t w, uint32_t h, leColor color)
Area fill no checking.
Definition: legato_pixelbuffer.c:395
LE_TRUE
@ LE_TRUE
Definition: legato_common.h:159
legato_state.h
leImage_Allocate
LIB_EXPORT leImage * leImage_Allocate(uint32_t width, uint32_t height, leColorMode mode)
Allocate an image buffer.
Definition: legato_image.c:79
leSize::height
int32_t height
Definition: legato_common.h:383
lePoint
This structure represents a integer Cartesian point.
Definition: legato_common.h:357
lePixelBuffer
Definition: legato_pixelbuffer.h:91