OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkBitmapSource.h" | 8 #include "SkBitmapSource.h" |
9 #include "SkDisplacementMapEffect.h" | 9 #include "SkDisplacementMapEffect.h" |
10 #include "gm.h" | 10 #include "gm.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 canvas->clipRect(SkRect::MakeWH(SkIntToScalar(fBitmap.width()), SkIntToS
calar(fBitmap.height()))); | 61 canvas->clipRect(SkRect::MakeWH(SkIntToScalar(fBitmap.width()), SkIntToS
calar(fBitmap.height()))); |
62 canvas->drawBitmap(fBitmap, 0, 0, &paint); | 62 canvas->drawBitmap(fBitmap, 0, 0, &paint); |
63 canvas->restore(); | 63 canvas->restore(); |
64 } | 64 } |
65 | 65 |
66 virtual void onDraw(SkCanvas* canvas) { | 66 virtual void onDraw(SkCanvas* canvas) { |
67 if (!fInitialized) { | 67 if (!fInitialized) { |
68 make_bitmaps(); | 68 make_bitmaps(); |
69 fInitialized = true; | 69 fInitialized = true; |
70 } | 70 } |
71 canvas->clear(0x00000000); | 71 canvas->clear(SK_ColorBLACK); |
72 SkPaint paint; | 72 SkPaint paint; |
73 SkAutoTUnref<SkImageFilter> displ(SkBitmapSource::Create(fCheckerboard))
; | 73 SkAutoTUnref<SkImageFilter> displ(SkBitmapSource::Create(fCheckerboard))
; |
74 paint.setImageFilter(SkDisplacementMapEffect::Create( | 74 paint.setImageFilter(SkDisplacementMapEffect::Create( |
75 SkDisplacementMapEffect::kR_ChannelSelectorType, | 75 SkDisplacementMapEffect::kR_ChannelSelectorType, |
76 SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ))->unre
f(); | 76 SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ))->unre
f(); |
77 drawClippedBitmap(canvas, 0, 0, paint); | 77 drawClippedBitmap(canvas, 0, 0, paint); |
78 paint.setImageFilter(SkDisplacementMapEffect::Create( | 78 paint.setImageFilter(SkDisplacementMapEffect::Create( |
79 SkDisplacementMapEffect::kB_ChannelSelectorType, | 79 SkDisplacementMapEffect::kB_ChannelSelectorType, |
80 SkDisplacementMapEffect::kA_ChannelSelectorType, 16.0f, displ))->unr
ef(); | 80 SkDisplacementMapEffect::kA_ChannelSelectorType, 16.0f, displ))->unr
ef(); |
81 drawClippedBitmap(canvas, 100, 0, paint); | 81 drawClippedBitmap(canvas, 100, 0, paint); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 SkBitmap fBitmap, fCheckerboard, fSmall, fLarge, fLargeW, fLargeH; | 207 SkBitmap fBitmap, fCheckerboard, fSmall, fLarge, fLargeW, fLargeH; |
208 bool fInitialized; | 208 bool fInitialized; |
209 }; | 209 }; |
210 | 210 |
211 ////////////////////////////////////////////////////////////////////////////// | 211 ////////////////////////////////////////////////////////////////////////////// |
212 | 212 |
213 static GM* MyFactory(void*) { return new DisplacementMapGM; } | 213 static GM* MyFactory(void*) { return new DisplacementMapGM; } |
214 static GMRegistry reg(MyFactory); | 214 static GMRegistry reg(MyFactory); |
215 | 215 |
216 } | 216 } |
OLD | NEW |