aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar herb <herb@google.com>2016-04-26 08:15:27 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-26 08:15:27 -0700
commit5d4943caae2ee8e2adc1152864304ba9903c2098 (patch)
tree73e9cacf9a924f8ea87016454af7ae414fad8a11 /src
parentb1b59576baf8abe457be159b13438b8668f8eeac (diff)
Add guards for edge cases.
Diffstat (limited to 'src')
-rw-r--r--src/core/SkBitmapProcShader.cpp1
-rw-r--r--src/core/SkLinearBitmapPipeline.cpp16
2 files changed, 10 insertions, 7 deletions
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index 3727bbca86..d230d147cb 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -225,6 +225,7 @@ private:
static bool choose_linear_pipeline(const SkShader::ContextRec& rec, const SkImageInfo& srcInfo) {
// These src attributes are not supported in the new 4f context (yet)
//
+ if (srcInfo.profileType() != kSRGB_SkColorProfileType) { return false; }
if (srcInfo.colorType() != kRGBA_8888_SkColorType
&& srcInfo.colorType() != kBGRA_8888_SkColorType
&& srcInfo.colorType() != kIndex_8_SkColorType
diff --git a/src/core/SkLinearBitmapPipeline.cpp b/src/core/SkLinearBitmapPipeline.cpp
index 415179a0b1..d9b4a8d504 100644
--- a/src/core/SkLinearBitmapPipeline.cpp
+++ b/src/core/SkLinearBitmapPipeline.cpp
@@ -584,18 +584,20 @@ public:
void pointSpan(Span span) override {
SkASSERT(fDest + span.count() <= fEnd);
- int32_t x = (int32_t)span.startX();
- int32_t y = (int32_t)span.startY();
- const uint32_t* src = this->pixelAddress(x, y);
- memmove(fDest, src, span.count() * sizeof(uint32_t));
- fDest += span.count();
+ if (span.length() != 0.0f) {
+ int32_t x = SkScalarTruncToInt(span.startX());
+ int32_t y = SkScalarTruncToInt(span.startY());
+ const uint32_t* src = this->pixelAddress(x, y);
+ memmove(fDest, src, span.count() * sizeof(uint32_t));
+ fDest += span.count();
+ }
}
void repeatSpan(Span span, int32_t repeatCount) override {
SkASSERT(fDest + span.count() * repeatCount <= fEnd);
- int32_t x = (int32_t)span.startX();
- int32_t y = (int32_t)span.startY();
+ int32_t x = SkScalarTruncToInt(span.startX());
+ int32_t y = SkScalarTruncToInt(span.startY());
const uint32_t* src = this->pixelAddress(x, y);
uint32_t* dest = fDest;
while (repeatCount --> 0) {