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 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 int srcW = mask.fBounds.width(); | 577 int srcW = mask.fBounds.width(); |
578 int srcH = mask.fBounds.height(); | 578 int srcH = mask.fBounds.height(); |
579 int dstW = srcW; | 579 int dstW = srcW; |
580 int dstH = srcH; | 580 int dstH = srcH; |
581 int dstRB = mask.fRowBytes; | 581 int dstRB = mask.fRowBytes; |
582 | 582 |
583 SkMatrix matrix; | 583 SkMatrix matrix; |
584 matrix.setTranslate(-SkIntToScalar(mask.fBounds.fLeft), | 584 matrix.setTranslate(-SkIntToScalar(mask.fBounds.fLeft), |
585 -SkIntToScalar(mask.fBounds.fTop)); | 585 -SkIntToScalar(mask.fBounds.fTop)); |
586 | 586 |
587 SkBitmap::Config config = SkBitmap::kA8_Config; | |
588 paint.setAntiAlias(SkMask::kBW_Format != mask.fFormat); | 587 paint.setAntiAlias(SkMask::kBW_Format != mask.fFormat); |
589 switch (mask.fFormat) { | 588 switch (mask.fFormat) { |
590 case SkMask::kBW_Format: | 589 case SkMask::kBW_Format: |
591 dstRB = 0; // signals we need a copy | 590 dstRB = 0; // signals we need a copy |
592 break; | 591 break; |
593 case SkMask::kA8_Format: | 592 case SkMask::kA8_Format: |
594 break; | 593 break; |
595 case SkMask::kLCD16_Format: | 594 case SkMask::kLCD16_Format: |
596 case SkMask::kLCD32_Format: | 595 case SkMask::kLCD32_Format: |
597 // TODO: trigger off LCD orientation | 596 // TODO: trigger off LCD orientation |
598 dstW = 4*dstW - 8; | 597 dstW = 4*dstW - 8; |
599 matrix.setTranslate(-SkIntToScalar(mask.fBounds.fLeft + 1), | 598 matrix.setTranslate(-SkIntToScalar(mask.fBounds.fLeft + 1), |
600 -SkIntToScalar(mask.fBounds.fTop)); | 599 -SkIntToScalar(mask.fBounds.fTop)); |
601 matrix.postScale(SkIntToScalar(4), SK_Scalar1); | 600 matrix.postScale(SkIntToScalar(4), SK_Scalar1); |
602 dstRB = 0; // signals we need a copy | 601 dstRB = 0; // signals we need a copy |
603 break; | 602 break; |
604 default: | 603 default: |
605 SkDEBUGFAIL("unexpected mask format"); | 604 SkDEBUGFAIL("unexpected mask format"); |
606 } | 605 } |
607 | 606 |
608 SkRasterClip clip; | 607 SkRasterClip clip; |
609 clip.setRect(SkIRect::MakeWH(dstW, dstH)); | 608 clip.setRect(SkIRect::MakeWH(dstW, dstH)); |
610 | 609 |
| 610 const SkImageInfo info = SkImageInfo::MakeA8(dstW, dstH); |
611 SkBitmap bm; | 611 SkBitmap bm; |
612 bm.setConfig(config, dstW, dstH, dstRB); | |
613 | 612 |
614 if (0 == dstRB) { | 613 if (0 == dstRB) { |
615 if (!bm.allocPixels()) { | 614 if (!bm.allocPixels(info)) { |
616 // can't allocate offscreen, so empty the mask and return | 615 // can't allocate offscreen, so empty the mask and return |
617 sk_bzero(mask.fImage, mask.computeImageSize()); | 616 sk_bzero(mask.fImage, mask.computeImageSize()); |
618 return; | 617 return; |
619 } | 618 } |
620 bm.lockPixels(); | |
621 } else { | 619 } else { |
622 bm.setPixels(mask.fImage); | 620 bm.installPixels(info, mask.fImage, dstRB); |
623 } | 621 } |
624 sk_bzero(bm.getPixels(), bm.getSafeSize()); | 622 sk_bzero(bm.getPixels(), bm.getSafeSize()); |
625 | 623 |
626 SkDraw draw; | 624 SkDraw draw; |
627 draw.fRC = &clip; | 625 draw.fRC = &clip; |
628 draw.fClip = &clip.bwRgn(); | 626 draw.fClip = &clip.bwRgn(); |
629 draw.fMatrix = &matrix; | 627 draw.fMatrix = &matrix; |
630 draw.fBitmap = &bm; | 628 draw.fBitmap = &bm; |
631 draw.drawPath(path, paint); | 629 draw.drawPath(path, paint); |
632 | 630 |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 SkScalerContext* SkTypeface::createScalerContext(const SkDescriptor* desc, | 980 SkScalerContext* SkTypeface::createScalerContext(const SkDescriptor* desc, |
983 bool allowFailure) const { | 981 bool allowFailure) const { |
984 SkScalerContext* c = this->onCreateScalerContext(desc); | 982 SkScalerContext* c = this->onCreateScalerContext(desc); |
985 | 983 |
986 if (!c && !allowFailure) { | 984 if (!c && !allowFailure) { |
987 c = SkNEW_ARGS(SkScalerContext_Empty, | 985 c = SkNEW_ARGS(SkScalerContext_Empty, |
988 (const_cast<SkTypeface*>(this), desc)); | 986 (const_cast<SkTypeface*>(this), desc)); |
989 } | 987 } |
990 return c; | 988 return c; |
991 } | 989 } |
OLD | NEW |