| OLD | NEW |
| 1 | |
| 2 /* | 1 /* |
| 3 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 4 * | 3 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 7 */ | 6 */ |
| 8 #include "SampleCode.h" | 7 #include "SampleCode.h" |
| 9 #include "SkView.h" | 8 #include "SkView.h" |
| 10 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 11 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
| 12 #include "SkPath.h" | 11 #include "SkPath.h" |
| 13 #include "SkRegion.h" | 12 #include "SkRegion.h" |
| 14 #include "SkShader.h" | 13 #include "SkShader.h" |
| 15 #include "SkUtils.h" | 14 #include "SkUtils.h" |
| 16 #include "SkImageDecoder.h" | 15 #include "SkImageDecoder.h" |
| 17 | 16 |
| 17 #include <math.h> |
| 18 |
| 18 static void test_strokerect(SkCanvas* canvas) { | 19 static void test_strokerect(SkCanvas* canvas) { |
| 19 int width = 100; | 20 int width = 100; |
| 20 int height = 100; | 21 int height = 100; |
| 21 | 22 |
| 22 SkBitmap bitmap; | 23 SkBitmap bitmap; |
| 23 bitmap.allocPixels(SkImageInfo::MakeA8(width*2, height*2)); | 24 bitmap.allocPixels(SkImageInfo::MakeA8(width*2, height*2)); |
| 24 bitmap.eraseColor(SK_ColorTRANSPARENT); | 25 bitmap.eraseColor(SK_ColorTRANSPARENT); |
| 25 | 26 |
| 26 SkScalar dx = 20; | 27 SkScalar dx = 20; |
| 27 SkScalar dy = 20; | 28 SkScalar dy = 20; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 SK_ARRAY_COUNT(colors), | 109 SK_ARRAY_COUNT(colors), |
| 109 SkShader::kClamp_TileMode); | 110 SkShader::kClamp_TileMode); |
| 110 paint.setShader(s)->unref(); | 111 paint.setShader(s)->unref(); |
| 111 canvas->drawText(str, len, x, y, paint); | 112 canvas->drawText(str, len, x, y, paint); |
| 112 | 113 |
| 113 y += 20; | 114 y += 20; |
| 114 paint.setShader(NULL); | 115 paint.setShader(NULL); |
| 115 drawFadingText(canvas, str, len, x, y, paint); | 116 drawFadingText(canvas, str, len, x, y, paint); |
| 116 } | 117 } |
| 117 | 118 |
| 118 #ifdef SK_BUILD_FOR_WIN | |
| 119 // windows doesn't have roundf | |
| 120 inline float roundf(float x) { return (x-floor(x))>0.5 ? ceil(x) : floor(x); } | |
| 121 #endif | |
| 122 | |
| 123 #ifdef SK_DEBUG | 119 #ifdef SK_DEBUG |
| 124 static void make_rgn(SkRegion* rgn, int left, int top, int right, int bottom, | 120 static void make_rgn(SkRegion* rgn, int left, int top, int right, int bottom, |
| 125 int count, int32_t runs[]) { | 121 int count, int32_t runs[]) { |
| 126 SkIRect r; | 122 SkIRect r; |
| 127 r.set(left, top, right, bottom); | 123 r.set(left, top, right, bottom); |
| 128 | 124 |
| 129 rgn->debugSetRuns(runs, count); | 125 rgn->debugSetRuns(runs, count); |
| 130 SkASSERT(rgn->getBounds() == r); | 126 SkASSERT(rgn->getBounds() == r); |
| 131 } | 127 } |
| 132 | 128 |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 private: | 405 private: |
| 410 SkIRect fBase, fRect; | 406 SkIRect fBase, fRect; |
| 411 | 407 |
| 412 typedef SampleView INHERITED; | 408 typedef SampleView INHERITED; |
| 413 }; | 409 }; |
| 414 | 410 |
| 415 ////////////////////////////////////////////////////////////////////////////// | 411 ////////////////////////////////////////////////////////////////////////////// |
| 416 | 412 |
| 417 static SkView* MyFactory() { return new RegionView; } | 413 static SkView* MyFactory() { return new RegionView; } |
| 418 static SkViewRegister reg(MyFactory); | 414 static SkViewRegister reg(MyFactory); |
| OLD | NEW |