Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: src/core/SkDraw.cpp

Issue 1955633002: Take SkStrokeRec::InitStyle rather than SkPaint::Style in mask filter and DrawMask (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 975 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 goto DRAW_PATH; 986 goto DRAW_PATH;
987 } 987 }
988 } 988 }
989 989
990 if (paint.getMaskFilter()) { 990 if (paint.getMaskFilter()) {
991 // Transform the rrect into device space. 991 // Transform the rrect into device space.
992 SkRRect devRRect; 992 SkRRect devRRect;
993 if (rrect.transform(*fMatrix, &devRRect)) { 993 if (rrect.transform(*fMatrix, &devRRect)) {
994 SkAutoBlitterChoose blitter(fDst, *fMatrix, paint); 994 SkAutoBlitterChoose blitter(fDst, *fMatrix, paint);
995 if (paint.getMaskFilter()->filterRRect(devRRect, *fMatrix, *fRC, bli tter.get(), 995 if (paint.getMaskFilter()->filterRRect(devRRect, *fMatrix, *fRC, bli tter.get(),
996 SkPaint::kFill_Style)) { 996 SkStrokeRec::kFill_InitStyle) ) {
997 return; // filterRRect() called the blitter, so we're done 997 return; // filterRRect() called the blitter, so we're done
998 } 998 }
999 } 999 }
1000 } 1000 }
1001 1001
1002 DRAW_PATH: 1002 DRAW_PATH:
1003 // Now fall back to the default case of using a path. 1003 // Now fall back to the default case of using a path.
1004 SkPath path; 1004 SkPath path;
1005 path.addRRect(rrect); 1005 path.addRRect(rrect);
1006 this->drawPath(path, paint, nullptr, true); 1006 this->drawPath(path, paint, nullptr, true);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 SkBlitter* blitter = nullptr; 1110 SkBlitter* blitter = nullptr;
1111 SkAutoBlitterChoose blitterStorage; 1111 SkAutoBlitterChoose blitterStorage;
1112 if (nullptr == customBlitter) { 1112 if (nullptr == customBlitter) {
1113 blitterStorage.choose(fDst, *fMatrix, *paint, drawCoverage); 1113 blitterStorage.choose(fDst, *fMatrix, *paint, drawCoverage);
1114 blitter = blitterStorage.get(); 1114 blitter = blitterStorage.get();
1115 } else { 1115 } else {
1116 blitter = customBlitter; 1116 blitter = customBlitter;
1117 } 1117 }
1118 1118
1119 if (paint->getMaskFilter()) { 1119 if (paint->getMaskFilter()) {
1120 SkPaint::Style style = doFill ? SkPaint::kFill_Style : 1120 SkStrokeRec::InitStyle style = doFill ? SkStrokeRec::kFill_InitStyle
1121 SkPaint::kStroke_Style; 1121 : SkStrokeRec::kHairline_InitStyle ;
1122 if (paint->getMaskFilter()->filterPath(*devPathPtr, *fMatrix, *fRC, blit ter, style)) { 1122 if (paint->getMaskFilter()->filterPath(*devPathPtr, *fMatrix, *fRC, blit ter, style)) {
1123 return; // filterPath() called the blitter, so we're done 1123 return; // filterPath() called the blitter, so we're done
1124 } 1124 }
1125 } 1125 }
1126 1126
1127 void (*proc)(const SkPath&, const SkRasterClip&, SkBlitter*); 1127 void (*proc)(const SkPath&, const SkRasterClip&, SkBlitter*);
1128 if (doFill) { 1128 if (doFill) {
1129 if (paint->isAntiAlias()) { 1129 if (paint->isAntiAlias()) {
1130 proc = SkScan::AntiFillPath; 1130 proc = SkScan::AntiFillPath;
1131 } else { 1131 } else {
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
2018 static const int MAX_MARGIN = 128; 2018 static const int MAX_MARGIN = 128;
2019 if (!bounds->intersect(clipBounds->makeOutset(SkMin32(margin.fX, MAX_MAR GIN), 2019 if (!bounds->intersect(clipBounds->makeOutset(SkMin32(margin.fX, MAX_MAR GIN),
2020 SkMin32(margin.fY, MAX_MAR GIN)))) { 2020 SkMin32(margin.fY, MAX_MAR GIN)))) {
2021 return false; 2021 return false;
2022 } 2022 }
2023 } 2023 }
2024 2024
2025 return true; 2025 return true;
2026 } 2026 }
2027 2027
2028 static void draw_into_mask(const SkMask& mask, const SkPath& devPath, SkPaint::S tyle style) { 2028 static void draw_into_mask(const SkMask& mask, const SkPath& devPath,
2029 SkStrokeRec::InitStyle style) {
2029 SkDraw draw; 2030 SkDraw draw;
2030 if (!draw.fDst.reset(mask)) { 2031 if (!draw.fDst.reset(mask)) {
2031 return; 2032 return;
2032 } 2033 }
2033 2034
2034 SkRasterClip clip; 2035 SkRasterClip clip;
2035 SkMatrix matrix; 2036 SkMatrix matrix;
2036 SkPaint paint; 2037 SkPaint paint;
2037 2038
2038 clip.setRect(SkIRect::MakeWH(mask.fBounds.width(), mask.fBounds.height())); 2039 clip.setRect(SkIRect::MakeWH(mask.fBounds.width(), mask.fBounds.height()));
2039 matrix.setTranslate(-SkIntToScalar(mask.fBounds.fLeft), 2040 matrix.setTranslate(-SkIntToScalar(mask.fBounds.fLeft),
2040 -SkIntToScalar(mask.fBounds.fTop)); 2041 -SkIntToScalar(mask.fBounds.fTop));
2041 2042
2042 draw.fRC = &clip; 2043 draw.fRC = &clip;
2043 draw.fMatrix = &matrix; 2044 draw.fMatrix = &matrix;
2044 paint.setAntiAlias(true); 2045 paint.setAntiAlias(true);
2045 paint.setStyle(style); 2046 switch (style) {
2047 case SkStrokeRec::kHairline_InitStyle:
robertphillips 2016/05/05 19:52:06 !paint.getStrokeWidth() ?
bsalomon 2016/05/05 20:15:16 Done.
2048 SkASSERT(paint.getStrokeWidth());
2049 paint.setStyle(SkPaint::kStroke_Style);
2050 break;
2051 case SkStrokeRec::kFill_InitStyle:
robertphillips 2016/05/05 19:52:06 xtra space ?
bsalomon 2016/05/05 20:15:16 Done. (actually other line is shy one space.)
2052 SkASSERT(paint.getStyle() == SkPaint::kFill_Style);
2053 break;
2054
2055 }
2046 draw.drawPath(devPath, paint); 2056 draw.drawPath(devPath, paint);
2047 } 2057 }
2048 2058
2049 bool SkDraw::DrawToMask(const SkPath& devPath, const SkIRect* clipBounds, 2059 bool SkDraw::DrawToMask(const SkPath& devPath, const SkIRect* clipBounds,
2050 const SkMaskFilter* filter, const SkMatrix* filterMatrix , 2060 const SkMaskFilter* filter, const SkMatrix* filterMatrix ,
2051 SkMask* mask, SkMask::CreateMode mode, 2061 SkMask* mask, SkMask::CreateMode mode,
2052 SkPaint::Style style) { 2062 SkStrokeRec::InitStyle style) {
2053 if (SkMask::kJustRenderImage_CreateMode != mode) { 2063 if (SkMask::kJustRenderImage_CreateMode != mode) {
2054 if (!compute_bounds(devPath, clipBounds, filter, filterMatrix, &mask->fB ounds)) 2064 if (!compute_bounds(devPath, clipBounds, filter, filterMatrix, &mask->fB ounds))
2055 return false; 2065 return false;
2056 } 2066 }
2057 2067
2058 if (SkMask::kComputeBoundsAndRenderImage_CreateMode == mode) { 2068 if (SkMask::kComputeBoundsAndRenderImage_CreateMode == mode) {
2059 mask->fFormat = SkMask::kA8_Format; 2069 mask->fFormat = SkMask::kA8_Format;
2060 mask->fRowBytes = mask->fBounds.width(); 2070 mask->fRowBytes = mask->fBounds.width();
2061 size_t size = mask->computeImageSize(); 2071 size_t size = mask->computeImageSize();
2062 if (0 == size) { 2072 if (0 == size) {
2063 // we're too big to allocate the mask, abort 2073 // we're too big to allocate the mask, abort
2064 return false; 2074 return false;
2065 } 2075 }
2066 mask->fImage = SkMask::AllocImage(size); 2076 mask->fImage = SkMask::AllocImage(size);
2067 memset(mask->fImage, 0, mask->computeImageSize()); 2077 memset(mask->fImage, 0, mask->computeImageSize());
2068 } 2078 }
2069 2079
2070 if (SkMask::kJustComputeBounds_CreateMode != mode) { 2080 if (SkMask::kJustComputeBounds_CreateMode != mode) {
2071 draw_into_mask(*mask, devPath, style); 2081 draw_into_mask(*mask, devPath, style);
2072 } 2082 }
2073 2083
2074 return true; 2084 return true;
2075 } 2085 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698