| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 #include "gm.h" | 8 #include "gm.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 canvas->translate(0, SkIntToScalar(bitmap.height() + 20)); | 67 canvas->translate(0, SkIntToScalar(bitmap.height() + 20)); |
| 68 canvas->drawBitmap(subset, 0, 0); | 68 canvas->drawBitmap(subset, 0, 0); |
| 69 // Now draw a subet which has the same width and pixelref offset but | 69 // Now draw a subet which has the same width and pixelref offset but |
| 70 // a different height | 70 // a different height |
| 71 bitmap.extractSubset(&subset, SkIRect::MakeWH(bitmap.height(), y)); | 71 bitmap.extractSubset(&subset, SkIRect::MakeWH(bitmap.height(), y)); |
| 72 canvas->translate(0, SkIntToScalar(bitmap.height() + 20)); | 72 canvas->translate(0, SkIntToScalar(bitmap.height() + 20)); |
| 73 canvas->drawBitmap(subset, 0, 0); | 73 canvas->drawBitmap(subset, 0, 0); |
| 74 } | 74 } |
| 75 | 75 |
| 76 // Now do the same but with a device bitmap as source image | 76 // Now do the same but with a device bitmap as source image |
| 77 SkAutoTUnref<SkDevice> secondDevice(canvas->createCompatibleDevice( | 77 SkAutoTUnref<SkBaseDevice> secondDevice(canvas->createCompatibleDevice( |
| 78 SkBitmap::kARGB_8888_Config, bitmap.width(), | 78 SkBitmap::kARGB_8888_Config, bitmap.width(), |
| 79 bitmap.height(), true)); | 79 bitmap.height(), true)); |
| 80 SkCanvas secondCanvas(secondDevice.get()); | 80 SkCanvas secondCanvas(secondDevice.get()); |
| 81 secondCanvas.writePixels(bitmap, 0, 0); | 81 secondCanvas.writePixels(bitmap, 0, 0); |
| 82 | 82 |
| 83 SkBitmap deviceBitmap = secondDevice->accessBitmap(false); | 83 SkBitmap deviceBitmap = secondDevice->accessBitmap(false); |
| 84 SkBitmap deviceSubset; | 84 SkBitmap deviceSubset; |
| 85 deviceBitmap.extractSubset(&deviceSubset, | 85 deviceBitmap.extractSubset(&deviceSubset, |
| 86 SkIRect::MakeXYWH(x, y, x, y)); | 86 SkIRect::MakeXYWH(x, y, x, y)); |
| 87 | 87 |
| 88 canvas->translate(SkIntToScalar(120), SkIntToScalar(0)); | 88 canvas->translate(SkIntToScalar(120), SkIntToScalar(0)); |
| 89 | 89 |
| 90 canvas->drawBitmap(deviceBitmap, 0, 0); | 90 canvas->drawBitmap(deviceBitmap, 0, 0); |
| 91 canvas->drawBitmap(deviceSubset, 0, 0); | 91 canvas->drawBitmap(deviceSubset, 0, 0); |
| 92 | 92 |
| 93 } | 93 } |
| 94 | 94 |
| 95 private: | 95 private: |
| 96 typedef GM INHERITED; | 96 typedef GM INHERITED; |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 ////////////////////////////////////////////////////////////////////////////// | 99 ////////////////////////////////////////////////////////////////////////////// |
| 100 | 100 |
| 101 static GM* MyFactory(void*) { return new ExtractBitmapGM; } | 101 static GM* MyFactory(void*) { return new ExtractBitmapGM; } |
| 102 static GMRegistry reg(MyFactory); | 102 static GMRegistry reg(MyFactory); |
| 103 | 103 |
| 104 } | 104 } |
| OLD | NEW |