[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master cd32f11: * graph/grblit.c (grBlitGlyphToBitmap)
From: |
Alexei Podtelezhnikov |
Subject: |
[freetype2-demos] master cd32f11: * graph/grblit.c (grBlitGlyphToBitmap): Move code from here... |
Date: |
Sun, 16 Jun 2019 23:37:00 -0400 (EDT) |
branch: master
commit cd32f11832e19f5baf74867815dd84345d3720ba
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>
* graph/grblit.c (grBlitGlyphToBitmap): Move code from here...
* graph/gblblit.c (gblender_blit_init): ... to here.
* graph/gblblit.h: Updated.
---
ChangeLog | 6 ++++++
graph/gblblit.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++-----------
graph/gblblit.h | 16 ++++-----------
graph/grblit.c | 59 ++++--------------------------------------------------
4 files changed, 64 insertions(+), 79 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 21cdc9e..2449ab6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2019-06-16 Alexei Podtelezhnikov <address@hidden>
+
+ * graph/grblit.c (grBlitGlyphToBitmap): Move code from here...
+ * graph/gblblit.c (gblender_blit_init): ... to here.
+ * graph/gblblit.h: Updated.
+
2019-06-15 Alexei Podtelezhnikov <address@hidden>
[graph] Relocate `gblender' to `grSurface'.
diff --git a/graph/gblblit.c b/graph/gblblit.c
index 6baabdd..5476f16 100644
--- a/graph/gblblit.c
+++ b/graph/gblblit.c
@@ -1,3 +1,4 @@
+#include "grobjs.h"
#include "gblblit.h"
/* blitting gray glyphs
@@ -212,26 +213,55 @@ _gblender_blit_dummy( GBlenderBlit blit,
GBLENDER_APIDEF( int )
gblender_blit_init( GBlenderBlit blit,
- GBlender blender,
int dst_x,
int dst_y,
- GBlenderSourceFormat src_format,
- const unsigned char* src_buffer,
- int src_pitch,
- int src_width,
- int src_height,
- GBlenderTargetFormat dst_format,
- unsigned char* dst_buffer,
- int dst_pitch,
- int dst_width,
- int dst_height )
+ grBitmap* target,
+ grBitmap* glyph )
{
int src_x = 0;
int src_y = 0;
int delta;
+ GBlenderSourceFormat src_format;
+ const unsigned char* src_buffer = glyph->buffer;
+ int src_pitch = glyph->pitch;
+ int src_width = glyph->width;
+ int src_height = glyph->rows;
+ GBlenderTargetFormat dst_format;
+ unsigned char* dst_buffer = target->buffer;
+ int dst_pitch = target->pitch;
+ int dst_width = target->width;
+ int dst_height = target->rows;
- blit->blender = blender;
+ grSurface* surface = (grSurface*)target;
+
+
+ if ( glyph->grays != 256 )
+ return -2;
+
+ switch ( glyph->mode )
+ {
+ case gr_pixel_mode_gray: src_format = GBLENDER_SOURCE_GRAY8; break;
+ case gr_pixel_mode_lcd: src_format = GBLENDER_SOURCE_HRGB; break;
+ case gr_pixel_mode_lcdv: src_format = GBLENDER_SOURCE_VRGB; break;
+ case gr_pixel_mode_lcd2: src_format = GBLENDER_SOURCE_HBGR; break;
+ case gr_pixel_mode_lcdv2: src_format = GBLENDER_SOURCE_VBGR; break;
+ case gr_pixel_mode_bgra: src_format = GBLENDER_SOURCE_BGRA; break;
+ default:
+ return -2;
+ }
+
+ switch ( target->mode )
+ {
+ case gr_pixel_mode_gray: dst_format = GBLENDER_TARGET_GRAY8; break;
+ case gr_pixel_mode_rgb32: dst_format = GBLENDER_TARGET_RGB32; break;
+ case gr_pixel_mode_rgb24: dst_format = GBLENDER_TARGET_RGB24; break;
+ case gr_pixel_mode_rgb565: dst_format = GBLENDER_TARGET_RGB565; break;
+ default:
+ return -2;
+ }
+
+ blit->blender = surface->gblender;
blit->blit_func = blit_funcs[dst_format][src_format];
if ( blit->blit_func == 0 )
@@ -242,6 +272,14 @@ gblender_blit_init( GBlenderBlit blit,
return -2;
}
+ if ( glyph->mode == gr_pixel_mode_lcd ||
+ glyph->mode == gr_pixel_mode_lcd2 )
+ src_width /= 3;
+
+ if ( glyph->mode == gr_pixel_mode_lcdv ||
+ glyph->mode == gr_pixel_mode_lcdv2 )
+ src_height /= 3;
+
if ( dst_x < 0 )
{
src_width += dst_x;
diff --git a/graph/gblblit.h b/graph/gblblit.h
index 4412178..082e7fe 100644
--- a/graph/gblblit.h
+++ b/graph/gblblit.h
@@ -1,6 +1,7 @@
#ifndef GBLBLIT_H_
#define GBLBLIT_H_
+#include "grobjs.h"
#include "gblender.h"
/*
@@ -60,22 +61,13 @@ typedef struct GBlenderBlitRec_
} GBlenderBlitRec;
-
GBLENDER_API( int )
gblender_blit_init( GBlenderBlit blit,
- GBlender blender,
int dst_x,
int dst_y,
- GBlenderSourceFormat src_format,
- const unsigned char* src_buffer,
- int src_pitch,
- int src_width,
- int src_height,
- GBlenderTargetFormat dst_format,
- unsigned char* dst_buffer,
- int dst_pitch,
- int dst_width,
- int dst_height );
+ grBitmap* target,
+ grBitmap* glyph );
+
#define gblender_blit_run(b,color) (b)->blit_func( (b), (color) )
diff --git a/graph/grblit.c b/graph/grblit.c
index fa6d449..53cfbc1 100644
--- a/graph/grblit.c
+++ b/graph/grblit.c
@@ -10,7 +10,6 @@
/****************************************************************************/
#include "grblit.h"
-#include "grobjs.h"
#define GRAY8
@@ -1844,66 +1843,16 @@
/* short cut to alpha blender for certain glyph types
*/
{
- GBlenderSourceFormat src_format;
- GBlenderTargetFormat dst_format;
- int width, height;
GBlenderBlitRec gblit[1];
GBlenderPixel gcolor;
- grSurface* surface = (grSurface*)target;
- if ( glyph->grays != 256 )
- goto LegacyBlit;
-
- switch ( glyph->mode )
- {
- case gr_pixel_mode_gray: src_format = GBLENDER_SOURCE_GRAY8; break;
- case gr_pixel_mode_lcd: src_format = GBLENDER_SOURCE_HRGB; break;
- case gr_pixel_mode_lcdv: src_format = GBLENDER_SOURCE_VRGB; break;
- case gr_pixel_mode_lcd2: src_format = GBLENDER_SOURCE_HBGR; break;
- case gr_pixel_mode_lcdv2: src_format = GBLENDER_SOURCE_VBGR; break;
- case gr_pixel_mode_bgra: src_format = GBLENDER_SOURCE_BGRA; break;
-
- default:
- goto LegacyBlit;
- }
-
- width = glyph->width;
- height = glyph->rows;
-
- if ( glyph->mode == gr_pixel_mode_lcd ||
- glyph->mode == gr_pixel_mode_lcd2 )
- width /= 3;
-
- if ( glyph->mode == gr_pixel_mode_lcdv ||
- glyph->mode == gr_pixel_mode_lcdv2 )
- height /= 3;
-
- switch ( target->mode )
- {
- case gr_pixel_mode_gray: dst_format = GBLENDER_TARGET_GRAY8; break;
- case gr_pixel_mode_rgb32: dst_format = GBLENDER_TARGET_RGB32; break;
- case gr_pixel_mode_rgb24: dst_format = GBLENDER_TARGET_RGB24; break;
- case gr_pixel_mode_rgb565: dst_format = GBLENDER_TARGET_RGB565; break;
- default:
- goto LegacyBlit;
- }
-
- if ( gblender_blit_init( gblit, surface->gblender,
- x, y,
- src_format,
- glyph->buffer,
- glyph->pitch,
- width,
- height,
- dst_format,
- target->buffer,
- target->pitch,
- target->width,
- target->rows ) < 0 )
+ switch ( gblender_blit_init( gblit, x, y, target, glyph ) )
{
- /* nothing to do */
+ case -1: /* nothing to do */
return 0;
+ case -2:
+ goto LegacyBlit;
}
gcolor = ((GBlenderPixel)color.chroma[0] << 16) |
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master cd32f11: * graph/grblit.c (grBlitGlyphToBitmap): Move code from here...,
Alexei Podtelezhnikov <=