aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMike Reed <reed@google.com>2009-08-26 14:12:10 -0400
committerMike Reed <reed@google.com>2009-08-26 14:12:10 -0400
commitd183501476bf8c4b92b1681857f0a96c487d9b40 (patch)
tree3c38c318a9182de35b1612208ef8625fc9d93a2f /include
parent9d93915d4705b9f5c85b533012aca9b491b5a4ca (diff)
downloadexternal_skia-d183501476bf8c4b92b1681857f0a96c487d9b40.zip
external_skia-d183501476bf8c4b92b1681857f0a96c487d9b40.tar.gz
external_skia-d183501476bf8c4b92b1681857f0a96c487d9b40.tar.bz2
refresh from trunk
- edge case fix in qsort compare proc (overflowing subtract) - special case 1x1 bitmaps to draw as a color (much faster)
Diffstat (limited to 'include')
-rw-r--r--include/core/SkColorPriv.h15
-rw-r--r--include/core/SkTDArray.h11
2 files changed, 26 insertions, 0 deletions
diff --git a/include/core/SkColorPriv.h b/include/core/SkColorPriv.h
index 7658d5b..5129ac6 100644
--- a/include/core/SkColorPriv.h
+++ b/include/core/SkColorPriv.h
@@ -393,6 +393,21 @@ inline SkPMColor SkPixel16ToPixel32(U16CPU src)
return SkPackARGB32(0xFF, r, g, b);
}
+// similar to SkPixel16ToPixel32, but returns SkColor instead of SkPMColor
+static inline SkColor SkPixel16ToColor(U16CPU src) {
+ SkASSERT(src == SkToU16(src));
+
+ unsigned r = SkPacked16ToR32(src);
+ unsigned g = SkPacked16ToG32(src);
+ unsigned b = SkPacked16ToB32(src);
+
+ SkASSERT((r >> (8 - SK_R16_BITS)) == SkGetPackedR16(src));
+ SkASSERT((g >> (8 - SK_G16_BITS)) == SkGetPackedG16(src));
+ SkASSERT((b >> (8 - SK_B16_BITS)) == SkGetPackedB16(src));
+
+ return SkColorSetRGB(r, g, b);
+}
+
///////////////////////////////////////////////////////////////////////////////
typedef uint16_t SkPMColor16;
diff --git a/include/core/SkTDArray.h b/include/core/SkTDArray.h
index 5f6bbd8..954bcf8 100644
--- a/include/core/SkTDArray.h
+++ b/include/core/SkTDArray.h
@@ -86,6 +86,17 @@ public:
SkTSwap(fCount, other.fCount);
}
+ /** Return a ptr to the array of data, to be freed with sk_free. This also
+ resets the SkTDArray to be empty.
+ */
+ T* detach() {
+ T* array = fArray;
+ fArray = NULL;
+ fReserve = fCount = 0;
+ SkDEBUGCODE(fData = NULL;)
+ return array;
+ }
+
bool isEmpty() const { return fCount == 0; }
int count() const { return fCount; }
T* begin() const { return fArray; }