MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / PiuViewDrawTextureAux

Function PiuViewDrawTextureAux

modules/piu/Pebble/piuView.c:175–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173}
174
175void PiuViewDrawTextureAux(PiuView* self, PiuTexture* texture, PiuCoordinate x, PiuCoordinate y, PiuCoordinate sx, PiuCoordinate sy, PiuDimension sw, PiuDimension sh)
176{
177 GContext *ctx = (*self)->ctx;
178 GRect saveClip = ctx->draw_state.clip_box;
179 GCompOp saveMode = ctx->draw_state.compositing_mode;
180 GRect rect = GRect(x - sx, y - sy, sw + sx, sh + sy);
181 grect_clip(&ctx->draw_state.clip_box, &GRect(x + ctx->draw_state.drawing_box.origin.x, y + ctx->draw_state.drawing_box.origin.y, sw, sh));
182 if ((*texture)->gbitmap) {
183 graphics_context_set_compositing_mode(ctx, GCompOpSet);
184 graphics_draw_bitmap_in_rect_processed(ctx, (*texture)->gbitmap, &GRect(x - sx, y - sy, sw + sx, sh + sy), C_NULL);
185 }
186 else {
187 PiuFlags flags = (*texture)->flags;
188 GBitmap* bits = (flags & piuTextureColor) ? &((*texture)->bits) : NULL;
189 GBitmap* mask = (flags & piuTextureAlpha) ? &((*texture)->mask) : NULL;
190 if (mask) {
191 if (bits) {
192 if (bits->info.format == GBitmapFormat1Bit) {
193 ctx->draw_state.compositing_mode = GCompOpSet;
194 graphics_draw_bitmap_in_rect_processed(ctx, mask, &rect, C_NULL);
195 ctx->draw_state.compositing_mode = GCompOpAnd;
196 }
197 else
198 graphics_context_set_compositing_mode(ctx, GCompOpSet);
199 graphics_draw_bitmap_in_rect_processed(ctx, bits, &rect, C_NULL);
200 }
201 else {
202 #if PBL_COLOR
203 GColor saveColor = ctx->draw_state.tint_color;
204 ctx->draw_state.tint_color.argb = (*self)->color.argb;
205 ctx->draw_state.compositing_mode = GCompOpTint;
206 graphics_draw_bitmap_in_rect_processed(ctx, mask, &rect, C_NULL);
207 ctx->draw_state.tint_color = saveColor;
208 #elif PBL_BW
209 ctx->draw_state.compositing_mode = ((*self)->color.argb == GColorBlack.argb) ? GCompOpAnd : GCompOpSet;
210 graphics_draw_bitmap_in_rect_processed(ctx, mask, &rect, C_NULL);
211 #else
212 #error PBL_COLOR or PBL_BW expected
213 #endif
214 }
215 }
216 else {
217 if (bits->info.format == GBitmapFormat1Bit)
218 graphics_context_set_compositing_mode(ctx, GCompOpAssign);
219 else
220 graphics_context_set_compositing_mode(ctx, GCompOpSet);
221 graphics_draw_bitmap_in_rect_processed(ctx, bits, &rect, C_NULL);
222 }
223 }
224 ctx->draw_state.compositing_mode = saveMode;
225 ctx->draw_state.clip_box = saveClip;
226}
227
228void PiuViewFillColor(PiuView* self, PiuCoordinate x, PiuCoordinate y, PiuDimension w, PiuDimension h)
229{

Callers 3

PiuViewDrawStringFunction · 0.70
PiuViewDrawTextureFunction · 0.70
PiuViewFillTextureFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected