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

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: fix xps change 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
« no previous file with comments | « include/core/SkMaskFilter.h ('k') | src/core/SkMaskFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 if (paint.getRasterizer()) { 985 if (paint.getRasterizer()) {
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)) {
997 return; // filterRRect() called the blitter, so we're done 996 return; // filterRRect() called the blitter, so we're done
998 } 997 }
999 } 998 }
1000 } 999 }
1001 1000
1002 DRAW_PATH: 1001 DRAW_PATH:
1003 // Now fall back to the default case of using a path. 1002 // Now fall back to the default case of using a path.
1004 SkPath path; 1003 SkPath path;
1005 path.addRRect(rrect); 1004 path.addRRect(rrect);
1006 this->drawPath(path, paint, nullptr, true); 1005 this->drawPath(path, paint, nullptr, true);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 SkBlitter* blitter = nullptr; 1109 SkBlitter* blitter = nullptr;
1111 SkAutoBlitterChoose blitterStorage; 1110 SkAutoBlitterChoose blitterStorage;
1112 if (nullptr == customBlitter) { 1111 if (nullptr == customBlitter) {
1113 blitterStorage.choose(fDst, *fMatrix, *paint, drawCoverage); 1112 blitterStorage.choose(fDst, *fMatrix, *paint, drawCoverage);
1114 blitter = blitterStorage.get(); 1113 blitter = blitterStorage.get();
1115 } else { 1114 } else {
1116 blitter = customBlitter; 1115 blitter = customBlitter;
1117 } 1116 }
1118 1117
1119 if (paint->getMaskFilter()) { 1118 if (paint->getMaskFilter()) {
1120 SkPaint::Style style = doFill ? SkPaint::kFill_Style : 1119 SkStrokeRec::InitStyle style = doFill ? SkStrokeRec::kFill_InitStyle
1121 SkPaint::kStroke_Style; 1120 : SkStrokeRec::kHairline_InitStyle ;
1122 if (paint->getMaskFilter()->filterPath(*devPathPtr, *fMatrix, *fRC, blit ter, style)) { 1121 if (paint->getMaskFilter()->filterPath(*devPathPtr, *fMatrix, *fRC, blit ter, style)) {
1123 return; // filterPath() called the blitter, so we're done 1122 return; // filterPath() called the blitter, so we're done
1124 } 1123 }
1125 } 1124 }
1126 1125
1127 void (*proc)(const SkPath&, const SkRasterClip&, SkBlitter*); 1126 void (*proc)(const SkPath&, const SkRasterClip&, SkBlitter*);
1128 if (doFill) { 1127 if (doFill) {
1129 if (paint->isAntiAlias()) { 1128 if (paint->isAntiAlias()) {
1130 proc = SkScan::AntiFillPath; 1129 proc = SkScan::AntiFillPath;
1131 } else { 1130 } else {
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
2018 static const int MAX_MARGIN = 128; 2017 static const int MAX_MARGIN = 128;
2019 if (!bounds->intersect(clipBounds->makeOutset(SkMin32(margin.fX, MAX_MAR GIN), 2018 if (!bounds->intersect(clipBounds->makeOutset(SkMin32(margin.fX, MAX_MAR GIN),
2020 SkMin32(margin.fY, MAX_MAR GIN)))) { 2019 SkMin32(margin.fY, MAX_MAR GIN)))) {
2021 return false; 2020 return false;
2022 } 2021 }
2023 } 2022 }
2024 2023
2025 return true; 2024 return true;
2026 } 2025 }
2027 2026
2028 static void draw_into_mask(const SkMask& mask, const SkPath& devPath, SkPaint::S tyle style) { 2027 static void draw_into_mask(const SkMask& mask, const SkPath& devPath,
2028 SkStrokeRec::InitStyle style) {
2029 SkDraw draw; 2029 SkDraw draw;
2030 if (!draw.fDst.reset(mask)) { 2030 if (!draw.fDst.reset(mask)) {
2031 return; 2031 return;
2032 } 2032 }
2033 2033
2034 SkRasterClip clip; 2034 SkRasterClip clip;
2035 SkMatrix matrix; 2035 SkMatrix matrix;
2036 SkPaint paint; 2036 SkPaint paint;
2037 2037
2038 clip.setRect(SkIRect::MakeWH(mask.fBounds.width(), mask.fBounds.height())); 2038 clip.setRect(SkIRect::MakeWH(mask.fBounds.width(), mask.fBounds.height()));
2039 matrix.setTranslate(-SkIntToScalar(mask.fBounds.fLeft), 2039 matrix.setTranslate(-SkIntToScalar(mask.fBounds.fLeft),
2040 -SkIntToScalar(mask.fBounds.fTop)); 2040 -SkIntToScalar(mask.fBounds.fTop));
2041 2041
2042 draw.fRC = &clip; 2042 draw.fRC = &clip;
2043 draw.fMatrix = &matrix; 2043 draw.fMatrix = &matrix;
2044 paint.setAntiAlias(true); 2044 paint.setAntiAlias(true);
2045 paint.setStyle(style); 2045 switch (style) {
2046 case SkStrokeRec::kHairline_InitStyle:
2047 SkASSERT(!paint.getStrokeWidth());
2048 paint.setStyle(SkPaint::kStroke_Style);
2049 break;
2050 case SkStrokeRec::kFill_InitStyle:
2051 SkASSERT(paint.getStyle() == SkPaint::kFill_Style);
2052 break;
2053
2054 }
2046 draw.drawPath(devPath, paint); 2055 draw.drawPath(devPath, paint);
2047 } 2056 }
2048 2057
2049 bool SkDraw::DrawToMask(const SkPath& devPath, const SkIRect* clipBounds, 2058 bool SkDraw::DrawToMask(const SkPath& devPath, const SkIRect* clipBounds,
2050 const SkMaskFilter* filter, const SkMatrix* filterMatrix , 2059 const SkMaskFilter* filter, const SkMatrix* filterMatrix ,
2051 SkMask* mask, SkMask::CreateMode mode, 2060 SkMask* mask, SkMask::CreateMode mode,
2052 SkPaint::Style style) { 2061 SkStrokeRec::InitStyle style) {
2053 if (SkMask::kJustRenderImage_CreateMode != mode) { 2062 if (SkMask::kJustRenderImage_CreateMode != mode) {
2054 if (!compute_bounds(devPath, clipBounds, filter, filterMatrix, &mask->fB ounds)) 2063 if (!compute_bounds(devPath, clipBounds, filter, filterMatrix, &mask->fB ounds))
2055 return false; 2064 return false;
2056 } 2065 }
2057 2066
2058 if (SkMask::kComputeBoundsAndRenderImage_CreateMode == mode) { 2067 if (SkMask::kComputeBoundsAndRenderImage_CreateMode == mode) {
2059 mask->fFormat = SkMask::kA8_Format; 2068 mask->fFormat = SkMask::kA8_Format;
2060 mask->fRowBytes = mask->fBounds.width(); 2069 mask->fRowBytes = mask->fBounds.width();
2061 size_t size = mask->computeImageSize(); 2070 size_t size = mask->computeImageSize();
2062 if (0 == size) { 2071 if (0 == size) {
2063 // we're too big to allocate the mask, abort 2072 // we're too big to allocate the mask, abort
2064 return false; 2073 return false;
2065 } 2074 }
2066 mask->fImage = SkMask::AllocImage(size); 2075 mask->fImage = SkMask::AllocImage(size);
2067 memset(mask->fImage, 0, mask->computeImageSize()); 2076 memset(mask->fImage, 0, mask->computeImageSize());
2068 } 2077 }
2069 2078
2070 if (SkMask::kJustComputeBounds_CreateMode != mode) { 2079 if (SkMask::kJustComputeBounds_CreateMode != mode) {
2071 draw_into_mask(*mask, devPath, style); 2080 draw_into_mask(*mask, devPath, style);
2072 } 2081 }
2073 2082
2074 return true; 2083 return true;
2075 } 2084 }
OLDNEW
« no previous file with comments | « include/core/SkMaskFilter.h ('k') | src/core/SkMaskFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698