OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkDraw.h" | 8 #include "SkDraw.h" |
9 #include "SkBlitter.h" | 9 #include "SkBlitter.h" |
10 #include "SkBounder.h" | 10 #include "SkBounder.h" |
(...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1209 } | 1209 } |
1210 | 1210 |
1211 // allocate (and clear) our temp buffer to hold the transformed bitmap | 1211 // allocate (and clear) our temp buffer to hold the transformed bitmap |
1212 SkAutoMalloc storage(size); | 1212 SkAutoMalloc storage(size); |
1213 mask.fImage = (uint8_t*)storage.get(); | 1213 mask.fImage = (uint8_t*)storage.get(); |
1214 memset(mask.fImage, 0, size); | 1214 memset(mask.fImage, 0, size); |
1215 | 1215 |
1216 // now draw our bitmap(src) into mask(dst), transformed by the matrix | 1216 // now draw our bitmap(src) into mask(dst), transformed by the matrix |
1217 { | 1217 { |
1218 SkBitmap device; | 1218 SkBitmap device; |
1219 device.setConfig(SkBitmap::kA8_Config, mask.fBounds.width(), | 1219 device.installPixels(SkImageInfo::MakeA8(mask.fBounds.width(), mask.
fBounds.height()), |
1220 mask.fBounds.height(), mask.fRowBytes); | 1220 mask.fImage, mask.fRowBytes); |
1221 device.setPixels(mask.fImage); | |
1222 | 1221 |
1223 SkCanvas c(device); | 1222 SkCanvas c(device); |
1224 // need the unclipped top/left for the translate | 1223 // need the unclipped top/left for the translate |
1225 c.translate(-SkIntToScalar(mask.fBounds.fLeft), | 1224 c.translate(-SkIntToScalar(mask.fBounds.fLeft), |
1226 -SkIntToScalar(mask.fBounds.fTop)); | 1225 -SkIntToScalar(mask.fBounds.fTop)); |
1227 c.concat(*fMatrix); | 1226 c.concat(*fMatrix); |
1228 | 1227 |
1229 // We can't call drawBitmap, or we'll infinitely recurse. Instead | 1228 // We can't call drawBitmap, or we'll infinitely recurse. Instead |
1230 // we manually build a shader and draw that into our new mask | 1229 // we manually build a shader and draw that into our new mask |
1231 SkPaint tmpPaint; | 1230 SkPaint tmpPaint; |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1659 } else { | 1658 } else { |
1660 return D1G_Bounder_AAClip; | 1659 return D1G_Bounder_AAClip; |
1661 } | 1660 } |
1662 } | 1661 } |
1663 } | 1662 } |
1664 | 1663 |
1665 void SkDraw1Glyph::blitMaskAsSprite(const SkMask& mask) const { | 1664 void SkDraw1Glyph::blitMaskAsSprite(const SkMask& mask) const { |
1666 SkASSERT(SkMask::kARGB32_Format == mask.fFormat); | 1665 SkASSERT(SkMask::kARGB32_Format == mask.fFormat); |
1667 | 1666 |
1668 SkBitmap bm; | 1667 SkBitmap bm; |
1669 bm.setConfig(SkBitmap::kARGB_8888_Config, | 1668 bm.installPixels(SkImageInfo::MakeN32Premul(mask.fBounds.width(), mask.fBoun
ds.height()), |
1670 mask.fBounds.width(), mask.fBounds.height(), mask.fRowBytes); | 1669 (SkPMColor*)mask.fImage, mask.fRowBytes); |
1671 bm.setPixels((SkPMColor*)mask.fImage); | |
1672 | 1670 |
1673 fDraw->drawSprite(bm, mask.fBounds.x(), mask.fBounds.y(), *fPaint); | 1671 fDraw->drawSprite(bm, mask.fBounds.x(), mask.fBounds.y(), *fPaint); |
1674 } | 1672 } |
1675 | 1673 |
1676 /////////////////////////////////////////////////////////////////////////////// | 1674 /////////////////////////////////////////////////////////////////////////////// |
1677 | 1675 |
1678 void SkDraw::drawText(const char text[], size_t byteLength, | 1676 void SkDraw::drawText(const char text[], size_t byteLength, |
1679 SkScalar x, SkScalar y, const SkPaint& paint) const { | 1677 SkScalar x, SkScalar y, const SkPaint& paint) const { |
1680 SkASSERT(byteLength == 0 || text != NULL); | 1678 SkASSERT(byteLength == 0 || text != NULL); |
1681 | 1679 |
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2666 } | 2664 } |
2667 | 2665 |
2668 static void draw_into_mask(const SkMask& mask, const SkPath& devPath, | 2666 static void draw_into_mask(const SkMask& mask, const SkPath& devPath, |
2669 SkPaint::Style style) { | 2667 SkPaint::Style style) { |
2670 SkBitmap bm; | 2668 SkBitmap bm; |
2671 SkDraw draw; | 2669 SkDraw draw; |
2672 SkRasterClip clip; | 2670 SkRasterClip clip; |
2673 SkMatrix matrix; | 2671 SkMatrix matrix; |
2674 SkPaint paint; | 2672 SkPaint paint; |
2675 | 2673 |
2676 bm.setConfig(SkBitmap::kA8_Config, mask.fBounds.width(), mask.fBounds.height
(), mask.fRowBytes); | 2674 bm.installPixels(SkImageInfo::MakeA8(mask.fBounds.width(), mask.fBounds.heig
ht()), |
2677 bm.setPixels(mask.fImage); | 2675 mask.fImage, mask.fRowBytes); |
2678 | 2676 |
2679 clip.setRect(SkIRect::MakeWH(mask.fBounds.width(), mask.fBounds.height())); | 2677 clip.setRect(SkIRect::MakeWH(mask.fBounds.width(), mask.fBounds.height())); |
2680 matrix.setTranslate(-SkIntToScalar(mask.fBounds.fLeft), | 2678 matrix.setTranslate(-SkIntToScalar(mask.fBounds.fLeft), |
2681 -SkIntToScalar(mask.fBounds.fTop)); | 2679 -SkIntToScalar(mask.fBounds.fTop)); |
2682 | 2680 |
2683 draw.fBitmap = &bm; | 2681 draw.fBitmap = &bm; |
2684 draw.fRC = &clip; | 2682 draw.fRC = &clip; |
2685 draw.fClip = &clip.bwRgn(); | 2683 draw.fClip = &clip.bwRgn(); |
2686 draw.fMatrix = &matrix; | 2684 draw.fMatrix = &matrix; |
2687 draw.fBounder = NULL; | 2685 draw.fBounder = NULL; |
(...skipping 22 matching lines...) Expand all Loading... |
2710 mask->fImage = SkMask::AllocImage(size); | 2708 mask->fImage = SkMask::AllocImage(size); |
2711 memset(mask->fImage, 0, mask->computeImageSize()); | 2709 memset(mask->fImage, 0, mask->computeImageSize()); |
2712 } | 2710 } |
2713 | 2711 |
2714 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2712 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
2715 draw_into_mask(*mask, devPath, style); | 2713 draw_into_mask(*mask, devPath, style); |
2716 } | 2714 } |
2717 | 2715 |
2718 return true; | 2716 return true; |
2719 } | 2717 } |
OLD | NEW |