aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/core/SkTDArray.h2
-rw-r--r--samplecode/SampleFilterFuzz.cpp20
-rw-r--r--src/core/SkBBoxRecord.cpp2
-rw-r--r--src/core/SkFlattenableSerialization.cpp2
-rw-r--r--src/core/SkPictureStateTree.cpp12
-rw-r--r--src/core/SkPictureStateTree.h8
-rw-r--r--src/core/SkWriteBuffer.cpp12
7 files changed, 38 insertions, 20 deletions
diff --git a/include/core/SkTDArray.h b/include/core/SkTDArray.h
index c5e7a02f28..14447217e9 100644
--- a/include/core/SkTDArray.h
+++ b/include/core/SkTDArray.h
@@ -239,7 +239,7 @@ public:
while (iter > stop) {
if (*--iter == elem) {
- return iter - stop;
+ return SkToInt(iter - stop);
}
}
return -1;
diff --git a/samplecode/SampleFilterFuzz.cpp b/samplecode/SampleFilterFuzz.cpp
index adf78dcc6e..f77f3b814d 100644
--- a/samplecode/SampleFilterFuzz.cpp
+++ b/samplecode/SampleFilterFuzz.cpp
@@ -128,9 +128,27 @@ static void make_g_bitmap(SkBitmap& bitmap) {
SkIntToScalar(kBitmapSize/4), paint);
}
+static bool valid_for_raster_canvas(const SkBitmap& bm) {
+ SkImageInfo info;
+ if (!bm.asImageInfo(&info)) {
+ return false;
+ }
+ switch (info.fColorType) {
+ case kAlpha_8_SkColorType:
+ case kRGB_565_SkColorType:
+ return true;
+ case kPMColor_SkColorType:
+ return kPremul_SkAlphaType == info.fAlphaType ||
+ kOpaque_SkAlphaType == info.fAlphaType;
+ default:
+ break;
+ }
+ return false;
+}
+
static void make_checkerboard_bitmap(SkBitmap& bitmap) {
bitmap.setConfig((SkBitmap::Config)R(SkBitmap::kConfigCount), kBitmapSize, kBitmapSize);
- while (!bitmap.allocPixels()) {
+ while (valid_for_raster_canvas(bitmap) && !bitmap.allocPixels()) {
bitmap.setConfig((SkBitmap::Config)R(SkBitmap::kConfigCount), kBitmapSize, kBitmapSize);
}
SkBitmapDevice device(bitmap);
diff --git a/src/core/SkBBoxRecord.cpp b/src/core/SkBBoxRecord.cpp
index cdb70bb730..a757a245ce 100644
--- a/src/core/SkBBoxRecord.cpp
+++ b/src/core/SkBBoxRecord.cpp
@@ -43,7 +43,7 @@ void SkBBoxRecord::drawPath(const SkPath& path, const SkPaint& paint) {
void SkBBoxRecord::drawPoints(PointMode mode, size_t count, const SkPoint pts[],
const SkPaint& paint) {
SkRect bbox;
- bbox.set(pts, count);
+ bbox.set(pts, SkToInt(count));
// Small min width value, just to ensure hairline point bounding boxes aren't empty.
// Even though we know hairline primitives are drawn one pixel wide, we do not use a
// minimum of 1 because the playback scale factor is unknown at record time. Later
diff --git a/src/core/SkFlattenableSerialization.cpp b/src/core/SkFlattenableSerialization.cpp
index f34e64170c..b33bca6dbb 100644
--- a/src/core/SkFlattenableSerialization.cpp
+++ b/src/core/SkFlattenableSerialization.cpp
@@ -14,7 +14,7 @@
SkData* SkValidatingSerializeFlattenable(SkFlattenable* flattenable) {
SkWriteBuffer writer(SkWriteBuffer::kValidation_Flag);
writer.writeFlattenable(flattenable);
- uint32_t size = writer.bytesWritten();
+ size_t size = writer.bytesWritten();
void* data = sk_malloc_throw(size);
writer.writeToMemory(data);
return SkData::NewFromMalloc(data, size);
diff --git a/src/core/SkPictureStateTree.cpp b/src/core/SkPictureStateTree.cpp
index 2f3b943cdd..26cc391bfd 100644
--- a/src/core/SkPictureStateTree.cpp
+++ b/src/core/SkPictureStateTree.cpp
@@ -27,10 +27,10 @@ SkPictureStateTree::SkPictureStateTree()
SkPictureStateTree::~SkPictureStateTree() {
}
-SkPictureStateTree::Draw* SkPictureStateTree::appendDraw(uint32_t offset) {
+SkPictureStateTree::Draw* SkPictureStateTree::appendDraw(size_t offset) {
Draw* draw = static_cast<Draw*>(fAlloc.allocThrow(sizeof(Draw)));
*draw = fCurrentState;
- draw->fOffset = offset;
+ draw->fOffset = SkToU32(offset);
return draw;
}
@@ -39,7 +39,7 @@ void SkPictureStateTree::appendSave() {
fCurrentState.fNode->fFlags |= Node::kSave_Flag;
}
-void SkPictureStateTree::appendSaveLayer(uint32_t offset) {
+void SkPictureStateTree::appendSaveLayer(size_t offset) {
*static_cast<Draw*>(fStateStack.push_back()) = fCurrentState;
this->appendNode(offset);
fCurrentState.fNode->fFlags |= Node::kSaveLayer_Flag;
@@ -69,7 +69,7 @@ void SkPictureStateTree::appendTransform(const SkMatrix& trans) {
fCurrentState.fMatrix = m;
}
-void SkPictureStateTree::appendClip(uint32_t offset) {
+void SkPictureStateTree::appendClip(size_t offset) {
this->appendNode(offset);
}
@@ -78,9 +78,9 @@ SkPictureStateTree::Iterator SkPictureStateTree::getIterator(const SkTDArray<voi
return Iterator(draws, canvas, &fRoot);
}
-void SkPictureStateTree::appendNode(uint32_t offset) {
+void SkPictureStateTree::appendNode(size_t offset) {
Node* n = static_cast<Node*>(fAlloc.allocThrow(sizeof(Node)));
- n->fOffset = offset;
+ n->fOffset = SkToU32(offset);
n->fFlags = 0;
n->fParent = fCurrentState.fNode;
n->fLevel = fCurrentState.fNode->fLevel + 1;
diff --git a/src/core/SkPictureStateTree.h b/src/core/SkPictureStateTree.h
index 87529586d3..448c0d31ce 100644
--- a/src/core/SkPictureStateTree.h
+++ b/src/core/SkPictureStateTree.h
@@ -47,7 +47,7 @@ public:
/**
* Creates and returns a struct representing a draw at the given offset.
*/
- Draw* appendDraw(uint32_t offset);
+ Draw* appendDraw(size_t offset);
/**
* Given a list of draws, and a canvas, returns an iterator that produces the correct sequence
@@ -57,10 +57,10 @@ public:
Iterator getIterator(const SkTDArray<void*>& draws, SkCanvas* canvas);
void appendSave();
- void appendSaveLayer(uint32_t offset);
+ void appendSaveLayer(size_t offset);
void appendRestore();
void appendTransform(const SkMatrix& trans);
- void appendClip(uint32_t offset);
+ void appendClip(size_t offset);
/**
* Call this immediately after an appendRestore call that is associated
@@ -112,7 +112,7 @@ public:
private:
- void appendNode(uint32_t offset);
+ void appendNode(size_t offset);
SkChunkAlloc fAlloc;
// Needed by saveCollapsed() because nodes do not currently store
diff --git a/src/core/SkWriteBuffer.cpp b/src/core/SkWriteBuffer.cpp
index 07e8252ed8..a7805b5355 100644
--- a/src/core/SkWriteBuffer.cpp
+++ b/src/core/SkWriteBuffer.cpp
@@ -41,7 +41,7 @@ SkWriteBuffer::~SkWriteBuffer() {
}
void SkWriteBuffer::writeByteArray(const void* data, size_t size) {
- fWriter.write32(size);
+ fWriter.write32(SkToU32(size));
fWriter.writePad(data, size);
}
@@ -86,7 +86,7 @@ void SkWriteBuffer::writeString(const char* value) {
void SkWriteBuffer::writeEncodedString(const void* value, size_t byteLength,
SkPaint::TextEncoding encoding) {
fWriter.writeInt(encoding);
- fWriter.writeInt(byteLength);
+ fWriter.writeInt(SkToU32(byteLength));
fWriter.write(value, byteLength);
}
@@ -131,7 +131,7 @@ void SkWriteBuffer::writePath(const SkPath& path) {
}
size_t SkWriteBuffer::writeStream(SkStream* stream, size_t length) {
- fWriter.write32(length);
+ fWriter.write32(SkToU32(length));
size_t bytesWritten = fWriter.readFromStream(stream, length);
if (bytesWritten < length) {
fWriter.reservePad(length - bytesWritten);
@@ -316,10 +316,10 @@ void SkWriteBuffer::writeFlattenable(const SkFlattenable* flattenable) {
// make room for the size of the flattened object
(void)fWriter.reserve(sizeof(uint32_t));
// record the current size, so we can subtract after the object writes.
- uint32_t offset = fWriter.bytesWritten();
+ size_t offset = fWriter.bytesWritten();
// now flatten the object
flattenable->flatten(*this);
- uint32_t objSize = fWriter.bytesWritten() - offset;
+ size_t objSize = fWriter.bytesWritten() - offset;
// record the obj's size
- fWriter.write32At(offset - sizeof(uint32_t), objSize);
+ fWriter.write32At(offset - sizeof(uint32_t), SkToU32(objSize));
}