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 #define __STDC_LIMIT_MACROS | 7 #define __STDC_LIMIT_MACROS |
8 | 8 |
9 #include "SkDraw.h" | 9 #include "SkDraw.h" |
10 #include "SkBlitter.h" | 10 #include "SkBlitter.h" |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 int y = SkScalarFloorToInt(devPts[i].fY); | 374 int y = SkScalarFloorToInt(devPts[i].fY); |
375 if (rec.fClip->contains(x, y)) { | 375 if (rec.fClip->contains(x, y)) { |
376 blitter->blitH(x, y, 1); | 376 blitter->blitH(x, y, 1); |
377 } | 377 } |
378 } | 378 } |
379 } | 379 } |
380 | 380 |
381 static void bw_line_hair_proc(const PtProcRec& rec, const SkPoint devPts[], | 381 static void bw_line_hair_proc(const PtProcRec& rec, const SkPoint devPts[], |
382 int count, SkBlitter* blitter) { | 382 int count, SkBlitter* blitter) { |
383 for (int i = 0; i < count; i += 2) { | 383 for (int i = 0; i < count; i += 2) { |
384 SkScan::HairLine(devPts[i], devPts[i+1], *rec.fRC, blitter); | 384 SkScan::HairLine(&devPts[i], 2, *rec.fRC, blitter); |
385 } | 385 } |
386 } | 386 } |
387 | 387 |
388 static void bw_poly_hair_proc(const PtProcRec& rec, const SkPoint devPts[], | 388 static void bw_poly_hair_proc(const PtProcRec& rec, const SkPoint devPts[], |
389 int count, SkBlitter* blitter) { | 389 int count, SkBlitter* blitter) { |
390 for (int i = 0; i < count - 1; i++) { | 390 SkScan::HairLine(devPts, count, *rec.fRC, blitter); |
391 SkScan::HairLine(devPts[i], devPts[i+1], *rec.fRC, blitter); | |
392 } | |
393 } | 391 } |
394 | 392 |
395 // aa versions | 393 // aa versions |
396 | 394 |
397 static void aa_line_hair_proc(const PtProcRec& rec, const SkPoint devPts[], | 395 static void aa_line_hair_proc(const PtProcRec& rec, const SkPoint devPts[], |
398 int count, SkBlitter* blitter) { | 396 int count, SkBlitter* blitter) { |
399 for (int i = 0; i < count; i += 2) { | 397 for (int i = 0; i < count; i += 2) { |
400 SkScan::AntiHairLine(devPts[i], devPts[i+1], *rec.fRC, blitter); | 398 SkScan::AntiHairLine(&devPts[i], 2, *rec.fRC, blitter); |
401 } | 399 } |
402 } | 400 } |
403 | 401 |
404 static void aa_poly_hair_proc(const PtProcRec& rec, const SkPoint devPts[], | 402 static void aa_poly_hair_proc(const PtProcRec& rec, const SkPoint devPts[], |
405 int count, SkBlitter* blitter) { | 403 int count, SkBlitter* blitter) { |
406 for (int i = 0; i < count - 1; i++) { | 404 SkScan::AntiHairLine(devPts, count, *rec.fRC, blitter); |
407 SkScan::AntiHairLine(devPts[i], devPts[i+1], *rec.fRC, blitter); | |
408 } | |
409 } | 405 } |
410 | 406 |
411 // square procs (strokeWidth > 0 but matrix is square-scale (sx == sy) | 407 // square procs (strokeWidth > 0 but matrix is square-scale (sx == sy) |
412 | 408 |
413 static void bw_square_proc(const PtProcRec& rec, const SkPoint devPts[], | 409 static void bw_square_proc(const PtProcRec& rec, const SkPoint devPts[], |
414 int count, SkBlitter* blitter) { | 410 int count, SkBlitter* blitter) { |
415 const SkFixed radius = rec.fRadius; | 411 const SkFixed radius = rec.fRadius; |
416 for (int i = 0; i < count; i++) { | 412 for (int i = 0; i < count; i++) { |
417 SkFixed x = SkScalarToFixed(devPts[i].fX); | 413 SkFixed x = SkScalarToFixed(devPts[i].fX); |
418 SkFixed y = SkScalarToFixed(devPts[i].fY); | 414 SkFixed y = SkScalarToFixed(devPts[i].fY); |
(...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1869 } | 1865 } |
1870 } | 1866 } |
1871 } | 1867 } |
1872 | 1868 |
1873 #if defined _WIN32 && _MSC_VER >= 1300 | 1869 #if defined _WIN32 && _MSC_VER >= 1300 |
1874 #pragma warning ( pop ) | 1870 #pragma warning ( pop ) |
1875 #endif | 1871 #endif |
1876 | 1872 |
1877 /////////////////////////////////////////////////////////////////////////////// | 1873 /////////////////////////////////////////////////////////////////////////////// |
1878 | 1874 |
1879 typedef void (*HairProc)(SkPoint, SkPoint, const SkRasterClip&, SkBlitter*); | 1875 static SkScan::HairRCProc ChooseHairProc(bool doAntiAlias) { |
1880 | |
1881 static HairProc ChooseHairProc(bool doAntiAlias) { | |
1882 return doAntiAlias ? SkScan::AntiHairLine : SkScan::HairLine; | 1876 return doAntiAlias ? SkScan::AntiHairLine : SkScan::HairLine; |
1883 } | 1877 } |
1884 | 1878 |
1885 static bool texture_to_matrix(const VertState& state, const SkPoint verts[], | 1879 static bool texture_to_matrix(const VertState& state, const SkPoint verts[], |
1886 const SkPoint texs[], SkMatrix* matrix) { | 1880 const SkPoint texs[], SkMatrix* matrix) { |
1887 SkPoint src[3], dst[3]; | 1881 SkPoint src[3], dst[3]; |
1888 | 1882 |
1889 src[0] = texs[state.f0]; | 1883 src[0] = texs[state.f0]; |
1890 src[1] = texs[state.f1]; | 1884 src[1] = texs[state.f1]; |
1891 src[2] = texs[state.f2]; | 1885 src[2] = texs[state.f2]; |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2137 } | 2131 } |
2138 } | 2132 } |
2139 | 2133 |
2140 SkPoint tmp[] = { | 2134 SkPoint tmp[] = { |
2141 devVerts[state.f0], devVerts[state.f1], devVerts[state.f2] | 2135 devVerts[state.f0], devVerts[state.f1], devVerts[state.f2] |
2142 }; | 2136 }; |
2143 SkScan::FillTriangle(tmp, *fRC, blitter.get()); | 2137 SkScan::FillTriangle(tmp, *fRC, blitter.get()); |
2144 } | 2138 } |
2145 } else { | 2139 } else { |
2146 // no colors[] and no texture, stroke hairlines with paint's color. | 2140 // no colors[] and no texture, stroke hairlines with paint's color. |
2147 HairProc hairProc = ChooseHairProc(paint.isAntiAlias()); | 2141 SkScan::HairRCProc hairProc = ChooseHairProc(paint.isAntiAlias()); |
2148 const SkRasterClip& clip = *fRC; | 2142 const SkRasterClip& clip = *fRC; |
2149 while (vertProc(&state)) { | 2143 while (vertProc(&state)) { |
2150 hairProc(devVerts[state.f0], devVerts[state.f1], clip, blitter.get()
); | 2144 SkPoint array[] = { |
2151 hairProc(devVerts[state.f1], devVerts[state.f2], clip, blitter.get()
); | 2145 devVerts[state.f0], devVerts[state.f1], devVerts[state.f2], devV
erts[state.f0] |
2152 hairProc(devVerts[state.f2], devVerts[state.f0], clip, blitter.get()
); | 2146 }; |
| 2147 hairProc(array, 4, clip, blitter.get()); |
2153 } | 2148 } |
2154 } | 2149 } |
2155 } | 2150 } |
2156 | 2151 |
2157 /////////////////////////////////////////////////////////////////////////////// | 2152 /////////////////////////////////////////////////////////////////////////////// |
2158 /////////////////////////////////////////////////////////////////////////////// | 2153 /////////////////////////////////////////////////////////////////////////////// |
2159 | 2154 |
2160 #ifdef SK_DEBUG | 2155 #ifdef SK_DEBUG |
2161 | 2156 |
2162 void SkDraw::validate() const { | 2157 void SkDraw::validate() const { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2268 mask->fImage = SkMask::AllocImage(size); | 2263 mask->fImage = SkMask::AllocImage(size); |
2269 memset(mask->fImage, 0, mask->computeImageSize()); | 2264 memset(mask->fImage, 0, mask->computeImageSize()); |
2270 } | 2265 } |
2271 | 2266 |
2272 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2267 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
2273 draw_into_mask(*mask, devPath, style); | 2268 draw_into_mask(*mask, devPath, style); |
2274 } | 2269 } |
2275 | 2270 |
2276 return true; | 2271 return true; |
2277 } | 2272 } |
OLD | NEW |