| 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 #include "SkSurface.h" | 9 #include "SkSurface.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| 11 #include "SkDecodingImageGenerator.h" | |
| 12 #include "SkStream.h" | 11 #include "SkStream.h" |
| 13 #include "SkData.h" | 12 #include "SkData.h" |
| 14 | 13 |
| 15 #if SK_SUPPORT_GPU | 14 #if SK_SUPPORT_GPU |
| 16 #include "GrContext.h" | 15 #include "GrContext.h" |
| 17 #endif | 16 #endif |
| 18 | 17 |
| 19 static void drawJpeg(SkCanvas* canvas, const SkISize& size) { | 18 static void drawJpeg(SkCanvas* canvas, const SkISize& size) { |
| 20 // TODO: Make this draw a file that is checked in, so it can | 19 // TODO: Make this draw a file that is checked in, so it can |
| 21 // be exercised on machines other than mike's. Will require a | 20 // be exercised on machines other than mike's. Will require a |
| 22 // rebaseline. | 21 // rebaseline. |
| 23 SkAutoDataUnref data(SkData::NewFromFileName("/Users/mike/Downloads/skia.goo
gle.jpeg")); | 22 SkAutoDataUnref data(SkData::NewFromFileName("/Users/mike/Downloads/skia.goo
gle.jpeg")); |
| 24 if (NULL == data.get()) { | 23 if (NULL == data.get()) { |
| 25 return; | 24 return; |
| 26 } | 25 } |
| 27 SkImage* image = SkImage::NewFromGenerator( | 26 SkImage* image = SkImage::NewFromData(data); |
| 28 SkDecodingImageGenerator::Create(data, SkDecodingImageGenerator:
:Options())); | |
| 29 if (image) { | 27 if (image) { |
| 30 SkAutoCanvasRestore acr(canvas, true); | 28 SkAutoCanvasRestore acr(canvas, true); |
| 31 canvas->scale(size.width() * 1.0f / image->width(), | 29 canvas->scale(size.width() * 1.0f / image->width(), |
| 32 size.height() * 1.0f / image->height()); | 30 size.height() * 1.0f / image->height()); |
| 33 canvas->drawImage(image, 0, 0, NULL); | 31 canvas->drawImage(image, 0, 0, NULL); |
| 34 image->unref(); | 32 image->unref(); |
| 35 } | 33 } |
| 36 } | 34 } |
| 37 | 35 |
| 38 static void drawContents(SkSurface* surface, SkColor fillC) { | 36 static void drawContents(SkSurface* surface, SkColor fillC) { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 } | 196 } |
| 199 | 197 |
| 200 private: | 198 private: |
| 201 typedef skiagm::GM INHERITED; | 199 typedef skiagm::GM INHERITED; |
| 202 }; | 200 }; |
| 203 | 201 |
| 204 ////////////////////////////////////////////////////////////////////////////// | 202 ////////////////////////////////////////////////////////////////////////////// |
| 205 | 203 |
| 206 static skiagm::GM* MyFactory(void*) { return new ImageGM; } | 204 static skiagm::GM* MyFactory(void*) { return new ImageGM; } |
| 207 static skiagm::GMRegistry reg(MyFactory); | 205 static skiagm::GMRegistry reg(MyFactory); |
| OLD | NEW |