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