OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkScalerContext.h" | 10 #include "SkScalerContext.h" |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
541 static void packA8ToA1(const SkMask& mask, const uint8_t* src, size_t srcRB) { | 541 static void packA8ToA1(const SkMask& mask, const uint8_t* src, size_t srcRB) { |
542 const int height = mask.fBounds.height(); | 542 const int height = mask.fBounds.height(); |
543 const int width = mask.fBounds.width(); | 543 const int width = mask.fBounds.width(); |
544 const int octs = width >> 3; | 544 const int octs = width >> 3; |
545 const int leftOverBits = width & 7; | 545 const int leftOverBits = width & 7; |
546 | 546 |
547 uint8_t* dst = mask.fImage; | 547 uint8_t* dst = mask.fImage; |
548 const int dstPad = mask.fRowBytes - SkAlign8(width)/8; | 548 const int dstPad = mask.fRowBytes - SkAlign8(width)/8; |
549 SkASSERT(dstPad >= 0); | 549 SkASSERT(dstPad >= 0); |
550 | 550 |
551 const int srcPad = srcRB - width; | 551 SkASSERT(srcRB >= (size_t)width); |
mtklein
2014/04/23 13:36:18
Is it sensible to add in SkASSERT(width >= 0) here
reed1
2014/04/23 14:04:22
yes, width should be >= 0. Will add that assert.
| |
552 SkASSERT(srcPad >= 0); | 552 const size_t srcPad = srcRB - width; |
553 | 553 |
554 for (int y = 0; y < height; ++y) { | 554 for (int y = 0; y < height; ++y) { |
555 for (int i = 0; i < octs; ++i) { | 555 for (int i = 0; i < octs; ++i) { |
556 *dst++ = pack_8_to_1(src); | 556 *dst++ = pack_8_to_1(src); |
557 src += 8; | 557 src += 8; |
558 } | 558 } |
559 if (leftOverBits > 0) { | 559 if (leftOverBits > 0) { |
560 unsigned bits = 0; | 560 unsigned bits = 0; |
561 int shift = 7; | 561 int shift = 7; |
562 for (int i = 0; i < leftOverBits; ++i, --shift) { | 562 for (int i = 0; i < leftOverBits; ++i, --shift) { |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
981 SkScalerContext* SkTypeface::createScalerContext(const SkDescriptor* desc, | 981 SkScalerContext* SkTypeface::createScalerContext(const SkDescriptor* desc, |
982 bool allowFailure) const { | 982 bool allowFailure) const { |
983 SkScalerContext* c = this->onCreateScalerContext(desc); | 983 SkScalerContext* c = this->onCreateScalerContext(desc); |
984 | 984 |
985 if (!c && !allowFailure) { | 985 if (!c && !allowFailure) { |
986 c = SkNEW_ARGS(SkScalerContext_Empty, | 986 c = SkNEW_ARGS(SkScalerContext_Empty, |
987 (const_cast<SkTypeface*>(this), desc)); | 987 (const_cast<SkTypeface*>(this), desc)); |
988 } | 988 } |
989 return c; | 989 return c; |
990 } | 990 } |
OLD | NEW |