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