| 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 "gm.h" | 8 #include "gm.h" |
| 9 | 9 |
| 10 #include "SkBitmapSource.h" | 10 #include "SkBitmapSource.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 static void fillRectFiltered(SkCanvas* canvas, const SkRect& clipRect, SkIma
geFilter* filter) { | 43 static void fillRectFiltered(SkCanvas* canvas, const SkRect& clipRect, SkIma
geFilter* filter) { |
| 44 SkPaint paint; | 44 SkPaint paint; |
| 45 paint.setImageFilter(filter); | 45 paint.setImageFilter(filter); |
| 46 canvas->save(); | 46 canvas->save(); |
| 47 canvas->clipRect(clipRect); | 47 canvas->clipRect(clipRect); |
| 48 canvas->drawPaint(paint); | 48 canvas->drawPaint(paint); |
| 49 canvas->restore(); | 49 canvas->restore(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void onDraw(SkCanvas* canvas) override { | 52 void onDraw(SkCanvas* canvas) override { |
| 53 canvas->clear(0x00000000); | 53 canvas->clear(SK_ColorBLACK); |
| 54 { | 54 { |
| 55 SkRect srcRect = SkRect::MakeXYWH(20, 20, 30, 30); | 55 SkRect srcRect = SkRect::MakeXYWH(20, 20, 30, 30); |
| 56 SkRect dstRect = SkRect::MakeXYWH(0, 10, 60, 60); | 56 SkRect dstRect = SkRect::MakeXYWH(0, 10, 60, 60); |
| 57 SkRect clipRect = SkRect::MakeXYWH(0, 0, 100, 100); | 57 SkRect clipRect = SkRect::MakeXYWH(0, 0, 100, 100); |
| 58 SkRect bounds; | 58 SkRect bounds; |
| 59 fBitmap.getBounds(&bounds); | 59 fBitmap.getBounds(&bounds); |
| 60 SkAutoTUnref<SkImageFilter> bitmapSource(SkBitmapSource::Create(fBit
map)); | 60 SkAutoTUnref<SkImageFilter> bitmapSource(SkBitmapSource::Create(fBit
map)); |
| 61 SkAutoTUnref<SkImageFilter> bitmapSourceSrcRect(SkBitmapSource::Crea
te(fBitmap, srcRect, srcRect)); | 61 SkAutoTUnref<SkImageFilter> bitmapSourceSrcRect(SkBitmapSource::Crea
te(fBitmap, srcRect, srcRect)); |
| 62 SkAutoTUnref<SkImageFilter> bitmapSourceSrcRectDstRect(SkBitmapSourc
e::Create(fBitmap, srcRect, dstRect)); | 62 SkAutoTUnref<SkImageFilter> bitmapSourceSrcRectDstRect(SkBitmapSourc
e::Create(fBitmap, srcRect, dstRect)); |
| 63 SkAutoTUnref<SkImageFilter> bitmapSourceDstRectOnly(SkBitmapSource::
Create(fBitmap, bounds, dstRect)); | 63 SkAutoTUnref<SkImageFilter> bitmapSourceDstRectOnly(SkBitmapSource::
Create(fBitmap, bounds, dstRect)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 81 } | 81 } |
| 82 | 82 |
| 83 private: | 83 private: |
| 84 SkBitmap fBitmap; | 84 SkBitmap fBitmap; |
| 85 typedef GM INHERITED; | 85 typedef GM INHERITED; |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 /////////////////////////////////////////////////////////////////////////////// | 88 /////////////////////////////////////////////////////////////////////////////// |
| 89 | 89 |
| 90 DEF_GM( return new BitmapSourceGM; ) | 90 DEF_GM( return new BitmapSourceGM; ) |
| OLD | NEW |