robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
Mike Reed | 986480a | 2017-01-13 22:43:16 +0000 | [diff] [blame] | 8 | #include "SkBitmapDevice.h" |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 9 | #include "SkDraw.h" |
reed | e51c356 | 2016-07-19 14:33:20 -0700 | [diff] [blame] | 10 | #include "SkImageFilter.h" |
senorblanco | 900c367 | 2016-04-27 11:31:23 -0700 | [diff] [blame] | 11 | #include "SkImageFilterCache.h" |
mtklein | cd49541 | 2015-11-05 09:46:23 -0800 | [diff] [blame] | 12 | #include "SkMallocPixelRef.h" |
bungeman | d3ebb48 | 2015-08-05 13:57:49 -0700 | [diff] [blame] | 13 | #include "SkMatrix.h" |
| 14 | #include "SkPaint.h" |
| 15 | #include "SkPath.h" |
reed | 884e97c | 2015-05-26 11:31:54 -0700 | [diff] [blame] | 16 | #include "SkPixelRef.h" |
bungeman | d3ebb48 | 2015-08-05 13:57:49 -0700 | [diff] [blame] | 17 | #include "SkPixmap.h" |
reed | e51c356 | 2016-07-19 14:33:20 -0700 | [diff] [blame] | 18 | #include "SkRasterClip.h" |
Mike Reed | 356f7c2 | 2017-01-10 11:58:39 -0500 | [diff] [blame] | 19 | #include "SkRasterHandleAllocator.h" |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 20 | #include "SkShader.h" |
reed | e51c356 | 2016-07-19 14:33:20 -0700 | [diff] [blame] | 21 | #include "SkSpecialImage.h" |
reed@google.com | 76f10a3 | 2014-02-05 15:32:21 +0000 | [diff] [blame] | 22 | #include "SkSurface.h" |
Mike Reed | 2f6b5a4 | 2017-03-19 15:04:17 -0400 | [diff] [blame] | 23 | #include "SkVertices.h" |
bungeman | d3ebb48 | 2015-08-05 13:57:49 -0700 | [diff] [blame] | 24 | |
| 25 | class SkColorTable; |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 26 | |
commit-bot@chromium.org | 15a1405 | 2014-02-16 00:59:25 +0000 | [diff] [blame] | 27 | static bool valid_for_bitmap_device(const SkImageInfo& info, |
| 28 | SkAlphaType* newAlphaType) { |
| 29 | if (info.width() < 0 || info.height() < 0) { |
| 30 | return false; |
| 31 | } |
| 32 | |
| 33 | // TODO: can we stop supporting kUnknown in SkBitmkapDevice? |
| 34 | if (kUnknown_SkColorType == info.colorType()) { |
| 35 | if (newAlphaType) { |
reed | 4497748 | 2015-02-27 10:23:00 -0800 | [diff] [blame] | 36 | *newAlphaType = kUnknown_SkAlphaType; |
commit-bot@chromium.org | 15a1405 | 2014-02-16 00:59:25 +0000 | [diff] [blame] | 37 | } |
| 38 | return true; |
| 39 | } |
skia.committer@gmail.com | 969588f | 2014-02-16 03:01:56 +0000 | [diff] [blame] | 40 | |
commit-bot@chromium.org | 15a1405 | 2014-02-16 00:59:25 +0000 | [diff] [blame] | 41 | switch (info.alphaType()) { |
| 42 | case kPremul_SkAlphaType: |
| 43 | case kOpaque_SkAlphaType: |
| 44 | break; |
| 45 | default: |
| 46 | return false; |
| 47 | } |
| 48 | |
| 49 | SkAlphaType canonicalAlphaType = info.alphaType(); |
| 50 | |
| 51 | switch (info.colorType()) { |
| 52 | case kAlpha_8_SkColorType: |
| 53 | break; |
| 54 | case kRGB_565_SkColorType: |
| 55 | canonicalAlphaType = kOpaque_SkAlphaType; |
| 56 | break; |
commit-bot@chromium.org | 28fcae2 | 2014-04-11 17:15:40 +0000 | [diff] [blame] | 57 | case kN32_SkColorType: |
commit-bot@chromium.org | 15a1405 | 2014-02-16 00:59:25 +0000 | [diff] [blame] | 58 | break; |
reed | a34be68 | 2016-02-15 07:48:35 -0800 | [diff] [blame] | 59 | case kRGBA_F16_SkColorType: |
| 60 | break; |
commit-bot@chromium.org | 15a1405 | 2014-02-16 00:59:25 +0000 | [diff] [blame] | 61 | default: |
| 62 | return false; |
| 63 | } |
| 64 | |
| 65 | if (newAlphaType) { |
| 66 | *newAlphaType = canonicalAlphaType; |
| 67 | } |
| 68 | return true; |
| 69 | } |
| 70 | |
robertphillips | 9a53fd7 | 2015-06-22 09:46:59 -0700 | [diff] [blame] | 71 | SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap) |
reed | 589a39e | 2016-08-20 07:59:19 -0700 | [diff] [blame] | 72 | : INHERITED(bitmap.info(), SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType)) |
reed | 2c9e200 | 2016-07-25 08:05:22 -0700 | [diff] [blame] | 73 | , fBitmap(bitmap) |
Mike Reed | c42a1cd | 2017-02-14 14:25:14 -0500 | [diff] [blame] | 74 | , fRCStack(bitmap.width(), bitmap.height()) |
reed | 2c9e200 | 2016-07-25 08:05:22 -0700 | [diff] [blame] | 75 | { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 76 | SkASSERT(valid_for_bitmap_device(bitmap.info(), nullptr)); |
reed | 2c9e200 | 2016-07-25 08:05:22 -0700 | [diff] [blame] | 77 | fBitmap.lockPixels(); |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 78 | } |
| 79 | |
robertphillips | 9a53fd7 | 2015-06-22 09:46:59 -0700 | [diff] [blame] | 80 | SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& info) { |
| 81 | return Create(info, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType)); |
| 82 | } |
| 83 | |
Mike Reed | 356f7c2 | 2017-01-10 11:58:39 -0500 | [diff] [blame] | 84 | SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkSurfaceProps& surfaceProps, |
| 85 | SkRasterHandleAllocator::Handle hndl) |
reed | 589a39e | 2016-08-20 07:59:19 -0700 | [diff] [blame] | 86 | : INHERITED(bitmap.info(), surfaceProps) |
reed | 2c9e200 | 2016-07-25 08:05:22 -0700 | [diff] [blame] | 87 | , fBitmap(bitmap) |
Mike Reed | 356f7c2 | 2017-01-10 11:58:39 -0500 | [diff] [blame] | 88 | , fRasterHandle(hndl) |
Mike Reed | c42a1cd | 2017-02-14 14:25:14 -0500 | [diff] [blame] | 89 | , fRCStack(bitmap.width(), bitmap.height()) |
reed | 2c9e200 | 2016-07-25 08:05:22 -0700 | [diff] [blame] | 90 | { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 91 | SkASSERT(valid_for_bitmap_device(bitmap.info(), nullptr)); |
reed | 2c9e200 | 2016-07-25 08:05:22 -0700 | [diff] [blame] | 92 | fBitmap.lockPixels(); |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 93 | } |
| 94 | |
commit-bot@chromium.org | 15a1405 | 2014-02-16 00:59:25 +0000 | [diff] [blame] | 95 | SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo, |
Mike Reed | 356f7c2 | 2017-01-10 11:58:39 -0500 | [diff] [blame] | 96 | const SkSurfaceProps& surfaceProps, |
| 97 | SkRasterHandleAllocator* allocator) { |
reed | e5ea500 | 2014-09-03 11:54:58 -0700 | [diff] [blame] | 98 | SkAlphaType newAT = origInfo.alphaType(); |
| 99 | if (!valid_for_bitmap_device(origInfo, &newAT)) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 100 | return nullptr; |
commit-bot@chromium.org | 15a1405 | 2014-02-16 00:59:25 +0000 | [diff] [blame] | 101 | } |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 102 | |
Mike Reed | 356f7c2 | 2017-01-10 11:58:39 -0500 | [diff] [blame] | 103 | SkRasterHandleAllocator::Handle hndl = nullptr; |
reed | e5ea500 | 2014-09-03 11:54:58 -0700 | [diff] [blame] | 104 | const SkImageInfo info = origInfo.makeAlphaType(newAT); |
commit-bot@chromium.org | 15a1405 | 2014-02-16 00:59:25 +0000 | [diff] [blame] | 105 | SkBitmap bitmap; |
| 106 | |
| 107 | if (kUnknown_SkColorType == info.colorType()) { |
commit-bot@chromium.org | a3264e5 | 2014-05-30 13:26:10 +0000 | [diff] [blame] | 108 | if (!bitmap.setInfo(info)) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 109 | return nullptr; |
commit-bot@chromium.org | 15a1405 | 2014-02-16 00:59:25 +0000 | [diff] [blame] | 110 | } |
Mike Reed | 356f7c2 | 2017-01-10 11:58:39 -0500 | [diff] [blame] | 111 | } else if (allocator) { |
| 112 | hndl = allocator->allocBitmap(info, &bitmap); |
| 113 | if (!hndl) { |
| 114 | return nullptr; |
| 115 | } |
lsalzman | 04d975a | 2016-01-08 11:20:14 -0800 | [diff] [blame] | 116 | } else if (info.isOpaque()) { |
mtklein | cd49541 | 2015-11-05 09:46:23 -0800 | [diff] [blame] | 117 | // If this bitmap is opaque, we don't have any sensible default color, |
| 118 | // so we just return uninitialized pixels. |
reed | 8482504 | 2014-09-02 12:50:45 -0700 | [diff] [blame] | 119 | if (!bitmap.tryAllocPixels(info)) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 120 | return nullptr; |
commit-bot@chromium.org | 15a1405 | 2014-02-16 00:59:25 +0000 | [diff] [blame] | 121 | } |
mtklein | cd49541 | 2015-11-05 09:46:23 -0800 | [diff] [blame] | 122 | } else { |
| 123 | // This bitmap has transparency, so we'll zero the pixels (to transparent). |
Mike Reed | 6b3155c | 2017-04-03 14:41:44 -0400 | [diff] [blame^] | 124 | // We use the flag as a faster alloc-then-eraseColor(SK_ColorTRANSPARENT). |
| 125 | if (!bitmap.tryAllocPixels(info, nullptr/*colortable*/, SkBitmap::kZeroPixels_AllocFlag)) { |
mtklein | cd49541 | 2015-11-05 09:46:23 -0800 | [diff] [blame] | 126 | return nullptr; |
commit-bot@chromium.org | 15a1405 | 2014-02-16 00:59:25 +0000 | [diff] [blame] | 127 | } |
| 128 | } |
| 129 | |
Mike Reed | 356f7c2 | 2017-01-10 11:58:39 -0500 | [diff] [blame] | 130 | return new SkBitmapDevice(bitmap, surfaceProps, hndl); |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) { |
| 134 | SkASSERT(bm.width() == fBitmap.width()); |
| 135 | SkASSERT(bm.height() == fBitmap.height()); |
| 136 | fBitmap = bm; // intent is to use bm's pixelRef (and rowbytes/config) |
| 137 | fBitmap.lockPixels(); |
reed | 589a39e | 2016-08-20 07:59:19 -0700 | [diff] [blame] | 138 | this->privateResize(fBitmap.info().width(), fBitmap.info().height()); |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 139 | } |
| 140 | |
reed | 76033be | 2015-03-14 10:54:31 -0700 | [diff] [blame] | 141 | SkBaseDevice* SkBitmapDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint*) { |
robertphillips | 9a53fd7 | 2015-06-22 09:46:59 -0700 | [diff] [blame] | 142 | const SkSurfaceProps surfaceProps(this->surfaceProps().flags(), cinfo.fPixelGeometry); |
Mike Reed | 356f7c2 | 2017-01-10 11:58:39 -0500 | [diff] [blame] | 143 | return SkBitmapDevice::Create(cinfo.fInfo, surfaceProps, cinfo.fAllocator); |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 144 | } |
| 145 | |
reed | 884e97c | 2015-05-26 11:31:54 -0700 | [diff] [blame] | 146 | bool SkBitmapDevice::onAccessPixels(SkPixmap* pmap) { |
reed | b560b5c | 2016-07-24 12:30:34 -0700 | [diff] [blame] | 147 | if (this->onPeekPixels(pmap)) { |
reed | 6e76485 | 2015-06-05 14:11:32 -0700 | [diff] [blame] | 148 | fBitmap.notifyPixelsChanged(); |
| 149 | return true; |
| 150 | } |
| 151 | return false; |
reed | 9572a10 | 2015-05-26 19:22:17 -0700 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | bool SkBitmapDevice::onPeekPixels(SkPixmap* pmap) { |
reed | 884e97c | 2015-05-26 11:31:54 -0700 | [diff] [blame] | 155 | const SkImageInfo info = fBitmap.info(); |
| 156 | if (fBitmap.getPixels() && (kUnknown_SkColorType != info.colorType())) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 157 | SkColorTable* ctable = nullptr; |
reed | 884e97c | 2015-05-26 11:31:54 -0700 | [diff] [blame] | 158 | pmap->reset(fBitmap.info(), fBitmap.getPixels(), fBitmap.rowBytes(), ctable); |
| 159 | return true; |
reed@google.com | 9c135db | 2014-03-12 18:28:35 +0000 | [diff] [blame] | 160 | } |
reed | 884e97c | 2015-05-26 11:31:54 -0700 | [diff] [blame] | 161 | return false; |
reed@google.com | 9c135db | 2014-03-12 18:28:35 +0000 | [diff] [blame] | 162 | } |
| 163 | |
commit-bot@chromium.org | 4cd9e21 | 2014-03-07 03:25:16 +0000 | [diff] [blame] | 164 | bool SkBitmapDevice::onWritePixels(const SkImageInfo& srcInfo, const void* srcPixels, |
| 165 | size_t srcRowBytes, int x, int y) { |
reed@google.com | 0d30c51 | 2014-03-14 14:02:58 +0000 | [diff] [blame] | 166 | // since we don't stop creating un-pixeled devices yet, check for no pixels here |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 167 | if (nullptr == fBitmap.getPixels()) { |
reed@google.com | 0d30c51 | 2014-03-14 14:02:58 +0000 | [diff] [blame] | 168 | return false; |
| 169 | } |
| 170 | |
Mike Reed | 68dd8d0 | 2017-01-04 16:34:31 -0500 | [diff] [blame] | 171 | if (fBitmap.writePixels(SkPixmap(srcInfo, srcPixels, srcRowBytes), x, y)) { |
commit-bot@chromium.org | 4cd9e21 | 2014-03-07 03:25:16 +0000 | [diff] [blame] | 172 | fBitmap.notifyPixelsChanged(); |
| 173 | return true; |
| 174 | } |
| 175 | return false; |
| 176 | } |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 177 | |
commit-bot@chromium.org | a713f9c | 2014-03-17 21:31:26 +0000 | [diff] [blame] | 178 | bool SkBitmapDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes, |
| 179 | int x, int y) { |
reed | b184f7f | 2014-07-13 04:32:32 -0700 | [diff] [blame] | 180 | return fBitmap.readPixels(dstInfo, dstPixels, dstRowBytes, x, y); |
commit-bot@chromium.org | a713f9c | 2014-03-17 21:31:26 +0000 | [diff] [blame] | 181 | } |
| 182 | |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 183 | /////////////////////////////////////////////////////////////////////////////// |
| 184 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 185 | class SkBitmapDevice::BDDraw : public SkDraw { |
Mike Reed | c42a1cd | 2017-02-14 14:25:14 -0500 | [diff] [blame] | 186 | public: |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 187 | BDDraw(SkBitmapDevice* dev) { |
| 188 | // we need fDst to be set, and if we're actually drawing, to dirty the genID |
| 189 | if (!dev->accessPixels(&fDst)) { |
| 190 | // NoDrawDevice uses us (why?) so we have to catch this case w/ no pixels |
| 191 | fDst.reset(dev->imageInfo(), nullptr, 0); |
| 192 | } |
| 193 | fMatrix = &dev->ctm(); |
| 194 | fRC = &dev->fRCStack.rc(); |
Mike Reed | c42a1cd | 2017-02-14 14:25:14 -0500 | [diff] [blame] | 195 | } |
| 196 | }; |
Mike Reed | c42a1cd | 2017-02-14 14:25:14 -0500 | [diff] [blame] | 197 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 198 | void SkBitmapDevice::drawPaint(const SkPaint& paint) { |
| 199 | BDDraw(this).drawPaint(paint); |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 200 | } |
| 201 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 202 | void SkBitmapDevice::drawPoints(SkCanvas::PointMode mode, size_t count, |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 203 | const SkPoint pts[], const SkPaint& paint) { |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 204 | BDDraw(this).drawPoints(mode, count, pts, paint, nullptr); |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 205 | } |
| 206 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 207 | void SkBitmapDevice::drawRect(const SkRect& r, const SkPaint& paint) { |
| 208 | BDDraw(this).drawRect(r, paint); |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 209 | } |
| 210 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 211 | void SkBitmapDevice::drawOval(const SkRect& oval, const SkPaint& paint) { |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 212 | SkPath path; |
| 213 | path.addOval(oval); |
| 214 | // call the VIRTUAL version, so any subclasses who do handle drawPath aren't |
| 215 | // required to override drawOval. |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 216 | this->drawPath(path, paint, nullptr, true); |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 217 | } |
| 218 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 219 | void SkBitmapDevice::drawRRect(const SkRRect& rrect, const SkPaint& paint) { |
robertphillips@google.com | 50a7600 | 2013-11-12 01:16:56 +0000 | [diff] [blame] | 220 | #ifdef SK_IGNORE_BLURRED_RRECT_OPT |
| 221 | SkPath path; |
| 222 | |
| 223 | path.addRRect(rrect); |
| 224 | // call the VIRTUAL version, so any subclasses who do handle drawPath aren't |
| 225 | // required to override drawRRect. |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 226 | this->drawPath(path, paint, nullptr, true); |
robertphillips@google.com | 50a7600 | 2013-11-12 01:16:56 +0000 | [diff] [blame] | 227 | #else |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 228 | BDDraw(this).drawRRect(rrect, paint); |
robertphillips@google.com | 50a7600 | 2013-11-12 01:16:56 +0000 | [diff] [blame] | 229 | #endif |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 230 | } |
| 231 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 232 | void SkBitmapDevice::drawPath(const SkPath& path, |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 233 | const SkPaint& paint, const SkMatrix* prePathMatrix, |
| 234 | bool pathIsMutable) { |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 235 | BDDraw(this).drawPath(path, paint, prePathMatrix, pathIsMutable); |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 236 | } |
| 237 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 238 | void SkBitmapDevice::drawBitmap(const SkBitmap& bitmap, |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 239 | const SkMatrix& matrix, const SkPaint& paint) { |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 240 | LogDrawScaleFactor(SkMatrix::Concat(this->ctm(), matrix), paint.getFilterQuality()); |
| 241 | BDDraw(this).drawBitmap(bitmap, matrix, nullptr, paint); |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 242 | } |
| 243 | |
fmalita | ab83da7 | 2016-08-26 13:04:14 -0700 | [diff] [blame] | 244 | static inline bool CanApplyDstMatrixAsCTM(const SkMatrix& m, const SkPaint& paint) { |
| 245 | if (!paint.getMaskFilter()) { |
| 246 | return true; |
| 247 | } |
| 248 | |
| 249 | // Some mask filters parameters (sigma) depend on the CTM/scale. |
| 250 | return m.getType() <= SkMatrix::kTranslate_Mask; |
| 251 | } |
| 252 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 253 | void SkBitmapDevice::drawBitmapRect(const SkBitmap& bitmap, |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 254 | const SkRect* src, const SkRect& dst, |
reed | 562fe47 | 2015-07-28 07:35:14 -0700 | [diff] [blame] | 255 | const SkPaint& paint, SkCanvas::SrcRectConstraint constraint) { |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 256 | SkMatrix matrix; |
| 257 | SkRect bitmapBounds, tmpSrc, tmpDst; |
| 258 | SkBitmap tmpBitmap; |
| 259 | |
| 260 | bitmapBounds.isetWH(bitmap.width(), bitmap.height()); |
| 261 | |
| 262 | // Compute matrix from the two rectangles |
| 263 | if (src) { |
| 264 | tmpSrc = *src; |
| 265 | } else { |
| 266 | tmpSrc = bitmapBounds; |
| 267 | } |
| 268 | matrix.setRectToRect(tmpSrc, dst, SkMatrix::kFill_ScaleToFit); |
| 269 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 270 | LogDrawScaleFactor(SkMatrix::Concat(this->ctm(), matrix), paint.getFilterQuality()); |
ericrk | 983294f | 2016-04-18 09:14:00 -0700 | [diff] [blame] | 271 | |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 272 | const SkRect* dstPtr = &dst; |
| 273 | const SkBitmap* bitmapPtr = &bitmap; |
| 274 | |
| 275 | // clip the tmpSrc to the bounds of the bitmap, and recompute dstRect if |
| 276 | // needed (if the src was clipped). No check needed if src==null. |
| 277 | if (src) { |
| 278 | if (!bitmapBounds.contains(*src)) { |
| 279 | if (!tmpSrc.intersect(bitmapBounds)) { |
| 280 | return; // nothing to draw |
| 281 | } |
| 282 | // recompute dst, based on the smaller tmpSrc |
| 283 | matrix.mapRect(&tmpDst, tmpSrc); |
| 284 | dstPtr = &tmpDst; |
| 285 | } |
reed | 27efa23 | 2016-07-25 19:10:10 -0700 | [diff] [blame] | 286 | } |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 287 | |
reed | 27efa23 | 2016-07-25 19:10:10 -0700 | [diff] [blame] | 288 | if (src && !src->contains(bitmapBounds) && |
| 289 | SkCanvas::kFast_SrcRectConstraint == constraint && |
| 290 | paint.getFilterQuality() != kNone_SkFilterQuality) { |
| 291 | // src is smaller than the bounds of the bitmap, and we are filtering, so we don't know |
| 292 | // how much more of the bitmap we need, so we can't use extractSubset or drawBitmap, |
| 293 | // but we must use a shader w/ dst bounds (which can access all of the bitmap needed). |
| 294 | goto USE_SHADER; |
| 295 | } |
| 296 | |
| 297 | if (src) { |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 298 | // since we may need to clamp to the borders of the src rect within |
| 299 | // the bitmap, we extract a subset. |
reed | b07a94f | 2014-11-19 05:03:18 -0800 | [diff] [blame] | 300 | const SkIRect srcIR = tmpSrc.roundOut(); |
bsalomon | 19fe41e | 2016-08-23 14:02:54 -0700 | [diff] [blame] | 301 | if (!bitmap.extractSubset(&tmpBitmap, srcIR)) { |
| 302 | return; |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 303 | } |
| 304 | bitmapPtr = &tmpBitmap; |
| 305 | |
| 306 | // Since we did an extract, we need to adjust the matrix accordingly |
| 307 | SkScalar dx = 0, dy = 0; |
| 308 | if (srcIR.fLeft > 0) { |
| 309 | dx = SkIntToScalar(srcIR.fLeft); |
| 310 | } |
| 311 | if (srcIR.fTop > 0) { |
| 312 | dy = SkIntToScalar(srcIR.fTop); |
| 313 | } |
| 314 | if (dx || dy) { |
| 315 | matrix.preTranslate(dx, dy); |
| 316 | } |
| 317 | |
mtklein | 65c74f1 | 2017-03-31 18:36:39 -0700 | [diff] [blame] | 318 | SkRect extractedBitmapBounds; |
| 319 | extractedBitmapBounds.isetWH(bitmapPtr->width(), bitmapPtr->height()); |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 320 | if (extractedBitmapBounds == tmpSrc) { |
| 321 | // no fractional part in src, we can just call drawBitmap |
| 322 | goto USE_DRAWBITMAP; |
| 323 | } |
| 324 | } else { |
| 325 | USE_DRAWBITMAP: |
| 326 | // We can go faster by just calling drawBitmap, which will concat the |
| 327 | // matrix with the CTM, and try to call drawSprite if it can. If not, |
| 328 | // it will make a shader and call drawRect, as we do below. |
fmalita | ab83da7 | 2016-08-26 13:04:14 -0700 | [diff] [blame] | 329 | if (CanApplyDstMatrixAsCTM(matrix, paint)) { |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 330 | BDDraw(this).drawBitmap(*bitmapPtr, matrix, dstPtr, paint); |
fmalita | ab83da7 | 2016-08-26 13:04:14 -0700 | [diff] [blame] | 331 | return; |
| 332 | } |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 333 | } |
| 334 | |
reed | 27efa23 | 2016-07-25 19:10:10 -0700 | [diff] [blame] | 335 | USE_SHADER: |
reed | f77c47b | 2016-08-05 10:15:00 -0700 | [diff] [blame] | 336 | |
Herb Derby | 83e939b | 2017-02-07 14:25:11 -0500 | [diff] [blame] | 337 | // TODO(herb): Move this over to SkArenaAlloc when arena alloc has a facility to return sk_sps. |
reed | f77c47b | 2016-08-05 10:15:00 -0700 | [diff] [blame] | 338 | // Since the shader need only live for our stack-frame, pass in a custom allocator. This |
| 339 | // can save malloc calls, and signals to SkMakeBitmapShader to not try to copy the bitmap |
| 340 | // if its mutable, since that precaution is not needed (give the short lifetime of the shader). |
Herb Derby | bfdc87a | 2017-02-14 15:06:23 +0000 | [diff] [blame] | 341 | |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 342 | // construct a shader, so we can call drawRect with the dst |
reed | f77c47b | 2016-08-05 10:15:00 -0700 | [diff] [blame] | 343 | auto s = SkMakeBitmapShader(*bitmapPtr, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, |
Herb Derby | bfdc87a | 2017-02-14 15:06:23 +0000 | [diff] [blame] | 344 | &matrix, kNever_SkCopyPixelsMode); |
reed | 8a21c9f | 2016-03-08 18:50:00 -0800 | [diff] [blame] | 345 | if (!s) { |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 346 | return; |
| 347 | } |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 348 | |
| 349 | SkPaint paintWithShader(paint); |
| 350 | paintWithShader.setStyle(SkPaint::kFill_Style); |
reed | f77c47b | 2016-08-05 10:15:00 -0700 | [diff] [blame] | 351 | paintWithShader.setShader(s); |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 352 | |
| 353 | // Call ourself, in case the subclass wanted to share this setup code |
| 354 | // but handle the drawRect code themselves. |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 355 | this->drawRect(*dstPtr, paintWithShader); |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 356 | } |
| 357 | |
Mike Reed | 2f6b5a4 | 2017-03-19 15:04:17 -0400 | [diff] [blame] | 358 | void SkBitmapDevice::drawSprite(const SkBitmap& bitmap, int x, int y, const SkPaint& paint) { |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 359 | BDDraw(this).drawSprite(bitmap, x, y, paint); |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 360 | } |
| 361 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 362 | void SkBitmapDevice::drawText(const void* text, size_t len, |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 363 | SkScalar x, SkScalar y, const SkPaint& paint) { |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 364 | BDDraw(this).drawText((const char*)text, len, x, y, paint, &fSurfaceProps); |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 365 | } |
| 366 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 367 | void SkBitmapDevice::drawPosText(const void* text, size_t len, const SkScalar xpos[], |
| 368 | int scalarsPerPos, const SkPoint& offset, const SkPaint& paint) { |
Mike Reed | 2f6b5a4 | 2017-03-19 15:04:17 -0400 | [diff] [blame] | 369 | BDDraw(this).drawPosText((const char*)text, len, xpos, scalarsPerPos, offset, paint, |
| 370 | &fSurfaceProps); |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 371 | } |
| 372 | |
Mike Reed | 2f6b5a4 | 2017-03-19 15:04:17 -0400 | [diff] [blame] | 373 | void SkBitmapDevice::drawVertices(const SkVertices* vertices, SkBlendMode bmode, |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 374 | const SkPaint& paint) { |
Mike Reed | 2f6b5a4 | 2017-03-19 15:04:17 -0400 | [diff] [blame] | 375 | BDDraw(this).drawVertices(vertices->mode(), vertices->vertexCount(), vertices->positions(), |
| 376 | vertices->texCoords(), vertices->colors(), bmode, |
| 377 | vertices->indices(), vertices->indexCount(), paint); |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 378 | } |
| 379 | |
Mike Reed | 2f6b5a4 | 2017-03-19 15:04:17 -0400 | [diff] [blame] | 380 | void SkBitmapDevice::drawDevice(SkBaseDevice* device, int x, int y, const SkPaint& paint) { |
reed | cf5c846 | 2016-07-20 12:28:40 -0700 | [diff] [blame] | 381 | SkASSERT(!paint.getImageFilter()); |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 382 | BDDraw(this).drawSprite(static_cast<SkBitmapDevice*>(device)->fBitmap, x, y, paint); |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 383 | } |
| 384 | |
reed | e51c356 | 2016-07-19 14:33:20 -0700 | [diff] [blame] | 385 | /////////////////////////////////////////////////////////////////////////////// |
| 386 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 387 | void SkBitmapDevice::drawSpecial(SkSpecialImage* srcImg, int x, int y, |
reed | e51c356 | 2016-07-19 14:33:20 -0700 | [diff] [blame] | 388 | const SkPaint& paint) { |
| 389 | SkASSERT(!srcImg->isTextureBacked()); |
| 390 | |
| 391 | SkBitmap resultBM; |
| 392 | |
| 393 | SkImageFilter* filter = paint.getImageFilter(); |
| 394 | if (filter) { |
| 395 | SkIPoint offset = SkIPoint::Make(0, 0); |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 396 | SkMatrix matrix = this->ctm(); |
reed | e51c356 | 2016-07-19 14:33:20 -0700 | [diff] [blame] | 397 | matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 398 | const SkIRect clipBounds = fRCStack.rc().getBounds().makeOffset(-x, -y); |
Hal Canary | 704cd32 | 2016-11-07 14:13:52 -0500 | [diff] [blame] | 399 | sk_sp<SkImageFilterCache> cache(this->getImageFilterCache()); |
brianosman | 2a75e5d | 2016-09-22 07:15:37 -0700 | [diff] [blame] | 400 | SkImageFilter::OutputProperties outputProperties(fBitmap.colorSpace()); |
| 401 | SkImageFilter::Context ctx(matrix, clipBounds, cache.get(), outputProperties); |
liyuqian | 2add0ff | 2016-10-20 11:04:39 -0700 | [diff] [blame] | 402 | |
reed | e51c356 | 2016-07-19 14:33:20 -0700 | [diff] [blame] | 403 | sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg, ctx, &offset)); |
| 404 | if (resultImg) { |
| 405 | SkPaint tmpUnfiltered(paint); |
| 406 | tmpUnfiltered.setImageFilter(nullptr); |
| 407 | if (resultImg->getROPixels(&resultBM)) { |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 408 | this->drawSprite(resultBM, x + offset.x(), y + offset.y(), tmpUnfiltered); |
reed | e51c356 | 2016-07-19 14:33:20 -0700 | [diff] [blame] | 409 | } |
| 410 | } |
| 411 | } else { |
| 412 | if (srcImg->getROPixels(&resultBM)) { |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 413 | this->drawSprite(resultBM, x, y, paint); |
reed | e51c356 | 2016-07-19 14:33:20 -0700 | [diff] [blame] | 414 | } |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | sk_sp<SkSpecialImage> SkBitmapDevice::makeSpecial(const SkBitmap& bitmap) { |
| 419 | return SkSpecialImage::MakeFromRaster(bitmap.bounds(), bitmap); |
| 420 | } |
| 421 | |
| 422 | sk_sp<SkSpecialImage> SkBitmapDevice::makeSpecial(const SkImage* image) { |
| 423 | return SkSpecialImage::MakeFromImage(SkIRect::MakeWH(image->width(), image->height()), |
Brian Osman | 61624f0 | 2016-12-09 14:51:59 -0500 | [diff] [blame] | 424 | image->makeNonTextureImage(), fBitmap.colorSpace()); |
reed | e51c356 | 2016-07-19 14:33:20 -0700 | [diff] [blame] | 425 | } |
| 426 | |
| 427 | sk_sp<SkSpecialImage> SkBitmapDevice::snapSpecial() { |
| 428 | return this->makeSpecial(fBitmap); |
| 429 | } |
| 430 | |
| 431 | /////////////////////////////////////////////////////////////////////////////// |
| 432 | |
reed | e8f3062 | 2016-03-23 18:59:25 -0700 | [diff] [blame] | 433 | sk_sp<SkSurface> SkBitmapDevice::makeSurface(const SkImageInfo& info, const SkSurfaceProps& props) { |
| 434 | return SkSurface::MakeRaster(info, &props); |
reed@google.com | 76f10a3 | 2014-02-05 15:32:21 +0000 | [diff] [blame] | 435 | } |
| 436 | |
senorblanco | 900c367 | 2016-04-27 11:31:23 -0700 | [diff] [blame] | 437 | SkImageFilterCache* SkBitmapDevice::getImageFilterCache() { |
| 438 | SkImageFilterCache* cache = SkImageFilterCache::Get(); |
senorblanco | 55b6d8b | 2014-07-30 11:26:46 -0700 | [diff] [blame] | 439 | cache->ref(); |
| 440 | return cache; |
| 441 | } |
| 442 | |
Mike Reed | 7627fa5 | 2017-02-08 10:07:53 -0500 | [diff] [blame] | 443 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 444 | |
reed | b2db898 | 2014-11-13 12:41:02 -0800 | [diff] [blame] | 445 | bool SkBitmapDevice::onShouldDisableLCD(const SkPaint& paint) const { |
commit-bot@chromium.org | cba7378 | 2014-05-29 15:57:47 +0000 | [diff] [blame] | 446 | if (kN32_SkColorType != fBitmap.colorType() || |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 447 | paint.getRasterizer() || |
| 448 | paint.getPathEffect() || |
| 449 | paint.isFakeBoldText() || |
| 450 | paint.getStyle() != SkPaint::kFill_Style || |
reed | 374772b | 2016-10-05 17:33:02 -0700 | [diff] [blame] | 451 | !paint.isSrcOver()) |
reed | b2db898 | 2014-11-13 12:41:02 -0800 | [diff] [blame] | 452 | { |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 453 | return true; |
| 454 | } |
robertphillips@google.com | 53238bc | 2013-08-30 13:12:10 +0000 | [diff] [blame] | 455 | return false; |
| 456 | } |
Mike Reed | 7627fa5 | 2017-02-08 10:07:53 -0500 | [diff] [blame] | 457 | |
| 458 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
| 459 | |
| 460 | void SkBitmapDevice::onSave() { |
Mike Reed | c42a1cd | 2017-02-14 14:25:14 -0500 | [diff] [blame] | 461 | fRCStack.save(); |
Mike Reed | 7627fa5 | 2017-02-08 10:07:53 -0500 | [diff] [blame] | 462 | } |
| 463 | |
| 464 | void SkBitmapDevice::onRestore() { |
Mike Reed | c42a1cd | 2017-02-14 14:25:14 -0500 | [diff] [blame] | 465 | fRCStack.restore(); |
Mike Reed | 7627fa5 | 2017-02-08 10:07:53 -0500 | [diff] [blame] | 466 | } |
| 467 | |
| 468 | void SkBitmapDevice::onClipRect(const SkRect& rect, SkClipOp op, bool aa) { |
Mike Reed | c42a1cd | 2017-02-14 14:25:14 -0500 | [diff] [blame] | 469 | fRCStack.clipRect(this->ctm(), rect, op, aa); |
Mike Reed | 7627fa5 | 2017-02-08 10:07:53 -0500 | [diff] [blame] | 470 | } |
| 471 | |
| 472 | void SkBitmapDevice::onClipRRect(const SkRRect& rrect, SkClipOp op, bool aa) { |
Mike Reed | c42a1cd | 2017-02-14 14:25:14 -0500 | [diff] [blame] | 473 | fRCStack.clipRRect(this->ctm(), rrect, op, aa); |
Mike Reed | 7627fa5 | 2017-02-08 10:07:53 -0500 | [diff] [blame] | 474 | } |
| 475 | |
| 476 | void SkBitmapDevice::onClipPath(const SkPath& path, SkClipOp op, bool aa) { |
Mike Reed | c42a1cd | 2017-02-14 14:25:14 -0500 | [diff] [blame] | 477 | fRCStack.clipPath(this->ctm(), path, op, aa); |
Mike Reed | 7627fa5 | 2017-02-08 10:07:53 -0500 | [diff] [blame] | 478 | } |
| 479 | |
| 480 | void SkBitmapDevice::onClipRegion(const SkRegion& rgn, SkClipOp op) { |
Mike Reed | c42a1cd | 2017-02-14 14:25:14 -0500 | [diff] [blame] | 481 | SkIPoint origin = this->getOrigin(); |
| 482 | SkRegion tmp; |
| 483 | const SkRegion* ptr = &rgn; |
| 484 | if (origin.fX | origin.fY) { |
| 485 | // translate from "global/canvas" coordinates to relative to this device |
| 486 | rgn.translate(-origin.fX, -origin.fY, &tmp); |
| 487 | ptr = &tmp; |
| 488 | } |
| 489 | fRCStack.clipRegion(*ptr, op); |
| 490 | } |
| 491 | |
| 492 | void SkBitmapDevice::onSetDeviceClipRestriction(SkIRect* mutableClipRestriction) { |
| 493 | fRCStack.setDeviceClipRestriction(mutableClipRestriction); |
Mike Reed | d519d48 | 2017-02-16 11:04:52 -0500 | [diff] [blame] | 494 | if (!mutableClipRestriction->isEmpty()) { |
| 495 | SkRegion rgn(*mutableClipRestriction); |
| 496 | fRCStack.clipRegion(rgn, SkClipOp::kIntersect); |
| 497 | } |
Mike Reed | c42a1cd | 2017-02-14 14:25:14 -0500 | [diff] [blame] | 498 | } |
| 499 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 500 | bool SkBitmapDevice::onClipIsAA() const { |
| 501 | const SkRasterClip& rc = fRCStack.rc(); |
| 502 | return !rc.isEmpty() && rc.isAA(); |
| 503 | } |
| 504 | |
| 505 | void SkBitmapDevice::onAsRgnClip(SkRegion* rgn) const { |
| 506 | const SkRasterClip& rc = fRCStack.rc(); |
| 507 | if (rc.isAA()) { |
| 508 | rgn->setRect(rc.getBounds()); |
| 509 | } else { |
| 510 | *rgn = rc.bwRgn(); |
| 511 | } |
| 512 | } |
| 513 | |
Mike Reed | c42a1cd | 2017-02-14 14:25:14 -0500 | [diff] [blame] | 514 | void SkBitmapDevice::validateDevBounds(const SkIRect& drawClipBounds) { |
| 515 | #ifdef SK_DEBUG |
| 516 | const SkIRect& stackBounds = fRCStack.rc().getBounds(); |
| 517 | SkASSERT(drawClipBounds == stackBounds); |
| 518 | #endif |
Mike Reed | 7627fa5 | 2017-02-08 10:07:53 -0500 | [diff] [blame] | 519 | } |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 520 | |
| 521 | SkBaseDevice::ClipType SkBitmapDevice::onGetClipType() const { |
| 522 | const SkRasterClip& rc = fRCStack.rc(); |
| 523 | if (rc.isEmpty()) { |
| 524 | return kEmpty_ClipType; |
| 525 | } else if (rc.isRect()) { |
| 526 | return kRect_ClipType; |
| 527 | } else { |
| 528 | return kComplex_ClipType; |
| 529 | } |
| 530 | } |