[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master 54bfce0 1/2: [graph] Implement and register gra
From: |
Alexei Podtelezhnikov |
Subject: |
[freetype2-demos] master 54bfce0 1/2: [graph] Implement and register gray_span function. |
Date: |
Wed, 19 Jun 2019 23:34:39 -0400 (EDT) |
branch: master
commit 54bfce0da1cd0d31a4aaff39f100ed19ac2a452e
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>
[graph] Implement and register gray_span function.
* graph/gblspans.h, graph/gblany.h (_gblender_spans_*): New functions.
* graph/grobjs.h (grSurface): New fields `gray_spans' and `gcolor'.
* graph/gblblit.c (grSetSurfaceGamma): Initialize `gray_spans'.
* graph/rules.mk: Add new file.
---
ChangeLog | 9 +++++++++
graph/gblany.h | 18 ++++++++++++++++++
graph/gblblit.c | 19 +++++++++++++++++++
graph/gblspans.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
graph/grobjs.h | 18 ++++++++++++++++++
graph/rules.mk | 1 +
6 files changed, 113 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 562062b..b0e7256 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2019-06-19 Alexei Podtelezhnikov <address@hidden>
+
+ [graph] Implement and register gray_span function.
+
+ * graph/gblspans.h, graph/gblany.h (_gblender_spans_*): New functions.
+ * graph/grobjs.h (grSurface): New fields `gray_spans' and `gcolor'.
+ * graph/gblblit.c (grSetSurfaceGamma): Initialize `gray_spans'.
+ * graph/rules.mk: Add new file.
+
2019-06-18 Alexei Podtelezhnikov <address@hidden>
[graph] Clearly separate two blenders.
diff --git a/graph/gblany.h b/graph/gblany.h
index 7ae46a4..78ac970 100644
--- a/graph/gblany.h
+++ b/graph/gblany.h
@@ -41,6 +41,24 @@
static void
+GCONCAT( _gblender_spans_, GDST_TYPE )( int y,
+ int count,
+ const grSpan* spans,
+ grSurface* surface )
+{
+ GBlenderPixel color = surface->gcolor;
+ GBlender blender = surface->gblender;
+ unsigned int r = (color >> 16) & 255;
+ unsigned int g = (color >> 8) & 255;
+ unsigned int b = (color) & 255;
+
+ GDST_COPY_VAR
+
+#include "gblspans.h"
+}
+
+
+static void
GCONCAT( _gblender_blit_gray8_, GDST_TYPE )( GBlenderBlit blit,
GBlenderPixel color )
{
diff --git a/graph/gblblit.c b/graph/gblblit.c
index 03e265e..718b811 100644
--- a/graph/gblblit.c
+++ b/graph/gblblit.c
@@ -394,4 +394,23 @@ grSetTargetGamma( grBitmap* target,
gblender_init( surface->gblender, gamma );
+
+ /* not related to gamma but needs to be set */
+ switch ( target->mode )
+ {
+ case gr_pixel_mode_gray:
+ surface->gray_spans = _gblender_spans_gray8;
+ break;
+ case gr_pixel_mode_rgb32:
+ surface->gray_spans = _gblender_spans_rgb32;
+ break;
+ case gr_pixel_mode_rgb24:
+ surface->gray_spans = _gblender_spans_rgb24;
+ break;
+ case gr_pixel_mode_rgb565:
+ surface->gray_spans = _gblender_spans_rgb565;
+ break;
+ default:
+ surface->gray_spans = (grSpanFunc)0;
+ }
}
diff --git a/graph/gblspans.h b/graph/gblspans.h
new file mode 100644
index 0000000..b0c38e5
--- /dev/null
+++ b/graph/gblspans.h
@@ -0,0 +1,48 @@
+
+ GBLENDER_VARS;
+
+ unsigned char* dst_line = surface->bitmap.buffer;
+
+ gblender_use_channels( blender, 0 );
+
+ GBLENDER_VARS_SET(blender,color);
+
+ /* make compiler happy */
+ (void)(r);
+ (void)(g);
+ (void)(b);
+
+ if ( surface->bitmap.pitch > 0 )
+ dst_line -= surface->bitmap.pitch * ( y - surface->bitmap.rows + 1 );
+ else
+ dst_line -= surface->bitmap.pitch * y;
+
+ for ( ; count--; spans++ )
+ {
+ unsigned char* dst = dst_line + spans->x * GDST_INCR;
+ unsigned short w = spans->len;
+ int a = GBLENDER_SHADE_INDEX( spans->coverage );
+
+ if ( a == GBLENDER_SHADE_COUNT-1 )
+ for ( ; w-- ; dst += GDST_INCR )
+ {
+ GDST_COPY(dst);
+ }
+ else if ( a )
+ for ( ; w-- ; dst += GDST_INCR )
+ {
+ GBlenderPixel back;
+
+ GDST_READ(dst,back);
+
+ GBLENDER_LOOKUP( blender, back );
+
+#ifdef GBLENDER_STORE_BYTES
+ GDST_STOREB(dst,_gcells,a);
+#else
+ GDST_STOREP(dst,_gcells,a);
+#endif
+ }
+ }
+
+ GBLENDER_CLOSE(blender);
diff --git a/graph/grobjs.h b/graph/grobjs.h
index 92c7f9b..c5cfd7d 100644
--- a/graph/grobjs.h
+++ b/graph/grobjs.h
@@ -107,6 +107,21 @@
grEvent *event );
+ typedef struct grSpan_
+ {
+ short x;
+ unsigned short len;
+ unsigned char coverage;
+
+ } grSpan;
+
+ typedef void
+ (*grSpanFunc)( int y,
+ int count,
+ const grSpan* spans,
+ grSurface* surface );
+
+
struct grSurface_
{
@@ -114,6 +129,9 @@
GBlenderRec gblender[1];
+ GBlenderPixel gcolor;
+ grSpanFunc gray_spans;
+
grDevice* device;
grBool refresh;
grBool owner;
diff --git a/graph/rules.mk b/graph/rules.mk
index b1a1e11..8f3e75b 100644
--- a/graph/rules.mk
+++ b/graph/rules.mk
@@ -19,6 +19,7 @@ GRAPH := $(TOP_DIR_2)/graph
GRAPH_H := $(GRAPH)/gblany.h \
$(GRAPH)/gblbgra.h \
$(GRAPH)/gblblit.h \
+ $(GRAPH)/gblspans.h \
$(GRAPH)/gblcolor.h \
$(GRAPH)/gblhbgr.h \
$(GRAPH)/gblhrgb.h \
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master 54bfce0 1/2: [graph] Implement and register gray_span function.,
Alexei Podtelezhnikov <=