epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2006 The Android Open Source Project |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
| 8 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 9 | |
| 10 | #include "SkMaskFilter.h" |
| 11 | #include "SkBlitter.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 12 | #include "SkDraw.h" |
reed | b0df8be | 2015-02-04 09:07:17 -0800 | [diff] [blame] | 13 | #include "SkCachedData.h" |
bungeman | d3ebb48 | 2015-08-05 13:57:49 -0700 | [diff] [blame^] | 14 | #include "SkPath.h" |
reed@google.com | 045e62d | 2011-10-24 12:19:46 +0000 | [diff] [blame] | 15 | #include "SkRasterClip.h" |
scroggo@google.com | a8e33a9 | 2013-11-08 18:02:53 +0000 | [diff] [blame] | 16 | #include "SkRRect.h" |
robertphillips@google.com | 4914931 | 2013-07-03 15:34:35 +0000 | [diff] [blame] | 17 | #include "SkTypes.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 18 | |
robertphillips@google.com | 0b82852 | 2013-07-03 15:49:05 +0000 | [diff] [blame] | 19 | #if SK_SUPPORT_GPU |
| 20 | #include "GrTexture.h" |
| 21 | #include "SkGr.h" |
| 22 | #include "SkGrPixelRef.h" |
| 23 | #endif |
reed@google.com | d729b3e | 2012-11-09 14:30:48 +0000 | [diff] [blame] | 24 | |
reed | b0df8be | 2015-02-04 09:07:17 -0800 | [diff] [blame] | 25 | SkMaskFilter::NinePatch::~NinePatch() { |
| 26 | if (fCache) { |
| 27 | SkASSERT((const void*)fMask.fImage == fCache->data()); |
| 28 | fCache->unref(); |
| 29 | } else { |
| 30 | SkMask::FreeImage(fMask.fImage); |
| 31 | } |
| 32 | } |
| 33 | |
reed@google.com | feb8cc8 | 2011-04-19 20:11:25 +0000 | [diff] [blame] | 34 | bool SkMaskFilter::filterMask(SkMask*, const SkMask&, const SkMatrix&, |
reed@google.com | 30711b7 | 2012-12-18 19:18:39 +0000 | [diff] [blame] | 35 | SkIPoint*) const { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 36 | return false; |
| 37 | } |
| 38 | |
reed@google.com | daaafa6 | 2014-04-29 15:20:16 +0000 | [diff] [blame] | 39 | bool SkMaskFilter::asABlur(BlurRec*) const { |
| 40 | return false; |
| 41 | } |
| 42 | |
reed@google.com | d729b3e | 2012-11-09 14:30:48 +0000 | [diff] [blame] | 43 | static void extractMaskSubset(const SkMask& src, SkMask* dst) { |
| 44 | SkASSERT(src.fBounds.contains(dst->fBounds)); |
| 45 | |
| 46 | const int dx = dst->fBounds.left() - src.fBounds.left(); |
| 47 | const int dy = dst->fBounds.top() - src.fBounds.top(); |
| 48 | dst->fImage = src.fImage + dy * src.fRowBytes + dx; |
| 49 | dst->fRowBytes = src.fRowBytes; |
| 50 | dst->fFormat = src.fFormat; |
| 51 | } |
| 52 | |
| 53 | static void blitClippedMask(SkBlitter* blitter, const SkMask& mask, |
| 54 | const SkIRect& bounds, const SkIRect& clipR) { |
| 55 | SkIRect r; |
| 56 | if (r.intersect(bounds, clipR)) { |
| 57 | blitter->blitMask(mask, r); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | static void blitClippedRect(SkBlitter* blitter, const SkIRect& rect, const SkIRect& clipR) { |
| 62 | SkIRect r; |
| 63 | if (r.intersect(rect, clipR)) { |
| 64 | blitter->blitRect(r.left(), r.top(), r.width(), r.height()); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | #if 0 |
| 69 | static void dump(const SkMask& mask) { |
| 70 | for (int y = mask.fBounds.top(); y < mask.fBounds.bottom(); ++y) { |
| 71 | for (int x = mask.fBounds.left(); x < mask.fBounds.right(); ++x) { |
| 72 | SkDebugf("%02X", *mask.getAddr8(x, y)); |
| 73 | } |
| 74 | SkDebugf("\n"); |
| 75 | } |
| 76 | SkDebugf("\n"); |
| 77 | } |
| 78 | #endif |
| 79 | |
| 80 | static void draw_nine_clipped(const SkMask& mask, const SkIRect& outerR, |
reed@google.com | dab9b4f | 2012-11-19 16:45:14 +0000 | [diff] [blame] | 81 | const SkIPoint& center, bool fillCenter, |
reed@google.com | d729b3e | 2012-11-09 14:30:48 +0000 | [diff] [blame] | 82 | const SkIRect& clipR, SkBlitter* blitter) { |
reed@google.com | dab9b4f | 2012-11-19 16:45:14 +0000 | [diff] [blame] | 83 | int cx = center.x(); |
| 84 | int cy = center.y(); |
reed@google.com | d729b3e | 2012-11-09 14:30:48 +0000 | [diff] [blame] | 85 | SkMask m; |
skia.committer@gmail.com | 453995e | 2012-11-10 02:01:26 +0000 | [diff] [blame] | 86 | |
reed@google.com | d729b3e | 2012-11-09 14:30:48 +0000 | [diff] [blame] | 87 | // top-left |
| 88 | m.fBounds = mask.fBounds; |
| 89 | m.fBounds.fRight = cx; |
| 90 | m.fBounds.fBottom = cy; |
tomhudson@google.com | 3c0ecc5 | 2013-04-25 16:56:40 +0000 | [diff] [blame] | 91 | if (m.fBounds.width() > 0 && m.fBounds.height() > 0) { |
| 92 | extractMaskSubset(mask, &m); |
| 93 | m.fBounds.offsetTo(outerR.left(), outerR.top()); |
| 94 | blitClippedMask(blitter, m, m.fBounds, clipR); |
| 95 | } |
skia.committer@gmail.com | 453995e | 2012-11-10 02:01:26 +0000 | [diff] [blame] | 96 | |
reed@google.com | d729b3e | 2012-11-09 14:30:48 +0000 | [diff] [blame] | 97 | // top-right |
| 98 | m.fBounds = mask.fBounds; |
| 99 | m.fBounds.fLeft = cx + 1; |
| 100 | m.fBounds.fBottom = cy; |
tomhudson@google.com | 3c0ecc5 | 2013-04-25 16:56:40 +0000 | [diff] [blame] | 101 | if (m.fBounds.width() > 0 && m.fBounds.height() > 0) { |
| 102 | extractMaskSubset(mask, &m); |
| 103 | m.fBounds.offsetTo(outerR.right() - m.fBounds.width(), outerR.top()); |
| 104 | blitClippedMask(blitter, m, m.fBounds, clipR); |
| 105 | } |
skia.committer@gmail.com | 453995e | 2012-11-10 02:01:26 +0000 | [diff] [blame] | 106 | |
reed@google.com | d729b3e | 2012-11-09 14:30:48 +0000 | [diff] [blame] | 107 | // bottom-left |
| 108 | m.fBounds = mask.fBounds; |
| 109 | m.fBounds.fRight = cx; |
| 110 | m.fBounds.fTop = cy + 1; |
tomhudson@google.com | 3c0ecc5 | 2013-04-25 16:56:40 +0000 | [diff] [blame] | 111 | if (m.fBounds.width() > 0 && m.fBounds.height() > 0) { |
| 112 | extractMaskSubset(mask, &m); |
| 113 | m.fBounds.offsetTo(outerR.left(), outerR.bottom() - m.fBounds.height()); |
| 114 | blitClippedMask(blitter, m, m.fBounds, clipR); |
| 115 | } |
skia.committer@gmail.com | 453995e | 2012-11-10 02:01:26 +0000 | [diff] [blame] | 116 | |
reed@google.com | d729b3e | 2012-11-09 14:30:48 +0000 | [diff] [blame] | 117 | // bottom-right |
| 118 | m.fBounds = mask.fBounds; |
| 119 | m.fBounds.fLeft = cx + 1; |
| 120 | m.fBounds.fTop = cy + 1; |
tomhudson@google.com | 3c0ecc5 | 2013-04-25 16:56:40 +0000 | [diff] [blame] | 121 | if (m.fBounds.width() > 0 && m.fBounds.height() > 0) { |
| 122 | extractMaskSubset(mask, &m); |
| 123 | m.fBounds.offsetTo(outerR.right() - m.fBounds.width(), |
| 124 | outerR.bottom() - m.fBounds.height()); |
| 125 | blitClippedMask(blitter, m, m.fBounds, clipR); |
| 126 | } |
reed@google.com | d729b3e | 2012-11-09 14:30:48 +0000 | [diff] [blame] | 127 | |
| 128 | SkIRect innerR; |
| 129 | innerR.set(outerR.left() + cx - mask.fBounds.left(), |
| 130 | outerR.top() + cy - mask.fBounds.top(), |
| 131 | outerR.right() + (cx + 1 - mask.fBounds.right()), |
| 132 | outerR.bottom() + (cy + 1 - mask.fBounds.bottom())); |
reed@google.com | dab9b4f | 2012-11-19 16:45:14 +0000 | [diff] [blame] | 133 | if (fillCenter) { |
| 134 | blitClippedRect(blitter, innerR, clipR); |
| 135 | } |
reed@google.com | d729b3e | 2012-11-09 14:30:48 +0000 | [diff] [blame] | 136 | |
| 137 | const int innerW = innerR.width(); |
| 138 | size_t storageSize = (innerW + 1) * (sizeof(int16_t) + sizeof(uint8_t)); |
| 139 | SkAutoSMalloc<4*1024> storage(storageSize); |
| 140 | int16_t* runs = (int16_t*)storage.get(); |
| 141 | uint8_t* alpha = (uint8_t*)(runs + innerW + 1); |
| 142 | |
| 143 | SkIRect r; |
| 144 | // top |
| 145 | r.set(innerR.left(), outerR.top(), innerR.right(), innerR.top()); |
| 146 | if (r.intersect(clipR)) { |
| 147 | int startY = SkMax32(0, r.top() - outerR.top()); |
| 148 | int stopY = startY + r.height(); |
| 149 | int width = r.width(); |
| 150 | for (int y = startY; y < stopY; ++y) { |
| 151 | runs[0] = width; |
| 152 | runs[width] = 0; |
| 153 | alpha[0] = *mask.getAddr8(cx, mask.fBounds.top() + y); |
| 154 | blitter->blitAntiH(r.left(), outerR.top() + y, alpha, runs); |
| 155 | } |
| 156 | } |
| 157 | // bottom |
| 158 | r.set(innerR.left(), innerR.bottom(), innerR.right(), outerR.bottom()); |
| 159 | if (r.intersect(clipR)) { |
| 160 | int startY = outerR.bottom() - r.bottom(); |
| 161 | int stopY = startY + r.height(); |
| 162 | int width = r.width(); |
| 163 | for (int y = startY; y < stopY; ++y) { |
| 164 | runs[0] = width; |
| 165 | runs[width] = 0; |
| 166 | alpha[0] = *mask.getAddr8(cx, mask.fBounds.bottom() - y - 1); |
| 167 | blitter->blitAntiH(r.left(), outerR.bottom() - y - 1, alpha, runs); |
| 168 | } |
| 169 | } |
| 170 | // left |
| 171 | r.set(outerR.left(), innerR.top(), innerR.left(), innerR.bottom()); |
| 172 | if (r.intersect(clipR)) { |
| 173 | int startX = r.left() - outerR.left(); |
| 174 | int stopX = startX + r.width(); |
| 175 | int height = r.height(); |
| 176 | for (int x = startX; x < stopX; ++x) { |
| 177 | blitter->blitV(outerR.left() + x, r.top(), height, |
| 178 | *mask.getAddr8(mask.fBounds.left() + x, mask.fBounds.top() + cy)); |
| 179 | } |
| 180 | } |
| 181 | // right |
| 182 | r.set(innerR.right(), innerR.top(), outerR.right(), innerR.bottom()); |
| 183 | if (r.intersect(clipR)) { |
| 184 | int startX = outerR.right() - r.right(); |
| 185 | int stopX = startX + r.width(); |
| 186 | int height = r.height(); |
| 187 | for (int x = startX; x < stopX; ++x) { |
| 188 | blitter->blitV(outerR.right() - x - 1, r.top(), height, |
| 189 | *mask.getAddr8(mask.fBounds.right() - x - 1, mask.fBounds.top() + cy)); |
| 190 | } |
| 191 | } |
| 192 | } |
| 193 | |
reed | 868074b | 2014-06-03 10:53:59 -0700 | [diff] [blame] | 194 | static void draw_nine(const SkMask& mask, const SkIRect& outerR, const SkIPoint& center, |
| 195 | bool fillCenter, const SkRasterClip& clip, SkBlitter* blitter) { |
reed@google.com | d729b3e | 2012-11-09 14:30:48 +0000 | [diff] [blame] | 196 | // if we get here, we need to (possibly) resolve the clip and blitter |
| 197 | SkAAClipBlitterWrapper wrapper(clip, blitter); |
| 198 | blitter = wrapper.getBlitter(); |
skia.committer@gmail.com | 453995e | 2012-11-10 02:01:26 +0000 | [diff] [blame] | 199 | |
reed@google.com | d729b3e | 2012-11-09 14:30:48 +0000 | [diff] [blame] | 200 | SkRegion::Cliperator clipper(wrapper.getRgn(), outerR); |
skia.committer@gmail.com | 453995e | 2012-11-10 02:01:26 +0000 | [diff] [blame] | 201 | |
reed | 868074b | 2014-06-03 10:53:59 -0700 | [diff] [blame] | 202 | if (!clipper.done()) { |
reed@google.com | d729b3e | 2012-11-09 14:30:48 +0000 | [diff] [blame] | 203 | const SkIRect& cr = clipper.rect(); |
| 204 | do { |
reed@google.com | dab9b4f | 2012-11-19 16:45:14 +0000 | [diff] [blame] | 205 | draw_nine_clipped(mask, outerR, center, fillCenter, cr, blitter); |
reed@google.com | d729b3e | 2012-11-09 14:30:48 +0000 | [diff] [blame] | 206 | clipper.next(); |
| 207 | } while (!clipper.done()); |
| 208 | } |
| 209 | } |
| 210 | |
reed@google.com | dab9b4f | 2012-11-19 16:45:14 +0000 | [diff] [blame] | 211 | static int countNestedRects(const SkPath& path, SkRect rects[2]) { |
caryclark | 95bc5f3 | 2015-04-08 08:34:15 -0700 | [diff] [blame] | 212 | if (path.isNestedFillRects(rects)) { |
reed@google.com | dab9b4f | 2012-11-19 16:45:14 +0000 | [diff] [blame] | 213 | return 2; |
| 214 | } |
| 215 | return path.isRect(&rects[0]); |
| 216 | } |
| 217 | |
scroggo@google.com | a8e33a9 | 2013-11-08 18:02:53 +0000 | [diff] [blame] | 218 | bool SkMaskFilter::filterRRect(const SkRRect& devRRect, const SkMatrix& matrix, |
reed | 868074b | 2014-06-03 10:53:59 -0700 | [diff] [blame] | 219 | const SkRasterClip& clip, SkBlitter* blitter, |
| 220 | SkPaint::Style style) const { |
scroggo@google.com | a8e33a9 | 2013-11-08 18:02:53 +0000 | [diff] [blame] | 221 | // Attempt to speed up drawing by creating a nine patch. If a nine patch |
| 222 | // cannot be used, return false to allow our caller to recover and perform |
| 223 | // the drawing another way. |
| 224 | NinePatch patch; |
| 225 | patch.fMask.fImage = NULL; |
| 226 | if (kTrue_FilterReturn != this->filterRRectToNine(devRRect, matrix, |
| 227 | clip.getBounds(), |
| 228 | &patch)) { |
| 229 | SkASSERT(NULL == patch.fMask.fImage); |
| 230 | return false; |
| 231 | } |
reed | 868074b | 2014-06-03 10:53:59 -0700 | [diff] [blame] | 232 | draw_nine(patch.fMask, patch.fOuterRect, patch.fCenter, true, clip, blitter); |
scroggo@google.com | a8e33a9 | 2013-11-08 18:02:53 +0000 | [diff] [blame] | 233 | return true; |
| 234 | } |
| 235 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 236 | bool SkMaskFilter::filterPath(const SkPath& devPath, const SkMatrix& matrix, |
reed | 868074b | 2014-06-03 10:53:59 -0700 | [diff] [blame] | 237 | const SkRasterClip& clip, SkBlitter* blitter, |
| 238 | SkPaint::Style style) const { |
reed@google.com | dab9b4f | 2012-11-19 16:45:14 +0000 | [diff] [blame] | 239 | SkRect rects[2]; |
| 240 | int rectCount = 0; |
reed@google.com | 5f0add3 | 2012-11-26 16:47:10 +0000 | [diff] [blame] | 241 | if (SkPaint::kFill_Style == style) { |
reed@google.com | dab9b4f | 2012-11-19 16:45:14 +0000 | [diff] [blame] | 242 | rectCount = countNestedRects(devPath, rects); |
| 243 | } |
| 244 | if (rectCount > 0) { |
| 245 | NinePatch patch; |
reed@google.com | d729b3e | 2012-11-09 14:30:48 +0000 | [diff] [blame] | 246 | |
reed | b0df8be | 2015-02-04 09:07:17 -0800 | [diff] [blame] | 247 | switch (this->filterRectsToNine(rects, rectCount, matrix, clip.getBounds(), &patch)) { |
reed@google.com | d729b3e | 2012-11-09 14:30:48 +0000 | [diff] [blame] | 248 | case kFalse_FilterReturn: |
reed@google.com | dab9b4f | 2012-11-19 16:45:14 +0000 | [diff] [blame] | 249 | SkASSERT(NULL == patch.fMask.fImage); |
reed@google.com | d729b3e | 2012-11-09 14:30:48 +0000 | [diff] [blame] | 250 | return false; |
reed@google.com | dab9b4f | 2012-11-19 16:45:14 +0000 | [diff] [blame] | 251 | |
reed@google.com | d729b3e | 2012-11-09 14:30:48 +0000 | [diff] [blame] | 252 | case kTrue_FilterReturn: |
reed | 868074b | 2014-06-03 10:53:59 -0700 | [diff] [blame] | 253 | draw_nine(patch.fMask, patch.fOuterRect, patch.fCenter, 1 == rectCount, clip, |
| 254 | blitter); |
reed@google.com | d729b3e | 2012-11-09 14:30:48 +0000 | [diff] [blame] | 255 | return true; |
reed@google.com | dab9b4f | 2012-11-19 16:45:14 +0000 | [diff] [blame] | 256 | |
reed@google.com | d729b3e | 2012-11-09 14:30:48 +0000 | [diff] [blame] | 257 | case kUnimplemented_FilterReturn: |
reed@google.com | dab9b4f | 2012-11-19 16:45:14 +0000 | [diff] [blame] | 258 | SkASSERT(NULL == patch.fMask.fImage); |
reed@google.com | d729b3e | 2012-11-09 14:30:48 +0000 | [diff] [blame] | 259 | // fall through |
| 260 | break; |
| 261 | } |
| 262 | } |
| 263 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 264 | SkMask srcM, dstM; |
| 265 | |
| 266 | if (!SkDraw::DrawToMask(devPath, &clip.getBounds(), this, &matrix, &srcM, |
junov@chromium.org | 2ac4ef5 | 2012-04-04 15:16:51 +0000 | [diff] [blame] | 267 | SkMask::kComputeBoundsAndRenderImage_CreateMode, |
| 268 | style)) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 269 | return false; |
| 270 | } |
bungeman@google.com | 02f5584 | 2011-10-04 21:25:00 +0000 | [diff] [blame] | 271 | SkAutoMaskFreeImage autoSrc(srcM.fImage); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 272 | |
qiankun.miao | eabd0d7 | 2015-01-07 19:20:49 -0800 | [diff] [blame] | 273 | if (!this->filterMask(&dstM, srcM, matrix, NULL)) { |
| 274 | return false; |
reed@google.com | feb8cc8 | 2011-04-19 20:11:25 +0000 | [diff] [blame] | 275 | } |
bungeman@google.com | 02f5584 | 2011-10-04 21:25:00 +0000 | [diff] [blame] | 276 | SkAutoMaskFreeImage autoDst(dstM.fImage); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 277 | |
reed@google.com | 045e62d | 2011-10-24 12:19:46 +0000 | [diff] [blame] | 278 | // if we get here, we need to (possibly) resolve the clip and blitter |
| 279 | SkAAClipBlitterWrapper wrapper(clip, blitter); |
| 280 | blitter = wrapper.getBlitter(); |
| 281 | |
| 282 | SkRegion::Cliperator clipper(wrapper.getRgn(), dstM.fBounds); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 283 | |
reed | 868074b | 2014-06-03 10:53:59 -0700 | [diff] [blame] | 284 | if (!clipper.done()) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 285 | const SkIRect& cr = clipper.rect(); |
| 286 | do { |
| 287 | blitter->blitMask(dstM, cr); |
| 288 | clipper.next(); |
| 289 | } while (!clipper.done()); |
| 290 | } |
| 291 | |
| 292 | return true; |
| 293 | } |
| 294 | |
reed@google.com | d729b3e | 2012-11-09 14:30:48 +0000 | [diff] [blame] | 295 | SkMaskFilter::FilterReturn |
scroggo@google.com | a8e33a9 | 2013-11-08 18:02:53 +0000 | [diff] [blame] | 296 | SkMaskFilter::filterRRectToNine(const SkRRect&, const SkMatrix&, |
| 297 | const SkIRect& clipBounds, NinePatch*) const { |
| 298 | return kUnimplemented_FilterReturn; |
| 299 | } |
| 300 | |
| 301 | SkMaskFilter::FilterReturn |
reed@google.com | dab9b4f | 2012-11-19 16:45:14 +0000 | [diff] [blame] | 302 | SkMaskFilter::filterRectsToNine(const SkRect[], int count, const SkMatrix&, |
reed@google.com | 30711b7 | 2012-12-18 19:18:39 +0000 | [diff] [blame] | 303 | const SkIRect& clipBounds, NinePatch*) const { |
reed@google.com | d729b3e | 2012-11-09 14:30:48 +0000 | [diff] [blame] | 304 | return kUnimplemented_FilterReturn; |
| 305 | } |
| 306 | |
robertphillips@google.com | 0b82852 | 2013-07-03 15:49:05 +0000 | [diff] [blame] | 307 | #if SK_SUPPORT_GPU |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 308 | bool SkMaskFilter::asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&) const { |
robertphillips@google.com | 4914931 | 2013-07-03 15:34:35 +0000 | [diff] [blame] | 309 | return false; |
| 310 | } |
| 311 | |
skia.committer@gmail.com | 1842adf | 2013-07-04 07:01:07 +0000 | [diff] [blame] | 312 | bool SkMaskFilter::canFilterMaskGPU(const SkRect& devBounds, |
robertphillips@google.com | 4914931 | 2013-07-03 15:34:35 +0000 | [diff] [blame] | 313 | const SkIRect& clipBounds, |
| 314 | const SkMatrix& ctm, |
| 315 | SkRect* maskRect) const { |
| 316 | return false; |
| 317 | } |
| 318 | |
robertphillips | ff0ca5e | 2015-07-22 11:54:44 -0700 | [diff] [blame] | 319 | bool SkMaskFilter::directFilterMaskGPU(GrTextureProvider* texProvider, |
| 320 | GrDrawContext* drawContext, |
joshualitt | 25d9c15 | 2015-02-18 12:29:52 -0800 | [diff] [blame] | 321 | GrRenderTarget* rt, |
commit-bot@chromium.org | cf34bc0 | 2014-01-30 15:34:43 +0000 | [diff] [blame] | 322 | GrPaint* grp, |
joshualitt | 570d2f8 | 2015-02-25 13:19:48 -0800 | [diff] [blame] | 323 | const GrClip&, |
joshualitt | 5531d51 | 2014-12-17 15:50:11 -0800 | [diff] [blame] | 324 | const SkMatrix& viewMatrix, |
commit-bot@chromium.org | cf34bc0 | 2014-01-30 15:34:43 +0000 | [diff] [blame] | 325 | const SkStrokeRec& strokeRec, |
| 326 | const SkPath& path) const { |
| 327 | return false; |
| 328 | } |
| 329 | |
robertphillips@google.com | 4914931 | 2013-07-03 15:34:35 +0000 | [diff] [blame] | 330 | |
robertphillips | ff0ca5e | 2015-07-22 11:54:44 -0700 | [diff] [blame] | 331 | bool SkMaskFilter::directFilterRRectMaskGPU(GrTextureProvider* texProvider, |
| 332 | GrDrawContext* drawContext, |
joshualitt | 25d9c15 | 2015-02-18 12:29:52 -0800 | [diff] [blame] | 333 | GrRenderTarget* rt, |
commit-bot@chromium.org | 8213970 | 2014-03-10 22:53:20 +0000 | [diff] [blame] | 334 | GrPaint* grp, |
joshualitt | 570d2f8 | 2015-02-25 13:19:48 -0800 | [diff] [blame] | 335 | const GrClip&, |
joshualitt | 5531d51 | 2014-12-17 15:50:11 -0800 | [diff] [blame] | 336 | const SkMatrix& viewMatrix, |
commit-bot@chromium.org | 8213970 | 2014-03-10 22:53:20 +0000 | [diff] [blame] | 337 | const SkStrokeRec& strokeRec, |
| 338 | const SkRRect& rrect) const { |
| 339 | return false; |
| 340 | } |
| 341 | |
skia.committer@gmail.com | 1842adf | 2013-07-04 07:01:07 +0000 | [diff] [blame] | 342 | bool SkMaskFilter::filterMaskGPU(GrTexture* src, |
commit-bot@chromium.org | 41bf930 | 2014-01-08 22:25:53 +0000 | [diff] [blame] | 343 | const SkMatrix& ctm, |
skia.committer@gmail.com | 1842adf | 2013-07-04 07:01:07 +0000 | [diff] [blame] | 344 | const SkRect& maskRect, |
robertphillips@google.com | 4914931 | 2013-07-03 15:34:35 +0000 | [diff] [blame] | 345 | GrTexture** result, |
| 346 | bool canOverwriteSrc) const { |
| 347 | return false; |
reed@google.com | 2b75f42 | 2011-07-07 13:43:38 +0000 | [diff] [blame] | 348 | } |
robertphillips@google.com | 0b82852 | 2013-07-03 15:49:05 +0000 | [diff] [blame] | 349 | #endif |
reed@google.com | 2b75f42 | 2011-07-07 13:43:38 +0000 | [diff] [blame] | 350 | |
reed@google.com | 30711b7 | 2012-12-18 19:18:39 +0000 | [diff] [blame] | 351 | void SkMaskFilter::computeFastBounds(const SkRect& src, SkRect* dst) const { |
reed@google.com | 9efd9a0 | 2012-01-30 15:41:43 +0000 | [diff] [blame] | 352 | SkMask srcM, dstM; |
| 353 | |
| 354 | srcM.fImage = NULL; |
reed | b07a94f | 2014-11-19 05:03:18 -0800 | [diff] [blame] | 355 | srcM.fBounds = src.roundOut(); |
reed@google.com | 9efd9a0 | 2012-01-30 15:41:43 +0000 | [diff] [blame] | 356 | srcM.fRowBytes = 0; |
| 357 | srcM.fFormat = SkMask::kA8_Format; |
| 358 | |
| 359 | SkIPoint margin; // ignored |
| 360 | if (this->filterMask(&dstM, srcM, SkMatrix::I(), &margin)) { |
| 361 | dst->set(dstM.fBounds); |
| 362 | } else { |
| 363 | dst->set(srcM.fBounds); |
| 364 | } |
| 365 | } |