Skip to content

Commit db94788

Browse files
author
Sebastien Bourdeauducq
committedMar 25, 2013
libagl: add 10:10:10 color space
1 parent 10f9d16 commit db94788

File tree

2 files changed

+54
-3
lines changed

2 files changed

+54
-3
lines changed
 

‎agg_test.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void agg_test(void)
7272
agg::rendering_buffer rbuf(buf, width, height, width * 4);
7373

7474
// Create the renderer and the rasterizer
75-
agg::renderer<agg::span_rgba32> ren(rbuf);
75+
agg::renderer<agg::span_rgb101010> ren(rbuf);
7676
agg::rasterizer ras;
7777

7878
// Setup the rasterizer
@@ -138,4 +138,3 @@ void agg_test(void)
138138

139139
delete [] buf;
140140
}
141-

‎libagl/include/agg.h

+53-1
Original file line numberDiff line numberDiff line change
@@ -1262,8 +1262,60 @@ namespace agg
12621262
};
12631263

12641264

1265-
}
12661265

1266+
//========================================================================
1267+
struct span_rgb101010
1268+
{
1269+
//--------------------------------------------------------------------
1270+
static void render(unsigned char* ptr,
1271+
int x,
1272+
unsigned count,
1273+
const unsigned char* covers,
1274+
const rgba8& c)
1275+
{
1276+
unsigned int* p = (unsigned int *)ptr + x;
1277+
do
1278+
{
1279+
int alpha = (*covers++) * c.a;
1280+
int r = (*p >> 20) & 0x3ff;
1281+
int g = (*p >> 10) & 0x3ff;
1282+
int b = *p & 0x3ff;
1283+
int cr = c.r << 2;
1284+
int cg = c.g << 2;
1285+
int cb = c.b << 2;
1286+
int dr = (((cr - r) * alpha) + (r << 16)) >> 16;
1287+
int dg = (((cg - g) * alpha) + (g << 16)) >> 16;
1288+
int db = (((cb - b) * alpha) + (b << 16)) >> 16;
1289+
*p++ = (dr << 20) | (dg << 10) | db;
1290+
}
1291+
while(--count);
1292+
}
1293+
1294+
//--------------------------------------------------------------------
1295+
static void hline(unsigned char* ptr,
1296+
int x,
1297+
unsigned count,
1298+
const rgba8& c)
1299+
{
1300+
unsigned int* p = (unsigned int *)ptr + x;
1301+
unsigned int c10 = (c.r << 22) | (c.g << 12) | (c.b << 2);
1302+
do { *p++ = c10; } while(--count);
1303+
}
1304+
1305+
//--------------------------------------------------------------------
1306+
static rgba8 get(unsigned char* ptr, int x)
1307+
{
1308+
unsigned int* p = (unsigned int *)ptr + x;
1309+
rgba8 c;
1310+
c.r = (*p >> 22) & 0xff;
1311+
c.g = (*p >> 12) & 0xff;
1312+
c.b = (*p >> 2) & 0xff;
1313+
c.a = 255;
1314+
return c;
1315+
}
1316+
};
1317+
1318+
}
12671319

12681320

12691321
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.