| 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 #include "SkPaint.h" | 9 #include "SkPaint.h" |
| 10 #include "SkAnnotation.h" | 10 #include "SkAnnotation.h" |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 return 0; | 529 return 0; |
| 530 } | 530 } |
| 531 | 531 |
| 532 SkASSERT(textData != NULL); | 532 SkASSERT(textData != NULL); |
| 533 | 533 |
| 534 if (NULL == glyphs) { | 534 if (NULL == glyphs) { |
| 535 switch (this->getTextEncoding()) { | 535 switch (this->getTextEncoding()) { |
| 536 case kUTF8_TextEncoding: | 536 case kUTF8_TextEncoding: |
| 537 return SkUTF8_CountUnichars((const char*)textData, byteLength); | 537 return SkUTF8_CountUnichars((const char*)textData, byteLength); |
| 538 case kUTF16_TextEncoding: | 538 case kUTF16_TextEncoding: |
| 539 return SkUTF16_CountUnichars((const uint16_t*)textData, | 539 return SkUTF16_CountUnichars((const uint16_t*)textData, SkToInt(byte
Length >> 1)); |
| 540 byteLength >> 1); | |
| 541 case kUTF32_TextEncoding: | 540 case kUTF32_TextEncoding: |
| 542 return byteLength >> 2; | 541 return SkToInt(byteLength >> 2); |
| 543 case kGlyphID_TextEncoding: | 542 case kGlyphID_TextEncoding: |
| 544 return byteLength >> 1; | 543 return SkToInt(byteLength >> 1); |
| 545 default: | 544 default: |
| 546 SkDEBUGFAIL("unknown text encoding"); | 545 SkDEBUGFAIL("unknown text encoding"); |
| 547 } | 546 } |
| 548 return 0; | 547 return 0; |
| 549 } | 548 } |
| 550 | 549 |
| 551 // if we get here, we have a valid glyphs[] array, so time to fill it in | 550 // if we get here, we have a valid glyphs[] array, so time to fill it in |
| 552 | 551 |
| 553 // handle this encoding before the setup for the glyphcache | 552 // handle this encoding before the setup for the glyphcache |
| 554 if (this->getTextEncoding() == kGlyphID_TextEncoding) { | 553 if (this->getTextEncoding() == kGlyphID_TextEncoding) { |
| 555 // we want to ignore the low bit of byteLength | 554 // we want to ignore the low bit of byteLength |
| 556 memcpy(glyphs, textData, byteLength >> 1 << 1); | 555 memcpy(glyphs, textData, byteLength >> 1 << 1); |
| 557 return byteLength >> 1; | 556 return SkToInt(byteLength >> 1); |
| 558 } | 557 } |
| 559 | 558 |
| 560 SkAutoGlyphCache autoCache(*this, NULL, NULL); | 559 SkAutoGlyphCache autoCache(*this, NULL, NULL); |
| 561 SkGlyphCache* cache = autoCache.getCache(); | 560 SkGlyphCache* cache = autoCache.getCache(); |
| 562 | 561 |
| 563 const char* text = (const char*)textData; | 562 const char* text = (const char*)textData; |
| 564 const char* stop = text + byteLength; | 563 const char* stop = text + byteLength; |
| 565 uint16_t* gptr = glyphs; | 564 uint16_t* gptr = glyphs; |
| 566 | 565 |
| 567 switch (this->getTextEncoding()) { | 566 switch (this->getTextEncoding()) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 582 const int32_t* text32 = (const int32_t*)text; | 581 const int32_t* text32 = (const int32_t*)text; |
| 583 const int32_t* stop32 = (const int32_t*)stop; | 582 const int32_t* stop32 = (const int32_t*)stop; |
| 584 while (text32 < stop32) { | 583 while (text32 < stop32) { |
| 585 *gptr++ = cache->unicharToGlyph(*text32++); | 584 *gptr++ = cache->unicharToGlyph(*text32++); |
| 586 } | 585 } |
| 587 break; | 586 break; |
| 588 } | 587 } |
| 589 default: | 588 default: |
| 590 SkDEBUGFAIL("unknown text encoding"); | 589 SkDEBUGFAIL("unknown text encoding"); |
| 591 } | 590 } |
| 592 return gptr - glyphs; | 591 return SkToInt(gptr - glyphs); |
| 593 } | 592 } |
| 594 | 593 |
| 595 bool SkPaint::containsText(const void* textData, size_t byteLength) const { | 594 bool SkPaint::containsText(const void* textData, size_t byteLength) const { |
| 596 if (0 == byteLength) { | 595 if (0 == byteLength) { |
| 597 return true; | 596 return true; |
| 598 } | 597 } |
| 599 | 598 |
| 600 SkASSERT(textData != NULL); | 599 SkASSERT(textData != NULL); |
| 601 | 600 |
| 602 // handle this encoding before the setup for the glyphcache | 601 // handle this encoding before the setup for the glyphcache |
| (...skipping 2125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2728 } | 2727 } |
| 2729 #ifdef SK_BUILD_FOR_ANDROID | 2728 #ifdef SK_BUILD_FOR_ANDROID |
| 2730 if (dirty & kPaintOptionsAndroid_DirtyBit) { | 2729 if (dirty & kPaintOptionsAndroid_DirtyBit) { |
| 2731 SkPaintOptionsAndroid options; | 2730 SkPaintOptionsAndroid options; |
| 2732 options.unflatten(buffer); | 2731 options.unflatten(buffer); |
| 2733 paint->setPaintOptionsAndroid(options); | 2732 paint->setPaintOptionsAndroid(options); |
| 2734 } | 2733 } |
| 2735 #endif | 2734 #endif |
| 2736 SkASSERT(dirty == paint->fDirtyBits); | 2735 SkASSERT(dirty == paint->fDirtyBits); |
| 2737 } | 2736 } |
| OLD | NEW |