aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-07-02 15:01:02 +0000
committerGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-07-02 15:01:02 +0000
commit1c12abe3508cd69615c2dd50653f782835e325ce (patch)
tree776040fd65fadd907d2afa873d0bd2a03a730c6c /src/core
parentab840b81a9833bbdeb49af59833d5c707e15143d (diff)
fix gradients with alpha to convert to premul *after* the intermediate color
has been computed, othewise we can't distinguish 0x00000000 from 0x00FF0000 Add fast case for index blit where we read 4 src pixels at a time git-svn-id: http://skia.googlecode.com/svn/trunk@248 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkSpriteBlitter_RGB16.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/core/SkSpriteBlitter_RGB16.cpp b/src/core/SkSpriteBlitter_RGB16.cpp
index a158637b87..b996ef7b87 100644
--- a/src/core/SkSpriteBlitter_RGB16.cpp
+++ b/src/core/SkSpriteBlitter_RGB16.cpp
@@ -172,6 +172,68 @@ public:
///////////////////////////////////////////////////////////////////////////////
+static intptr_t asint(const void* ptr) {
+ return reinterpret_cast<const char*>(ptr) - (const char*)0;
+}
+
+static void blitrow_d16_si8(SK_RESTRICT uint16_t* dst,
+ SK_RESTRICT const uint8_t* src, int count,
+ SK_RESTRICT const uint16_t* ctable) {
+ if (count <= 8) {
+ do {
+ *dst++ = ctable[*src++];
+ } while (--count);
+ return;
+ }
+
+ // eat src until we're on a 4byte boundary
+ while (asint(src) & 3) {
+ *dst++ = ctable[*src++];
+ count -= 1;
+ }
+
+ int qcount = count >> 2;
+ SkASSERT(qcount > 0);
+ const uint32_t* qsrc = reinterpret_cast<const uint32_t*>(src);
+ if (asint(dst) & 2) {
+ do {
+ uint32_t s4 = *qsrc++;
+#ifdef SK_CPU_LENDIAN
+ *dst++ = ctable[s4 & 0xFF];
+ *dst++ = ctable[(s4 >> 8) & 0xFF];
+ *dst++ = ctable[(s4 >> 16) & 0xFF];
+ *dst++ = ctable[s4 >> 24];
+#else // BENDIAN
+ *dst++ = ctable[s4 >> 24];
+ *dst++ = ctable[(s4 >> 16) & 0xFF];
+ *dst++ = ctable[(s4 >> 8) & 0xFF];
+ *dst++ = ctable[s4 & 0xFF];
+#endif
+ } while (--qcount);
+ } else { // dst is on a 4byte boundary
+ uint32_t* ddst = reinterpret_cast<uint32_t*>(dst);
+ do {
+ uint32_t s4 = *qsrc++;
+#ifdef SK_CPU_LENDIAN
+ *ddst++ = (ctable[(s4 >> 8) & 0xFF] << 16) | ctable[s4 & 0xFF];
+ *ddst++ = (ctable[s4 >> 24] << 16) | ctable[(s4 >> 16) & 0xFF];
+#else // BENDIAN
+ *ddst++ = (ctable[s4 >> 24] << 16) | ctable[(s4 >> 16) & 0xFF];
+ *ddst++ = (ctable[(s4 >> 8) & 0xFF] << 16) | ctable[s4 & 0xFF];
+#endif
+ } while (--qcount);
+ dst = reinterpret_cast<uint16_t*>(ddst);
+ }
+ src = reinterpret_cast<const uint8_t*>(qsrc);
+ count &= 3;
+ // catch any remaining (will be < 4)
+ while (--count >= 0) {
+ *dst++ = ctable[*src++];
+ }
+}
+
+#define SkSPRITE_ROW_PROC(d, s, n, x, y) blitrow_d16_si8(d, s, n, ctable)
+
#define SkSPRITE_CLASSNAME Sprite_D16_SIndex8_Opaque
#define SkSPRITE_ARGS
#define SkSPRITE_FIELDS