aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-16 13:40:12 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-16 13:40:12 +0000
commitba6e954140e45e251d67934ed6ad752149fcf72f (patch)
tree2abaa3baddbbf3a75788b7841b9a6bd5e578a1db /include/core
parent478884f7d3b8c7be8b62f3fa2b79192f411c3fec (diff)
Revert the revert of 11247, 11250, 11251 and 11279 (Chrome already relies on changes in r11247)
git-svn-id: http://skia.googlecode.com/svn/trunk@11287 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core')
-rw-r--r--include/core/SkBitmap.h1
-rw-r--r--include/core/SkFlattenableBuffers.h26
-rw-r--r--include/core/SkFlattenableSerialization.h10
-rw-r--r--include/core/SkRect.h4
4 files changed, 37 insertions, 4 deletions
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h
index 887169ccb5..79b6fa6703 100644
--- a/include/core/SkBitmap.h
+++ b/include/core/SkBitmap.h
@@ -52,6 +52,7 @@ public:
kRGB_565_Config, //!< 16-bits per pixel, (see SkColorPriv.h for packing)
kARGB_4444_Config, //!< 16-bits per pixel, (see SkColorPriv.h for packing)
kARGB_8888_Config, //!< 32-bits per pixel, (see SkColorPriv.h for packing)
+ kLastConfig = kARGB_8888_Config,
};
// do not add this to the Config enum, otherwise the compiler will let us
diff --git a/include/core/SkFlattenableBuffers.h b/include/core/SkFlattenableBuffers.h
index 03c03f3877..b3f3684daa 100644
--- a/include/core/SkFlattenableBuffers.h
+++ b/include/core/SkFlattenableBuffers.h
@@ -41,14 +41,20 @@ public:
kCrossProcess_Flag = 1 << 0,
kScalarIsFloat_Flag = 1 << 1,
kPtrIs64Bit_Flag = 1 << 2,
+ /** The kValidation_Flag is used to force stream validations (by making
+ * sure that no operation reads past the end of the stream, for example)
+ * and error handling if any reading operation yields an invalid value.
+ */
+ kValidation_Flag = 1 << 3,
};
void setFlags(uint32_t flags) { fFlags = flags; }
uint32_t getFlags() const { return fFlags; }
- bool isCrossProcess() const { return SkToBool(fFlags & kCrossProcess_Flag); }
+ bool isCrossProcess() const { return SkToBool(fFlags & (kCrossProcess_Flag | kValidation_Flag)); }
bool isScalarFloat() const { return SkToBool(fFlags & kScalarIsFloat_Flag); }
bool isPtr64Bit() const { return SkToBool(fFlags & kPtrIs64Bit_Flag); }
+ bool isValidating() const { return SkToBool(fFlags & kValidation_Flag); }
// primitives
virtual bool readBool() = 0;
@@ -102,6 +108,13 @@ public:
return static_cast<T*>(this->readFlattenable());
}
+ void validate(bool isValid) {
+ fError |= !isValid;
+ }
+
+protected:
+ bool fError;
+
private:
uint32_t fFlags;
};
@@ -154,13 +167,22 @@ public:
enum Flags {
kCrossProcess_Flag = 0x01,
+ /** The kValidation_Flag is used here to make sure the write operation
+ * is symmetric with the read operation using the equivalent flag
+ * SkFlattenableReadBuffer::kValidation_Flag.
+ */
+ kValidation_Flag = 0x02,
};
uint32_t getFlags() const { return fFlags; }
void setFlags(uint32_t flags) { fFlags = flags; }
bool isCrossProcess() const {
- return SkToBool(fFlags & kCrossProcess_Flag);
+ return SkToBool(fFlags & (kCrossProcess_Flag | kValidation_Flag));
+ }
+
+ bool isValidating() const {
+ return SkToBool(fFlags & kValidation_Flag);
}
bool persistTypeface() const { return (fFlags & kCrossProcess_Flag) != 0; }
diff --git a/include/core/SkFlattenableSerialization.h b/include/core/SkFlattenableSerialization.h
index 720bae0917..26463bbca9 100644
--- a/include/core/SkFlattenableSerialization.h
+++ b/include/core/SkFlattenableSerialization.h
@@ -13,8 +13,14 @@
class SkData;
class SkFlattenable;
-SK_API SkData* SkSerializeFlattenable(SkFlattenable*);
-SK_API SkFlattenable* SkDeserializeFlattenable(const void* data, size_t size);
+/**
+ * These utility functions are used by the chromium codebase to safely
+ * serialize and deserialize SkFlattenable objects. These aren't made for
+ * optimal speed, but rather designed with security in mind in order to
+ * prevent Skia from being an entry point for potential attacks.
+ */
+SK_API SkData* SkValidatingSerializeFlattenable(SkFlattenable*);
+SK_API SkFlattenable* SkValidatingDeserializeFlattenable(const void* data, size_t size);
// Temporary fix for canary build
#define SkSerializeFlattenable SkValidatingSerializeFlattenable
diff --git a/include/core/SkRect.h b/include/core/SkRect.h
index d8919ae5d6..bd5d026d50 100644
--- a/include/core/SkRect.h
+++ b/include/core/SkRect.h
@@ -100,6 +100,8 @@ struct SK_API SkIRect {
*/
bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; }
+ bool isInverted() const { return fLeft > fRight || fTop > fBottom; }
+
bool isLargest() const { return SK_MinS32 == fLeft &&
SK_MinS32 == fTop &&
SK_MaxS32 == fRight &&
@@ -419,6 +421,8 @@ struct SK_API SkRect {
*/
bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; }
+ bool isInverted() const { return fLeft > fRight || fTop > fBottom; }
+
/**
* Returns true iff all values in the rect are finite. If any are
* infinite or NaN (or SK_FixedNaN when SkScalar is fixed) then this