mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 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 | |
halcanary | b0cce2c | 2015-01-26 12:49:00 -0800 | [diff] [blame] | 8 | #include "sk_tool_utils.h" |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 9 | #include "SampleCode.h" |
| 10 | #include "SkView.h" |
| 11 | #include "SkCanvas.h" |
| 12 | #include "SkPath.h" |
Cary Clark | df429f3 | 2017-11-08 11:44:31 -0500 | [diff] [blame] | 13 | #include "SkPointPriv.h" |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 14 | #include "SkRegion.h" |
| 15 | #include "SkShader.h" |
| 16 | #include "SkUtils.h" |
| 17 | #include "SkImage.h" |
| 18 | #include "SkSurface.h" |
Mike Reed | ebfce6d | 2016-12-12 10:02:12 -0500 | [diff] [blame] | 19 | #include "SkClipOpPriv.h" |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 20 | |
reed@google.com | c83e352 | 2012-10-22 22:00:08 +0000 | [diff] [blame] | 21 | #define FAT_PIXEL_COLOR SK_ColorBLACK |
| 22 | #define PIXEL_CENTER_SIZE 3 |
| 23 | #define WIRE_FRAME_COLOR 0xFFFF0000 /*0xFF00FFFF*/ |
| 24 | #define WIRE_FRAME_SIZE 1.5f |
| 25 | |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 26 | static SkScalar apply_grid(SkScalar x) { |
| 27 | const SkScalar grid = 2; |
| 28 | return SkScalarRoundToScalar(x * grid) / grid; |
| 29 | } |
| 30 | |
| 31 | static void apply_grid(SkPoint pts[], int count) { |
| 32 | for (int i = 0; i < count; ++i) { |
| 33 | pts[i].set(apply_grid(pts[i].fX), apply_grid(pts[i].fY)); |
| 34 | } |
| 35 | } |
| 36 | |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 37 | static void erase(SkSurface* surface) { |
junov@google.com | dbfac8a | 2012-12-06 21:47:40 +0000 | [diff] [blame] | 38 | surface->getCanvas()->clear(SK_ColorTRANSPARENT); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 39 | } |
| 40 | |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 41 | class FatBits { |
| 42 | public: |
commit-bot@chromium.org | 5970f62 | 2014-05-12 20:42:21 +0000 | [diff] [blame] | 43 | FatBits() { |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 44 | fAA = false; |
| 45 | fStyle = kHair_Style; |
reed | bb88674 | 2015-08-15 07:42:31 -0700 | [diff] [blame] | 46 | fGrid = false; |
reed@google.com | c83e352 | 2012-10-22 22:00:08 +0000 | [diff] [blame] | 47 | fShowSkeleton = true; |
reed@google.com | 9c0bef1 | 2012-11-02 19:59:18 +0000 | [diff] [blame] | 48 | fUseClip = false; |
mike@reedtribe.org | 64494e9 | 2013-03-06 02:18:33 +0000 | [diff] [blame] | 49 | fRectAsOval = false; |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 50 | fUseTriangle = false; |
reed | a5d1207 | 2015-11-16 18:57:18 -0800 | [diff] [blame] | 51 | fStrokeCap = SkPaint::kButt_Cap; |
skia.committer@gmail.com | 1aa90cf | 2012-11-06 13:18:25 +0000 | [diff] [blame] | 52 | |
reed@google.com | 9c0bef1 | 2012-11-02 19:59:18 +0000 | [diff] [blame] | 53 | fClipRect.set(2, 2, 11, 8 ); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 54 | } |
| 55 | |
robertphillips@google.com | ca47aae | 2012-12-12 15:58:25 +0000 | [diff] [blame] | 56 | int getZoom() const { return fZoom; } |
reed@google.com | c83e352 | 2012-10-22 22:00:08 +0000 | [diff] [blame] | 57 | |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 58 | bool getAA() const { return fAA; } |
| 59 | void setAA(bool aa) { fAA = aa; } |
| 60 | |
| 61 | bool getGrid() const { return fGrid; } |
| 62 | void setGrid(bool g) { fGrid = g; } |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 63 | |
reed@google.com | c83e352 | 2012-10-22 22:00:08 +0000 | [diff] [blame] | 64 | bool getShowSkeleton() const { return fShowSkeleton; } |
| 65 | void setShowSkeleton(bool ss) { fShowSkeleton = ss; } |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 66 | |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 67 | bool getTriangle() const { return fUseTriangle; } |
| 68 | void setTriangle(bool ut) { fUseTriangle = ut; } |
skia.committer@gmail.com | 7ed98df | 2013-10-31 07:01:53 +0000 | [diff] [blame] | 69 | |
mike@reedtribe.org | 64494e9 | 2013-03-06 02:18:33 +0000 | [diff] [blame] | 70 | void toggleRectAsOval() { fRectAsOval = !fRectAsOval; } |
| 71 | |
reed | 8716a8a | 2016-09-19 07:10:36 -0700 | [diff] [blame] | 72 | void togglePixelColors() { |
| 73 | if (fShader == fShader0) { |
| 74 | fShader = fShader1; |
| 75 | } else { |
| 76 | fShader = fShader0; |
| 77 | } |
| 78 | } |
| 79 | |
Mike Reed | ce54bce | 2017-11-01 21:17:11 -0400 | [diff] [blame] | 80 | float fStrokeWidth = 1; |
| 81 | |
reed@google.com | 9c0bef1 | 2012-11-02 19:59:18 +0000 | [diff] [blame] | 82 | bool getUseClip() const { return fUseClip; } |
| 83 | void setUseClip(bool uc) { fUseClip = uc; } |
| 84 | |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 85 | enum Style { |
| 86 | kHair_Style, |
reed@google.com | c83e352 | 2012-10-22 22:00:08 +0000 | [diff] [blame] | 87 | kStroke_Style, |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 88 | }; |
| 89 | Style getStyle() const { return fStyle; } |
| 90 | void setStyle(Style s) { fStyle = s; } |
| 91 | |
| 92 | void setWHZ(int width, int height, int zoom) { |
| 93 | fW = width; |
| 94 | fH = height; |
robertphillips@google.com | ca47aae | 2012-12-12 15:58:25 +0000 | [diff] [blame] | 95 | fZoom = zoom; |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 96 | fBounds.set(0, 0, SkIntToScalar(width * zoom), SkIntToScalar(height * zoom)); |
| 97 | fMatrix.setScale(SkIntToScalar(zoom), SkIntToScalar(zoom)); |
| 98 | fInverse.setScale(SK_Scalar1 / zoom, SK_Scalar1 / zoom); |
reed | 8716a8a | 2016-09-19 07:10:36 -0700 | [diff] [blame] | 99 | fShader0 = sk_tool_utils::create_checkerboard_shader(0xFFDDDDDD, 0xFFFFFFFF, zoom); |
| 100 | fShader1 = SkShader::MakeColorShader(SK_ColorWHITE); |
| 101 | fShader = fShader0; |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 102 | |
commit-bot@chromium.org | 32678d9 | 2014-01-15 02:38:22 +0000 | [diff] [blame] | 103 | SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); |
reed | e8f3062 | 2016-03-23 18:59:25 -0700 | [diff] [blame] | 104 | fMinSurface = SkSurface::MakeRaster(info); |
reed | e5ea500 | 2014-09-03 11:54:58 -0700 | [diff] [blame] | 105 | info = info.makeWH(width * zoom, height * zoom); |
reed | e8f3062 | 2016-03-23 18:59:25 -0700 | [diff] [blame] | 106 | fMaxSurface = SkSurface::MakeRaster(info); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | void drawBG(SkCanvas*); |
| 110 | void drawFG(SkCanvas*); |
| 111 | void drawLine(SkCanvas*, SkPoint pts[2]); |
| 112 | void drawRect(SkCanvas* canvas, SkPoint pts[2]); |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 113 | void drawTriangle(SkCanvas* canvas, SkPoint pts[3]); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 114 | |
reed | a5d1207 | 2015-11-16 18:57:18 -0800 | [diff] [blame] | 115 | SkPaint::Cap fStrokeCap; |
| 116 | |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 117 | private: |
reed | 8716a8a | 2016-09-19 07:10:36 -0700 | [diff] [blame] | 118 | bool fAA, fGrid, fShowSkeleton, fUseClip, fRectAsOval, fUseTriangle; |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 119 | Style fStyle; |
robertphillips@google.com | ca47aae | 2012-12-12 15:58:25 +0000 | [diff] [blame] | 120 | int fW, fH, fZoom; |
reed | 8716a8a | 2016-09-19 07:10:36 -0700 | [diff] [blame] | 121 | SkMatrix fMatrix, fInverse; |
| 122 | SkRect fBounds, fClipRect; |
| 123 | sk_sp<SkShader> fShader0; |
| 124 | sk_sp<SkShader> fShader1; |
| 125 | sk_sp<SkShader> fShader; |
| 126 | sk_sp<SkSurface> fMinSurface; |
| 127 | sk_sp<SkSurface> fMaxSurface; |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 128 | |
| 129 | void setupPaint(SkPaint* paint) { |
| 130 | bool aa = this->getAA(); |
reed | a5d1207 | 2015-11-16 18:57:18 -0800 | [diff] [blame] | 131 | paint->setStrokeCap(fStrokeCap); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 132 | switch (fStyle) { |
| 133 | case kHair_Style: |
| 134 | paint->setStrokeWidth(0); |
| 135 | break; |
| 136 | case kStroke_Style: |
Mike Reed | ce54bce | 2017-11-01 21:17:11 -0400 | [diff] [blame] | 137 | paint->setStrokeWidth(fStrokeWidth); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 138 | break; |
| 139 | } |
| 140 | paint->setAntiAlias(aa); |
| 141 | } |
| 142 | |
reed@google.com | c83e352 | 2012-10-22 22:00:08 +0000 | [diff] [blame] | 143 | void setupSkeletonPaint(SkPaint* paint) { |
| 144 | paint->setStyle(SkPaint::kStroke_Style); |
| 145 | paint->setStrokeWidth(WIRE_FRAME_SIZE); |
| 146 | paint->setColor(fShowSkeleton ? WIRE_FRAME_COLOR : 0); |
| 147 | paint->setAntiAlias(true); |
| 148 | } |
| 149 | |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 150 | void drawTriangleSkeleton(SkCanvas* max, const SkPoint pts[]); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 151 | void drawLineSkeleton(SkCanvas* max, const SkPoint pts[]); |
| 152 | void drawRectSkeleton(SkCanvas* max, const SkRect& r) { |
| 153 | SkPaint paint; |
reed@google.com | c83e352 | 2012-10-22 22:00:08 +0000 | [diff] [blame] | 154 | this->setupSkeletonPaint(&paint); |
| 155 | SkPath path; |
| 156 | |
reed | 8716a8a | 2016-09-19 07:10:36 -0700 | [diff] [blame] | 157 | fRectAsOval ? path.addOval(r) : path.addRect(r); |
reed@google.com | c83e352 | 2012-10-22 22:00:08 +0000 | [diff] [blame] | 158 | max->drawPath(path, paint); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 159 | } |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 160 | |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 161 | void copyMinToMax() { |
reed | e8f3062 | 2016-03-23 18:59:25 -0700 | [diff] [blame] | 162 | erase(fMaxSurface.get()); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 163 | SkCanvas* canvas = fMaxSurface->getCanvas(); |
| 164 | canvas->save(); |
| 165 | canvas->concat(fMatrix); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 166 | fMinSurface->draw(canvas, 0, 0, nullptr); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 167 | canvas->restore(); |
| 168 | |
| 169 | SkPaint paint; |
reed | 374772b | 2016-10-05 17:33:02 -0700 | [diff] [blame] | 170 | paint.setBlendMode(SkBlendMode::kClear); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 171 | for (int iy = 1; iy < fH; ++iy) { |
robertphillips@google.com | ca47aae | 2012-12-12 15:58:25 +0000 | [diff] [blame] | 172 | SkScalar y = SkIntToScalar(iy * fZoom); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 173 | canvas->drawLine(0, y - SK_ScalarHalf, 999, y - SK_ScalarHalf, paint); |
| 174 | } |
| 175 | for (int ix = 1; ix < fW; ++ix) { |
robertphillips@google.com | ca47aae | 2012-12-12 15:58:25 +0000 | [diff] [blame] | 176 | SkScalar x = SkIntToScalar(ix * fZoom); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 177 | canvas->drawLine(x - SK_ScalarHalf, 0, x - SK_ScalarHalf, 999, paint); |
| 178 | } |
| 179 | } |
| 180 | }; |
| 181 | |
| 182 | void FatBits::drawBG(SkCanvas* canvas) { |
| 183 | SkPaint paint; |
| 184 | |
| 185 | paint.setShader(fShader); |
| 186 | canvas->drawRect(fBounds, paint); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 187 | paint.setShader(nullptr); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | void FatBits::drawFG(SkCanvas* canvas) { |
reed@google.com | c83e352 | 2012-10-22 22:00:08 +0000 | [diff] [blame] | 191 | SkPaint inner, outer; |
| 192 | |
| 193 | inner.setAntiAlias(true); |
| 194 | inner.setColor(SK_ColorBLACK); |
| 195 | inner.setStrokeWidth(PIXEL_CENTER_SIZE); |
| 196 | |
| 197 | outer.setAntiAlias(true); |
| 198 | outer.setColor(SK_ColorWHITE); |
| 199 | outer.setStrokeWidth(PIXEL_CENTER_SIZE + 2); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 200 | |
robertphillips@google.com | ca47aae | 2012-12-12 15:58:25 +0000 | [diff] [blame] | 201 | SkScalar half = SkIntToScalar(fZoom) / 2; |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 202 | for (int iy = 0; iy < fH; ++iy) { |
robertphillips@google.com | ca47aae | 2012-12-12 15:58:25 +0000 | [diff] [blame] | 203 | SkScalar y = SkIntToScalar(iy * fZoom) + half; |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 204 | for (int ix = 0; ix < fW; ++ix) { |
robertphillips@google.com | ca47aae | 2012-12-12 15:58:25 +0000 | [diff] [blame] | 205 | SkScalar x = SkIntToScalar(ix * fZoom) + half; |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 206 | |
reed@google.com | c83e352 | 2012-10-22 22:00:08 +0000 | [diff] [blame] | 207 | canvas->drawPoint(x, y, outer); |
| 208 | canvas->drawPoint(x, y, inner); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 209 | } |
| 210 | } |
reed@google.com | 9c0bef1 | 2012-11-02 19:59:18 +0000 | [diff] [blame] | 211 | |
| 212 | if (fUseClip) { |
| 213 | SkPaint p; |
| 214 | p.setStyle(SkPaint::kStroke_Style); |
| 215 | p.setColor(SK_ColorLTGRAY); |
| 216 | SkRect r = { |
robertphillips@google.com | ca47aae | 2012-12-12 15:58:25 +0000 | [diff] [blame] | 217 | fClipRect.fLeft * fZoom, |
| 218 | fClipRect.fTop * fZoom, |
| 219 | fClipRect.fRight * fZoom, |
| 220 | fClipRect.fBottom * fZoom |
reed@google.com | 9c0bef1 | 2012-11-02 19:59:18 +0000 | [diff] [blame] | 221 | }; |
| 222 | canvas->drawRect(r, p); |
| 223 | } |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | void FatBits::drawLineSkeleton(SkCanvas* max, const SkPoint pts[]) { |
| 227 | SkPaint paint; |
reed@google.com | c83e352 | 2012-10-22 22:00:08 +0000 | [diff] [blame] | 228 | this->setupSkeletonPaint(&paint); |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 229 | |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 230 | SkPath path; |
| 231 | path.moveTo(pts[0]); |
| 232 | path.lineTo(pts[1]); |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 233 | |
reed | 8716a8a | 2016-09-19 07:10:36 -0700 | [diff] [blame] | 234 | if (fStyle == kStroke_Style) { |
| 235 | SkPaint p; |
| 236 | p.setStyle(SkPaint::kStroke_Style); |
Mike Reed | ce54bce | 2017-11-01 21:17:11 -0400 | [diff] [blame] | 237 | p.setStrokeWidth(fStrokeWidth * fZoom); |
reed | 8716a8a | 2016-09-19 07:10:36 -0700 | [diff] [blame] | 238 | p.setStrokeCap(fStrokeCap); |
| 239 | SkPath dst; |
| 240 | p.getFillPath(path, &dst); |
| 241 | path = dst; |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 242 | |
reed | 8716a8a | 2016-09-19 07:10:36 -0700 | [diff] [blame] | 243 | path.moveTo(pts[0]); |
| 244 | path.lineTo(pts[1]); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 245 | } |
| 246 | max->drawPath(path, paint); |
| 247 | } |
| 248 | |
| 249 | void FatBits::drawLine(SkCanvas* canvas, SkPoint pts[]) { |
| 250 | SkPaint paint; |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 251 | |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 252 | fInverse.mapPoints(pts, 2); |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 253 | |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 254 | if (fGrid) { |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 255 | apply_grid(pts, 2); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 256 | } |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 257 | |
reed | e8f3062 | 2016-03-23 18:59:25 -0700 | [diff] [blame] | 258 | erase(fMinSurface.get()); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 259 | this->setupPaint(&paint); |
reed@google.com | c83e352 | 2012-10-22 22:00:08 +0000 | [diff] [blame] | 260 | paint.setColor(FAT_PIXEL_COLOR); |
reed@google.com | 9c0bef1 | 2012-11-02 19:59:18 +0000 | [diff] [blame] | 261 | if (fUseClip) { |
| 262 | fMinSurface->getCanvas()->save(); |
| 263 | SkRect r = fClipRect; |
| 264 | r.inset(SK_Scalar1/3, SK_Scalar1/3); |
Mike Reed | c1f7774 | 2016-12-09 09:00:50 -0500 | [diff] [blame] | 265 | fMinSurface->getCanvas()->clipRect(r, kIntersect_SkClipOp, true); |
reed@google.com | 9c0bef1 | 2012-11-02 19:59:18 +0000 | [diff] [blame] | 266 | } |
Hal Canary | 23e474c | 2017-05-15 13:35:35 -0400 | [diff] [blame] | 267 | fMinSurface->getCanvas()->drawLine(pts[0], pts[1], paint); |
reed@google.com | 9c0bef1 | 2012-11-02 19:59:18 +0000 | [diff] [blame] | 268 | if (fUseClip) { |
| 269 | fMinSurface->getCanvas()->restore(); |
| 270 | } |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 271 | this->copyMinToMax(); |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 272 | |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 273 | SkCanvas* max = fMaxSurface->getCanvas(); |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 274 | |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 275 | fMatrix.mapPoints(pts, 2); |
| 276 | this->drawLineSkeleton(max, pts); |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 277 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 278 | fMaxSurface->draw(canvas, 0, 0, nullptr); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | void FatBits::drawRect(SkCanvas* canvas, SkPoint pts[2]) { |
| 282 | SkPaint paint; |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 283 | |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 284 | fInverse.mapPoints(pts, 2); |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 285 | |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 286 | if (fGrid) { |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 287 | apply_grid(pts, 2); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 288 | } |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 289 | |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 290 | SkRect r; |
| 291 | r.set(pts, 2); |
| 292 | |
reed | e8f3062 | 2016-03-23 18:59:25 -0700 | [diff] [blame] | 293 | erase(fMinSurface.get()); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 294 | this->setupPaint(&paint); |
reed@google.com | c83e352 | 2012-10-22 22:00:08 +0000 | [diff] [blame] | 295 | paint.setColor(FAT_PIXEL_COLOR); |
mike@reedtribe.org | 64494e9 | 2013-03-06 02:18:33 +0000 | [diff] [blame] | 296 | { |
| 297 | SkCanvas* c = fMinSurface->getCanvas(); |
| 298 | fRectAsOval ? c->drawOval(r, paint) : c->drawRect(r, paint); |
| 299 | } |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 300 | this->copyMinToMax(); |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 301 | |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 302 | SkCanvas* max = fMaxSurface->getCanvas(); |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 303 | |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 304 | fMatrix.mapPoints(pts, 2); |
| 305 | r.set(pts, 2); |
| 306 | this->drawRectSkeleton(max, r); |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 307 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 308 | fMaxSurface->draw(canvas, 0, 0, nullptr); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 309 | } |
| 310 | |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 311 | void FatBits::drawTriangleSkeleton(SkCanvas* max, const SkPoint pts[]) { |
| 312 | SkPaint paint; |
| 313 | this->setupSkeletonPaint(&paint); |
skia.committer@gmail.com | 7ed98df | 2013-10-31 07:01:53 +0000 | [diff] [blame] | 314 | |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 315 | SkPath path; |
| 316 | path.moveTo(pts[0]); |
| 317 | path.lineTo(pts[1]); |
| 318 | path.lineTo(pts[2]); |
| 319 | path.close(); |
skia.committer@gmail.com | 7ed98df | 2013-10-31 07:01:53 +0000 | [diff] [blame] | 320 | |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 321 | max->drawPath(path, paint); |
| 322 | } |
| 323 | |
| 324 | void FatBits::drawTriangle(SkCanvas* canvas, SkPoint pts[3]) { |
| 325 | SkPaint paint; |
skia.committer@gmail.com | 7ed98df | 2013-10-31 07:01:53 +0000 | [diff] [blame] | 326 | |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 327 | fInverse.mapPoints(pts, 3); |
skia.committer@gmail.com | 7ed98df | 2013-10-31 07:01:53 +0000 | [diff] [blame] | 328 | |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 329 | if (fGrid) { |
| 330 | apply_grid(pts, 3); |
| 331 | } |
skia.committer@gmail.com | 7ed98df | 2013-10-31 07:01:53 +0000 | [diff] [blame] | 332 | |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 333 | SkPath path; |
| 334 | path.moveTo(pts[0]); |
| 335 | path.lineTo(pts[1]); |
| 336 | path.lineTo(pts[2]); |
| 337 | path.close(); |
skia.committer@gmail.com | 7ed98df | 2013-10-31 07:01:53 +0000 | [diff] [blame] | 338 | |
reed | e8f3062 | 2016-03-23 18:59:25 -0700 | [diff] [blame] | 339 | erase(fMinSurface.get()); |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 340 | this->setupPaint(&paint); |
| 341 | paint.setColor(FAT_PIXEL_COLOR); |
| 342 | fMinSurface->getCanvas()->drawPath(path, paint); |
| 343 | this->copyMinToMax(); |
skia.committer@gmail.com | 7ed98df | 2013-10-31 07:01:53 +0000 | [diff] [blame] | 344 | |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 345 | SkCanvas* max = fMaxSurface->getCanvas(); |
skia.committer@gmail.com | 7ed98df | 2013-10-31 07:01:53 +0000 | [diff] [blame] | 346 | |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 347 | fMatrix.mapPoints(pts, 3); |
| 348 | this->drawTriangleSkeleton(max, pts); |
skia.committer@gmail.com | 7ed98df | 2013-10-31 07:01:53 +0000 | [diff] [blame] | 349 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 350 | fMaxSurface->draw(canvas, 0, 0, nullptr); |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 351 | } |
| 352 | |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 353 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
| 354 | |
| 355 | class IndexClick : public SkView::Click { |
| 356 | int fIndex; |
| 357 | public: |
| 358 | IndexClick(SkView* v, int index) : SkView::Click(v), fIndex(index) {} |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 359 | |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 360 | static int GetIndex(SkView::Click* click) { |
| 361 | return ((IndexClick*)click)->fIndex; |
| 362 | } |
| 363 | }; |
| 364 | |
| 365 | class DrawLineView : public SampleView { |
| 366 | FatBits fFB; |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 367 | SkPoint fPts[3]; |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 368 | bool fIsRect; |
reed | 8716a8a | 2016-09-19 07:10:36 -0700 | [diff] [blame] | 369 | int fZoom = 64; |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 370 | public: |
| 371 | DrawLineView() { |
reed | 8716a8a | 2016-09-19 07:10:36 -0700 | [diff] [blame] | 372 | fFB.setWHZ(24*2, 16*2, fZoom); |
reed | bb88674 | 2015-08-15 07:42:31 -0700 | [diff] [blame] | 373 | fPts[0].set(1, 1); |
| 374 | fPts[1].set(5, 4); |
| 375 | fPts[2].set(2, 6); |
reed | 8716a8a | 2016-09-19 07:10:36 -0700 | [diff] [blame] | 376 | SkMatrix::MakeScale(SkIntToScalar(fZoom)).mapPoints(fPts, 3); |
reed@google.com | cdbcb3e | 2012-10-22 22:10:20 +0000 | [diff] [blame] | 377 | fIsRect = false; |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 378 | } |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 379 | |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 380 | void setStyle(FatBits::Style s) { |
| 381 | fFB.setStyle(s); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 382 | this->inval(nullptr); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | protected: |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 386 | bool onQuery(SkEvent* evt) override { |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 387 | if (SampleCode::TitleQ(*evt)) { |
| 388 | SampleCode::TitleR(evt, "FatBits"); |
| 389 | return true; |
| 390 | } |
| 391 | SkUnichar uni; |
| 392 | if (SampleCode::CharQ(*evt, &uni)) { |
| 393 | switch (uni) { |
reed@google.com | 9c0bef1 | 2012-11-02 19:59:18 +0000 | [diff] [blame] | 394 | case 'c': |
| 395 | fFB.setUseClip(!fFB.getUseClip()); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 396 | this->inval(nullptr); |
reed@google.com | 9c0bef1 | 2012-11-02 19:59:18 +0000 | [diff] [blame] | 397 | return true; |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 398 | case 'r': |
| 399 | fIsRect = !fIsRect; |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 400 | this->inval(nullptr); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 401 | return true; |
mike@reedtribe.org | 64494e9 | 2013-03-06 02:18:33 +0000 | [diff] [blame] | 402 | case 'o': |
| 403 | fFB.toggleRectAsOval(); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 404 | this->inval(nullptr); |
mike@reedtribe.org | 64494e9 | 2013-03-06 02:18:33 +0000 | [diff] [blame] | 405 | return true; |
reed@google.com | c83e352 | 2012-10-22 22:00:08 +0000 | [diff] [blame] | 406 | case 'x': |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 407 | fFB.setGrid(!fFB.getGrid()); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 408 | this->inval(nullptr); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 409 | return true; |
| 410 | case 's': |
| 411 | if (FatBits::kStroke_Style == fFB.getStyle()) { |
| 412 | this->setStyle(FatBits::kHair_Style); |
| 413 | } else { |
| 414 | this->setStyle(FatBits::kStroke_Style); |
| 415 | } |
| 416 | return true; |
reed | a5d1207 | 2015-11-16 18:57:18 -0800 | [diff] [blame] | 417 | case 'k': { |
| 418 | const SkPaint::Cap caps[] = { |
| 419 | SkPaint::kButt_Cap, SkPaint::kRound_Cap, SkPaint::kSquare_Cap, |
| 420 | }; |
| 421 | fFB.fStrokeCap = caps[(fFB.fStrokeCap + 1) % 3]; |
| 422 | this->inval(nullptr); |
| 423 | return true; |
| 424 | } break; |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 425 | case 'a': |
| 426 | fFB.setAA(!fFB.getAA()); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 427 | this->inval(nullptr); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 428 | return true; |
reed@google.com | c83e352 | 2012-10-22 22:00:08 +0000 | [diff] [blame] | 429 | case 'w': |
| 430 | fFB.setShowSkeleton(!fFB.getShowSkeleton()); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 431 | this->inval(nullptr); |
reed@google.com | c83e352 | 2012-10-22 22:00:08 +0000 | [diff] [blame] | 432 | return true; |
| 433 | case 'g': |
reed | 8716a8a | 2016-09-19 07:10:36 -0700 | [diff] [blame] | 434 | fFB.togglePixelColors(); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 435 | this->inval(nullptr); |
reed@google.com | c83e352 | 2012-10-22 22:00:08 +0000 | [diff] [blame] | 436 | return true; |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 437 | case 't': |
| 438 | fFB.setTriangle(!fFB.getTriangle()); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 439 | this->inval(nullptr); |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 440 | return true; |
Mike Reed | ce54bce | 2017-11-01 21:17:11 -0400 | [diff] [blame] | 441 | case '-': |
| 442 | fFB.fStrokeWidth -= 0.125f; |
| 443 | this->inval(nullptr); |
| 444 | return true; |
| 445 | case '=': |
| 446 | fFB.fStrokeWidth += 0.125f; |
| 447 | this->inval(nullptr); |
| 448 | return true; |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 449 | } |
| 450 | } |
| 451 | return this->INHERITED::onQuery(evt); |
| 452 | } |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 453 | |
mtklein | f059900 | 2015-07-13 06:18:39 -0700 | [diff] [blame] | 454 | void onDrawContent(SkCanvas* canvas) override { |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 455 | fFB.drawBG(canvas); |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 456 | if (fFB.getTriangle()) { |
| 457 | fFB.drawTriangle(canvas, fPts); |
| 458 | } |
| 459 | else if (fIsRect) { |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 460 | fFB.drawRect(canvas, fPts); |
| 461 | } else { |
| 462 | fFB.drawLine(canvas, fPts); |
| 463 | } |
| 464 | fFB.drawFG(canvas); |
skia.committer@gmail.com | 1e34ff7 | 2012-10-24 02:01:24 +0000 | [diff] [blame] | 465 | |
reed@google.com | ffe9d01 | 2012-10-23 15:33:41 +0000 | [diff] [blame] | 466 | { |
| 467 | SkString str; |
reed | 8716a8a | 2016-09-19 07:10:36 -0700 | [diff] [blame] | 468 | str.printf("%s %s %s", |
reed@google.com | ffe9d01 | 2012-10-23 15:33:41 +0000 | [diff] [blame] | 469 | fFB.getAA() ? "AA" : "BW", |
| 470 | FatBits::kHair_Style == fFB.getStyle() ? "Hair" : "Stroke", |
reed@google.com | 9c0bef1 | 2012-11-02 19:59:18 +0000 | [diff] [blame] | 471 | fFB.getUseClip() ? "clip" : "noclip"); |
reed@google.com | ffe9d01 | 2012-10-23 15:33:41 +0000 | [diff] [blame] | 472 | SkPaint paint; |
| 473 | paint.setAntiAlias(true); |
| 474 | paint.setTextSize(16); |
| 475 | paint.setColor(SK_ColorBLUE); |
Cary Clark | 2a475ea | 2017-04-28 15:35:12 -0400 | [diff] [blame] | 476 | canvas->drawString(str, 10, 16, paint); |
reed@google.com | ffe9d01 | 2012-10-23 15:33:41 +0000 | [diff] [blame] | 477 | } |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 478 | } |
| 479 | |
mtklein | f059900 | 2015-07-13 06:18:39 -0700 | [diff] [blame] | 480 | SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override { |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 481 | SkPoint pt = { x, y }; |
| 482 | int index = -1; |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 483 | int count = fFB.getTriangle() ? 3 : 2; |
reed@google.com | cdbcb3e | 2012-10-22 22:10:20 +0000 | [diff] [blame] | 484 | SkScalar tol = 12; |
skia.committer@gmail.com | 7ed98df | 2013-10-31 07:01:53 +0000 | [diff] [blame] | 485 | |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 486 | for (int i = 0; i < count; ++i) { |
Cary Clark | df429f3 | 2017-11-08 11:44:31 -0500 | [diff] [blame] | 487 | if (SkPointPriv::EqualsWithinTolerance(fPts[i], pt, tol)) { |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 488 | index = i; |
| 489 | break; |
| 490 | } |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 491 | } |
mike@reedtribe.org | c892a15 | 2012-10-23 03:10:46 +0000 | [diff] [blame] | 492 | return new IndexClick(this, index); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 493 | } |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 494 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 495 | bool onClick(Click* click) override { |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 496 | int index = IndexClick::GetIndex(click); |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 497 | if (index >= 0 && index <= 2) { |
mike@reedtribe.org | c892a15 | 2012-10-23 03:10:46 +0000 | [diff] [blame] | 498 | fPts[index] = click->fCurr; |
| 499 | } else { |
| 500 | SkScalar dx = click->fCurr.fX - click->fPrev.fX; |
| 501 | SkScalar dy = click->fCurr.fY - click->fPrev.fY; |
| 502 | fPts[0].offset(dx, dy); |
| 503 | fPts[1].offset(dx, dy); |
reed@google.com | bbe66f0 | 2013-10-30 13:41:19 +0000 | [diff] [blame] | 504 | fPts[2].offset(dx, dy); |
mike@reedtribe.org | c892a15 | 2012-10-23 03:10:46 +0000 | [diff] [blame] | 505 | } |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 506 | this->inval(nullptr); |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 507 | return true; |
| 508 | } |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 509 | |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 510 | private: |
skia.committer@gmail.com | 45ba2f7 | 2012-10-23 02:01:22 +0000 | [diff] [blame] | 511 | |
mike@reedtribe.org | 50e4c72 | 2012-10-22 03:59:34 +0000 | [diff] [blame] | 512 | typedef SampleView INHERITED; |
| 513 | }; |
| 514 | |
| 515 | ////////////////////////////////////////////////////////////////////////////// |
| 516 | |
| 517 | static SkView* MyFactory() { return new DrawLineView; } |
| 518 | static SkViewRegister reg(MyFactory); |