OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * 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 |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "gm.h" | 8 #include "gm.h" |
9 | 9 |
10 #include "Resources.h" | 10 #include "Resources.h" |
11 #include "SkBitmapProcState.h" | 11 #include "SkBitmapProcState.h" |
12 #include "SkBitmapScaler.h" | 12 #include "SkBitmapScaler.h" |
13 #include "SkGradientShader.h" | 13 #include "SkGradientShader.h" |
14 #include "SkImageDecoder.h" | 14 #include "SkImageDecoder.h" |
15 #include "SkImageEncoder.h" | 15 #include "SkImageEncoder.h" |
16 #include "SkStream.h" | 16 #include "SkStream.h" |
17 #include "SkTypeface.h" | 17 #include "SkTypeface.h" |
18 | 18 |
19 static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) { | 19 static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) { |
20 SkRect bounds = SkRect::MakeWH(SkIntToScalar(bm.width()), | 20 SkRect bounds = SkRect::MakeWH(SkIntToScalar(bm.width()), |
21 SkIntToScalar(bm.height())); | 21 SkIntToScalar(bm.height())); |
22 mat.mapRect(&bounds); | 22 mat.mapRect(&bounds); |
23 return SkSize::Make(bounds.width(), bounds.height()); | 23 return SkSize::Make(bounds.width(), bounds.height()); |
24 } | 24 } |
25 | 25 |
26 static void draw_row(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat,
SkScalar dx) { | 26 static void draw_cell(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat,
SkScalar dx, |
| 27 SkPaint::FilterLevel lvl) { |
27 SkPaint paint; | 28 SkPaint paint; |
| 29 paint.setFilterLevel(lvl); |
28 | 30 |
29 SkAutoCanvasRestore acr(canvas, true); | 31 SkAutoCanvasRestore acr(canvas, true); |
30 | 32 |
31 canvas->drawBitmapMatrix(bm, mat, &paint); | 33 canvas->translate(dx, 0); |
| 34 canvas->concat(mat); |
| 35 canvas->drawBitmap(bm, 0, 0, &paint); |
| 36 } |
32 | 37 |
33 paint.setFilterLevel(SkPaint::kLow_FilterLevel); | 38 static void draw_row(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat,
SkScalar dx) { |
34 canvas->translate(dx, 0); | 39 draw_cell(canvas, bm, mat, 0 * dx, SkPaint::kNone_FilterLevel); |
35 canvas->drawBitmapMatrix(bm, mat, &paint); | 40 draw_cell(canvas, bm, mat, 1 * dx, SkPaint::kLow_FilterLevel); |
36 | 41 draw_cell(canvas, bm, mat, 2 * dx, SkPaint::kMedium_FilterLevel); |
37 paint.setFilterLevel(SkPaint::kMedium_FilterLevel); | 42 draw_cell(canvas, bm, mat, 3 * dx, SkPaint::kHigh_FilterLevel); |
38 canvas->translate(dx, 0); | |
39 canvas->drawBitmapMatrix(bm, mat, &paint); | |
40 | |
41 paint.setFilterLevel(SkPaint::kHigh_FilterLevel); | |
42 canvas->translate(dx, 0); | |
43 canvas->drawBitmapMatrix(bm, mat, &paint); | |
44 } | 43 } |
45 | 44 |
46 class FilterIndiaBoxGM : public skiagm::GM { | 45 class FilterIndiaBoxGM : public skiagm::GM { |
47 void onOnceBeforeDraw() { | 46 void onOnceBeforeDraw() { |
48 this->makeBitmap(); | 47 this->makeBitmap(); |
49 | 48 |
50 SkScalar cx = SkScalarHalf(fBM.width()); | 49 SkScalar cx = SkScalarHalf(fBM.width()); |
51 SkScalar cy = SkScalarHalf(fBM.height()); | 50 SkScalar cy = SkScalarHalf(fBM.height()); |
52 | 51 |
53 float vertScale = 30.0f/55.0f; | 52 float vertScale = 30.0f/55.0f; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 fSize = fBM.height(); | 123 fSize = fBM.height(); |
125 } | 124 } |
126 private: | 125 private: |
127 typedef skiagm::GM INHERITED; | 126 typedef skiagm::GM INHERITED; |
128 }; | 127 }; |
129 | 128 |
130 ////////////////////////////////////////////////////////////////////////////// | 129 ////////////////////////////////////////////////////////////////////////////// |
131 | 130 |
132 | 131 |
133 DEF_GM( return new FilterIndiaBoxGM("box.gif"); ) | 132 DEF_GM( return new FilterIndiaBoxGM("box.gif"); ) |
OLD | NEW |