epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2011 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 8 | #include "SampleCode.h" |
| 9 | #include "SkView.h" |
| 10 | #include "SkCanvas.h" |
| 11 | #include "Sk64.h" |
| 12 | #include "SkGradientShader.h" |
| 13 | #include "SkGraphics.h" |
| 14 | #include "SkImageDecoder.h" |
| 15 | #include "SkKernel33MaskFilter.h" |
| 16 | #include "SkPath.h" |
| 17 | #include "SkRandom.h" |
| 18 | #include "SkRegion.h" |
| 19 | #include "SkShader.h" |
| 20 | #include "SkUtils.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 21 | #include "SkColorPriv.h" |
| 22 | #include "SkColorFilter.h" |
| 23 | #include "SkTime.h" |
| 24 | #include "SkTypeface.h" |
| 25 | #include "SkXfermode.h" |
| 26 | |
| 27 | #include "SkStream.h" |
| 28 | #include "SkXMLParser.h" |
| 29 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 30 | class ReduceNoise : public SkKernel33ProcMaskFilter { |
| 31 | public: |
| 32 | ReduceNoise(int percent256) : SkKernel33ProcMaskFilter(percent256) {} |
| 33 | virtual uint8_t computeValue(uint8_t* const* srcRows) |
| 34 | { |
| 35 | int c = srcRows[1][1]; |
| 36 | int min = 255, max = 0; |
| 37 | for (int i = 0; i < 3; i++) |
| 38 | for (int j = 0; j < 3; j++) |
| 39 | if (i != 1 || j != 1) |
| 40 | { |
| 41 | int v = srcRows[i][j]; |
| 42 | if (max < v) |
| 43 | max = v; |
| 44 | if (min > v) |
| 45 | min = v; |
| 46 | } |
| 47 | if (c > max) c = max; |
| 48 | // if (c < min) c = min; |
| 49 | return c; |
| 50 | } |
djsollen@google.com | ba28d03 | 2012-03-26 17:57:35 +0000 | [diff] [blame] | 51 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(ReduceNoise) |
| 52 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 53 | private: |
| 54 | ReduceNoise(SkFlattenableReadBuffer& rb) : SkKernel33ProcMaskFilter(rb) {} |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | class Darken : public SkKernel33ProcMaskFilter { |
| 58 | public: |
| 59 | Darken(int percent256) : SkKernel33ProcMaskFilter(percent256) {} |
| 60 | virtual uint8_t computeValue(uint8_t* const* srcRows) |
| 61 | { |
| 62 | int c = srcRows[1][1]; |
| 63 | float f = c / 255.f; |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 64 | |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 65 | if (c >= 0) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 66 | f = sqrtf(f); |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 67 | } else { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 68 | f *= f; |
| 69 | } |
| 70 | SkASSERT(f >= 0 && f <= 1); |
| 71 | return (int)(f * 255); |
| 72 | } |
djsollen@google.com | ba28d03 | 2012-03-26 17:57:35 +0000 | [diff] [blame] | 73 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Darken) |
| 74 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 75 | private: |
| 76 | Darken(SkFlattenableReadBuffer& rb) : SkKernel33ProcMaskFilter(rb) {} |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | static SkMaskFilter* makemf() { return new Darken(0x30); } |
| 80 | |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 81 | static void test_breakText() { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 82 | SkPaint paint; |
| 83 | const char* text = "sdfkljAKLDFJKEWkldfjlk#$%&sdfs.dsj"; |
| 84 | size_t length = strlen(text); |
| 85 | SkScalar width = paint.measureText(text, length); |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 86 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 87 | SkScalar mm = 0; |
| 88 | SkScalar nn = 0; |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 89 | for (SkScalar w = 0; w <= width; w += SK_Scalar1) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 90 | SkScalar m; |
| 91 | size_t n = paint.breakText(text, length, w, &m, |
| 92 | SkPaint::kBackward_TextBufferDirection); |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 93 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 94 | SkASSERT(n <= length); |
| 95 | SkASSERT(m <= width); |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 96 | |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 97 | if (n == 0) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 98 | SkASSERT(m == 0); |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 99 | } else { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 100 | // now assert that we're monotonic |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 101 | if (n == nn) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 102 | SkASSERT(m == mm); |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 103 | } else { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 104 | SkASSERT(n > nn); |
| 105 | SkASSERT(m > mm); |
| 106 | } |
| 107 | } |
tomhudson@google.com | ffe39bd | 2012-05-17 15:38:00 +0000 | [diff] [blame] | 108 | nn = SkIntToScalar((unsigned int)n); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 109 | mm = m; |
| 110 | } |
| 111 | |
senorblanco@chromium.org | 64cc579 | 2011-05-19 19:58:58 +0000 | [diff] [blame] | 112 | SkDEBUGCODE(size_t length2 =) paint.breakText(text, length, width, &mm); |
reed@google.com | 261b8e2 | 2011-04-14 17:53:24 +0000 | [diff] [blame] | 113 | SkASSERT(length2 == length); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 114 | SkASSERT(mm == width); |
| 115 | } |
| 116 | |
| 117 | static SkRandom gRand; |
| 118 | |
| 119 | class SkPowerMode : public SkXfermode { |
| 120 | public: |
| 121 | SkPowerMode(SkScalar exponent) { this->init(exponent); } |
| 122 | |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 123 | virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count, |
| 124 | const SkAlpha aa[]); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 125 | |
| 126 | typedef SkFlattenable* (*Factory)(SkFlattenableReadBuffer&); |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 127 | |
djsollen@google.com | ba28d03 | 2012-03-26 17:57:35 +0000 | [diff] [blame] | 128 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPowerMode) |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 129 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 130 | private: |
| 131 | SkScalar fExp; // user's value |
| 132 | uint8_t fTable[256]; // cache |
| 133 | |
| 134 | void init(SkScalar exponent); |
djsollen@google.com | 5492424 | 2012-03-29 15:18:04 +0000 | [diff] [blame] | 135 | SkPowerMode(SkFlattenableReadBuffer& b) : INHERITED(b) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 136 | // read the exponent |
| 137 | this->init(SkFixedToScalar(b.readS32())); |
| 138 | } |
djsollen@google.com | 5492424 | 2012-03-29 15:18:04 +0000 | [diff] [blame] | 139 | virtual void flatten(SkFlattenableWriteBuffer& b) const SK_OVERRIDE { |
| 140 | this->INHERITED::flatten(b); |
| 141 | b.write32(SkScalarToFixed(fExp)); |
| 142 | } |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 143 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 144 | typedef SkXfermode INHERITED; |
| 145 | }; |
| 146 | |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 147 | void SkPowerMode::init(SkScalar e) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 148 | fExp = e; |
| 149 | float ee = SkScalarToFloat(e); |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 150 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 151 | printf("------ %g\n", ee); |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 152 | for (int i = 0; i < 256; i++) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 153 | float x = i / 255.f; |
| 154 | // printf(" %d %g", i, x); |
| 155 | x = powf(x, ee); |
| 156 | // printf(" %g", x); |
| 157 | int xx = SkScalarRound(SkFloatToScalar(x * 255)); |
| 158 | // printf(" %d\n", xx); |
| 159 | fTable[i] = SkToU8(xx); |
| 160 | } |
| 161 | } |
| 162 | |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 163 | void SkPowerMode::xfer16(uint16_t dst[], const SkPMColor src[], int count, |
| 164 | const SkAlpha aa[]) { |
| 165 | for (int i = 0; i < count; i++) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 166 | SkPMColor c = src[i]; |
| 167 | int r = SkGetPackedR32(c); |
| 168 | int g = SkGetPackedG32(c); |
| 169 | int b = SkGetPackedB32(c); |
| 170 | r = fTable[r]; |
| 171 | g = fTable[g]; |
| 172 | b = fTable[b]; |
| 173 | dst[i] = SkPack888ToRGB16(r, g, b); |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | static const struct { |
| 178 | const char* fName; |
| 179 | uint32_t fFlags; |
| 180 | bool fFlushCache; |
| 181 | } gHints[] = { |
| 182 | { "Linear", SkPaint::kLinearText_Flag, false }, |
| 183 | { "Normal", 0, true }, |
| 184 | { "Subpixel", SkPaint::kSubpixelText_Flag, true } |
| 185 | }; |
| 186 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 187 | static void DrawTheText(SkCanvas* canvas, const char text[], size_t length, |
| 188 | SkScalar x, SkScalar y, const SkPaint& paint, |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 189 | SkScalar clickX, SkMaskFilter* mf) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 190 | SkPaint p(paint); |
| 191 | |
| 192 | #if 0 |
| 193 | canvas->drawText(text, length, x, y, paint); |
| 194 | #else |
| 195 | { |
| 196 | SkPoint pts[1000]; |
| 197 | SkScalar xpos = x; |
| 198 | SkASSERT(length <= SK_ARRAY_COUNT(pts)); |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 199 | for (size_t i = 0; i < length; i++) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 200 | pts[i].set(xpos, y), xpos += paint.getTextSize(); |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 201 | } |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 202 | canvas->drawPosText(text, length, pts, paint); |
| 203 | } |
| 204 | #endif |
| 205 | |
| 206 | p.setSubpixelText(true); |
| 207 | x += SkIntToScalar(180); |
| 208 | canvas->drawText(text, length, x, y, p); |
| 209 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 210 | #ifdef SK_DEBUG |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 211 | if (true) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 212 | // p.setMaskFilter(mf); |
| 213 | p.setSubpixelText(false); |
| 214 | p.setLinearText(true); |
| 215 | x += SkIntToScalar(180); |
| 216 | canvas->drawText(text, length, x, y, p); |
| 217 | } |
| 218 | #endif |
| 219 | } |
| 220 | |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 221 | class TextSpeedView : public SampleView { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 222 | public: |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 223 | TextSpeedView() { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 224 | fMF = makemf(); |
| 225 | |
| 226 | fHints = 0; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 227 | fClickX = 0; |
| 228 | |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 229 | test_breakText(); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 230 | } |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 231 | |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 232 | virtual ~TextSpeedView() { |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 233 | SkSafeUnref(fMF); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | protected: |
| 237 | // overrides from SkEventSink |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 238 | virtual bool onQuery(SkEvent* evt) { |
| 239 | if (SampleCode::TitleQ(*evt)) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 240 | SampleCode::TitleR(evt, "Text"); |
| 241 | return true; |
| 242 | } |
| 243 | return this->INHERITED::onQuery(evt); |
| 244 | } |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 245 | |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 246 | static void make_textstrip(SkBitmap* bm) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 247 | bm->setConfig(SkBitmap::kRGB_565_Config, 200, 18); |
| 248 | bm->allocPixels(); |
| 249 | bm->eraseColor(SK_ColorWHITE); |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 250 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 251 | SkCanvas canvas(*bm); |
| 252 | SkPaint paint; |
| 253 | const char* s = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit"; |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 254 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 255 | paint.setFlags(paint.getFlags() | SkPaint::kAntiAlias_Flag |
| 256 | | SkPaint::kDevKernText_Flag); |
| 257 | paint.setTextSize(SkIntToScalar(14)); |
| 258 | canvas.drawText(s, strlen(s), SkIntToScalar(8), SkIntToScalar(14), paint); |
| 259 | } |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 260 | |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 261 | static void fill_pts(SkPoint pts[], size_t n, SkRandom* rand) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 262 | for (size_t i = 0; i < n; i++) |
| 263 | pts[i].set(rand->nextUScalar1() * 640, rand->nextUScalar1() * 480); |
| 264 | } |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 265 | |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 266 | virtual void onDrawContent(SkCanvas* canvas) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 267 | SkAutoCanvasRestore restore(canvas, false); |
| 268 | { |
| 269 | SkRect r; |
| 270 | r.set(0, 0, SkIntToScalar(1000), SkIntToScalar(20)); |
| 271 | // canvas->saveLayer(&r, NULL, SkCanvas::kHasAlphaLayer_SaveFlag); |
| 272 | } |
| 273 | |
| 274 | SkPaint paint; |
| 275 | // const uint16_t glyphs[] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 }; |
| 276 | int index = fHints % SK_ARRAY_COUNT(gHints); |
| 277 | index = 1; |
| 278 | // const char* style = gHints[index].fName; |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 279 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 280 | // canvas->translate(0, SkIntToScalar(50)); |
| 281 | |
| 282 | // canvas->drawText(style, strlen(style), SkIntToScalar(20), SkIntToScalar(20), paint); |
| 283 | |
reed@android.com | 04d86c6 | 2010-01-25 22:02:44 +0000 | [diff] [blame] | 284 | SkSafeUnref(paint.setTypeface(SkTypeface::CreateFromFile("/skimages/samplefont.ttf"))); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 285 | paint.setAntiAlias(true); |
| 286 | paint.setFlags(paint.getFlags() | gHints[index].fFlags); |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 287 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 288 | SkRect clip; |
| 289 | clip.set(SkIntToScalar(25), SkIntToScalar(34), SkIntToScalar(88), SkIntToScalar(155)); |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 290 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 291 | const char* text = "Hamburgefons"; |
| 292 | size_t length = strlen(text); |
| 293 | |
reed@google.com | 2f3dc9d | 2011-05-02 17:33:45 +0000 | [diff] [blame] | 294 | SkScalar y = SkIntToScalar(0); |
| 295 | for (int i = 9; i <= 24; i++) { |
| 296 | paint.setTextSize(SkIntToScalar(i) /*+ (gRand.nextU() & 0xFFFF)*/); |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 297 | for (SkScalar dx = 0; dx <= SkIntToScalar(3)/4; |
| 298 | dx += SkIntToScalar(1) /* /4 */) { |
reed@google.com | 2f3dc9d | 2011-05-02 17:33:45 +0000 | [diff] [blame] | 299 | y += paint.getFontSpacing(); |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 300 | DrawTheText(canvas, text, length, SkIntToScalar(20) + dx, y, |
| 301 | paint, fClickX, fMF); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 302 | } |
| 303 | } |
reed@google.com | 2f3dc9d | 2011-05-02 17:33:45 +0000 | [diff] [blame] | 304 | if (gHints[index].fFlushCache) { |
| 305 | // SkGraphics::SetFontCacheUsed(0); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 306 | } |
| 307 | } |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 308 | |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 309 | virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 310 | fClickX = x; |
| 311 | this->inval(NULL); |
| 312 | return this->INHERITED::onFindClickHandler(x, y); |
| 313 | } |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 314 | |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 315 | virtual bool onClick(Click* click) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 316 | return this->INHERITED::onClick(click); |
| 317 | } |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 318 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 319 | private: |
| 320 | int fHints; |
| 321 | SkScalar fClickX; |
| 322 | SkMaskFilter* fMF; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 323 | |
reed@google.com | 9e39bb3 | 2011-05-18 12:17:53 +0000 | [diff] [blame] | 324 | typedef SampleView INHERITED; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 325 | }; |
| 326 | |
| 327 | ////////////////////////////////////////////////////////////////////////////// |
| 328 | |
| 329 | static SkView* MyFactory() { return new TextSpeedView; } |
| 330 | static SkViewRegister reg(MyFactory); |
| 331 | |