| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 } | 49 } |
| 50 | 50 |
| 51 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 51 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 52 canvas->clear(0x00000000); | 52 canvas->clear(0x00000000); |
| 53 { | 53 { |
| 54 SkRect srcRect = SkRect::MakeXYWH(20, 20, 30, 30); | 54 SkRect srcRect = SkRect::MakeXYWH(20, 20, 30, 30); |
| 55 SkRect dstRect = SkRect::MakeXYWH(0, 10, 60, 60); | 55 SkRect dstRect = SkRect::MakeXYWH(0, 10, 60, 60); |
| 56 SkRect clipRect = SkRect::MakeXYWH(0, 0, 100, 100); | 56 SkRect clipRect = SkRect::MakeXYWH(0, 0, 100, 100); |
| 57 SkRect bounds; | 57 SkRect bounds; |
| 58 fBitmap.getBounds(&bounds); | 58 fBitmap.getBounds(&bounds); |
| 59 SkAutoTUnref<SkImageFilter> bitmapSource(new SkBitmapSource(fBitmap)
); | 59 SkAutoTUnref<SkImageFilter> bitmapSource(SkBitmapSource::Create(fBit
map)); |
| 60 SkAutoTUnref<SkImageFilter> bitmapSourceSrcRect(new SkBitmapSource(f
Bitmap, srcRect, srcRect)); | 60 SkAutoTUnref<SkImageFilter> bitmapSourceSrcRect(SkBitmapSource::Crea
te(fBitmap, srcRect, srcRect)); |
| 61 SkAutoTUnref<SkImageFilter> bitmapSourceSrcRectDstRect(new SkBitmapS
ource(fBitmap, srcRect, dstRect)); | 61 SkAutoTUnref<SkImageFilter> bitmapSourceSrcRectDstRect(SkBitmapSourc
e::Create(fBitmap, srcRect, dstRect)); |
| 62 SkAutoTUnref<SkImageFilter> bitmapSourceDstRectOnly(new SkBitmapSour
ce(fBitmap, bounds, dstRect)); | 62 SkAutoTUnref<SkImageFilter> bitmapSourceDstRectOnly(SkBitmapSource::
Create(fBitmap, bounds, dstRect)); |
| 63 | 63 |
| 64 // Draw an unscaled bitmap. | 64 // Draw an unscaled bitmap. |
| 65 fillRectFiltered(canvas, clipRect, bitmapSource); | 65 fillRectFiltered(canvas, clipRect, bitmapSource); |
| 66 canvas->translate(SkIntToScalar(100), 0); | 66 canvas->translate(SkIntToScalar(100), 0); |
| 67 | 67 |
| 68 // Draw an unscaled subset of the source bitmap (srcRect -> srcRect)
. | 68 // Draw an unscaled subset of the source bitmap (srcRect -> srcRect)
. |
| 69 fillRectFiltered(canvas, clipRect, bitmapSourceSrcRect); | 69 fillRectFiltered(canvas, clipRect, bitmapSourceSrcRect); |
| 70 canvas->translate(SkIntToScalar(100), 0); | 70 canvas->translate(SkIntToScalar(100), 0); |
| 71 | 71 |
| 72 // Draw a subset of the bitmap scaled to a destination rect (srcRect
-> dstRect). | 72 // Draw a subset of the bitmap scaled to a destination rect (srcRect
-> dstRect). |
| 73 fillRectFiltered(canvas, clipRect, bitmapSourceSrcRectDstRect); | 73 fillRectFiltered(canvas, clipRect, bitmapSourceSrcRectDstRect); |
| 74 canvas->translate(SkIntToScalar(100), 0); | 74 canvas->translate(SkIntToScalar(100), 0); |
| 75 | 75 |
| 76 // Draw the entire bitmap scaled to a destination rect (bounds -> ds
tRect). | 76 // Draw the entire bitmap scaled to a destination rect (bounds -> ds
tRect). |
| 77 fillRectFiltered(canvas, clipRect, bitmapSourceDstRectOnly); | 77 fillRectFiltered(canvas, clipRect, bitmapSourceDstRectOnly); |
| 78 canvas->translate(SkIntToScalar(100), 0); | 78 canvas->translate(SkIntToScalar(100), 0); |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 SkBitmap fBitmap; | 83 SkBitmap fBitmap; |
| 84 typedef GM INHERITED; | 84 typedef GM INHERITED; |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 /////////////////////////////////////////////////////////////////////////////// | 87 /////////////////////////////////////////////////////////////////////////////// |
| 88 | 88 |
| 89 DEF_GM( return new BitmapSourceGM; ) | 89 DEF_GM( return new BitmapSourceGM; ) |
| OLD | NEW |