[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master 6944770: [graph] Let the driver set convenient
From: |
Alexei Podtelezhnikov |
Subject: |
[freetype2-demos] master 6944770: [graph] Let the driver set convenient depth. |
Date: |
Tue, 27 Oct 2020 23:30:26 -0400 (EDT) |
branch: master
commit 69447701abc519169287ec5198e2aff891367de1
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>
[graph] Let the driver set convenient depth.
Let the driver change `gr_pixel_mode_none' to whatever depth is
convenient and make that the default. You can still force an
alternative depth from the command line.
* graph/batch/grbatch.c (gr_batch_surface_init): Default to rgb24.
* graph/win32/grwin32.c (gr_win32_surface_init): Default to rgb32.
* graph/x11/grx11.c (gr_x11_surface_init): Match the visual depth.
* graph/graph.h (grNewSurface): Document `gr_pixel_mode_none' request.
* src/ftcommon.c (FTDemo_Display_New): Use `gr_pixel_mode_none'.
---
ChangeLog | 15 +++++++++++++++
graph/batch/grbatch.c | 4 ++++
graph/graph.h | 3 +++
graph/win32/grwin32.c | 5 +++++
graph/x11/grx11.c | 16 ++++++++++++++++
src/ftcommon.c | 7 +++++--
6 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e0d8a88..6012e7d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
2020-10-27 Alexei Podtelezhnikov <apodtele@gmail.com>
+ [graph] Let the driver set convenient depth.
+
+ Let the driver change `gr_pixel_mode_none' to whatever depth is
+ convenient and make that the default. You can still force an
+ alternative depth from the command line.
+
+ * graph/batch/grbatch.c (gr_batch_surface_init): Default to rgb24.
+ * graph/win32/grwin32.c (gr_win32_surface_init): Default to rgb32.
+ * graph/x11/grx11.c (gr_x11_surface_init): Match the visual depth.
+
+ * graph/graph.h (grNewSurface): Document `gr_pixel_mode_none' request.
+ * src/ftcommon.c (FTDemo_Display_New): Use `gr_pixel_mode_none'.
+
+2020-10-27 Alexei Podtelezhnikov <apodtele@gmail.com>
+
[graph/x11] Zero-copy 15/16/32-bit modes.
We opportunistically rely on XPutImage that can perform minimal
diff --git a/graph/batch/grbatch.c b/graph/batch/grbatch.c
index 2d59af4..289119f 100644
--- a/graph/batch/grbatch.c
+++ b/graph/batch/grbatch.c
@@ -72,6 +72,10 @@
gr_batch_surface_init( grSurface* surface,
grBitmap* bitmap )
{
+ /* Set default mode */
+ if ( bitmap->mode == gr_pixel_mode_none )
+ bitmap->mode = gr_pixel_mode_rgb24;
+
if ( grNewBitmap( bitmap->mode, bitmap->grays,
bitmap->width, bitmap->rows, bitmap ) )
return 0;
diff --git a/graph/graph.h b/graph/graph.h
index 9f71a04..96b62ae 100644
--- a/graph/graph.h
+++ b/graph/graph.h
@@ -481,6 +481,9 @@
* handle to the corresponding surface object. 0 in case of error
*
* <Note>
+ * If the requsted mode is gr_pixel_mode_mono, the driver can choose
+ * a mode that is convenient for the driver.
+ *
* All drivers are _required_ to support at least the following
* pixel formats :
*
diff --git a/graph/win32/grwin32.c b/graph/win32/grwin32.c
index b220d0f..47f0bfa 100644
--- a/graph/win32/grwin32.c
+++ b/graph/win32/grwin32.c
@@ -432,6 +432,11 @@ gr_win32_surface_init( grWin32Surface* surface,
static RGBQUAD black = { 0, 0, 0, 0 };
static RGBQUAD white = { 0xFF, 0xFF, 0xFF, 0 };
+
+ /* Set default mode */
+ if ( bitmap->mode == gr_pixel_mode_none )
+ bitmap->mode = gr_pixel_mode_rgb32;
+
LOG(( "Win32: init_surface( %p, %p )\n", surface, bitmap ));
LOG(( " -- input bitmap =\n" ));
diff --git a/graph/x11/grx11.c b/graph/x11/grx11.c
index 674fffa..e84cdb4 100644
--- a/graph/x11/grx11.c
+++ b/graph/x11/grx11.c
@@ -1321,6 +1321,22 @@
surface->display = display = x11dev.display;
surface->visual = x11dev.visual;
+ /* Select default mode */
+ if ( bitmap->mode == gr_pixel_mode_none )
+ {
+ if ( x11dev.format->x_bits_per_pixel == 32 &&
+ x11dev.format->x_depth == 24 )
+ bitmap->mode = gr_pixel_mode_rgb32;
+ else if ( x11dev.format->x_bits_per_pixel == 16 &&
+ x11dev.format->x_depth == 16 )
+ bitmap->mode = gr_pixel_mode_rgb565;
+ else if ( x11dev.format->x_bits_per_pixel == 16 &&
+ x11dev.format->x_depth == 15 )
+ bitmap->mode = gr_pixel_mode_rgb555;
+ else
+ bitmap->mode = gr_pixel_mode_rgb24;
+ }
+
/* Set up conversion routines or opportunistic zero-copy */
switch ( bitmap->mode )
{
diff --git a/src/ftcommon.c b/src/ftcommon.c
index 9f70378..a5c52d8 100644
--- a/src/ftcommon.c
+++ b/src/ftcommon.c
@@ -110,7 +110,7 @@
grPixelMode mode;
grSurface* surface;
grBitmap bit;
- int width, height, depth = 24;
+ int width, height, depth = 0;
if ( sscanf( dims, "%dx%dx%d", &width, &height, &depth ) < 2 )
@@ -127,11 +127,14 @@
case 16:
mode = gr_pixel_mode_rgb565;
break;
+ case 24:
+ mode = gr_pixel_mode_rgb24;
+ break;
case 32:
mode = gr_pixel_mode_rgb32;
break;
default:
- mode = gr_pixel_mode_rgb24;
+ mode = gr_pixel_mode_none;
break;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master 6944770: [graph] Let the driver set convenient depth.,
Alexei Podtelezhnikov <=