Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

libagl: add 10:10:10 color space

  • Loading branch information...
commit db9478810bd1b575e526cb63430a2c18bce31acf 1 parent 10f9d16
Sébastien Bourdeauducq authored March 25, 2013
3  agg_test.cpp
@@ -72,7 +72,7 @@ void agg_test(void)
72 72
     agg::rendering_buffer rbuf(buf, width, height, width * 4);
73 73
 
74 74
     // Create the renderer and the rasterizer
75  
-    agg::renderer<agg::span_rgba32> ren(rbuf);
  75
+    agg::renderer<agg::span_rgb101010> ren(rbuf);
76 76
     agg::rasterizer ras;
77 77
 
78 78
     // Setup the rasterizer
@@ -138,4 +138,3 @@ void agg_test(void)
138 138
 
139 139
     delete [] buf;
140 140
 }
141  
-
54  libagl/include/agg.h
@@ -1262,8 +1262,60 @@ namespace agg
1262 1262
     };
1263 1263
 
1264 1264
 
1265  
-}
1266 1265
 
  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
+}
1267 1319
 
1268 1320
 
1269 1321
 #endif

0 notes on commit db94788

Please sign in to comment.
Something went wrong with that request. Please try again.