| 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" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 if (!stream.isValid()) { | 24 if (!stream.isValid()) { |
| 25 return SkData::NewEmpty(); | 25 return SkData::NewEmpty(); |
| 26 } | 26 } |
| 27 size_t size = stream.getLength(); | 27 size_t size = stream.getLength(); |
| 28 void* mem = sk_malloc_throw(size); | 28 void* mem = sk_malloc_throw(size); |
| 29 stream.read(mem, size); | 29 stream.read(mem, size); |
| 30 return SkData::NewFromMalloc(mem, size); | 30 return SkData::NewFromMalloc(mem, size); |
| 31 } | 31 } |
| 32 | 32 |
| 33 static void drawJpeg(SkCanvas* canvas, const SkISize& size) { | 33 static void drawJpeg(SkCanvas* canvas, const SkISize& size) { |
| 34 // TODO: Make this draw a file that is checked in, so it can | |
| 35 // be exercised on machines other than mike's. Will require a | |
| 36 // rebaseline. | |
| 37 SkAutoDataUnref data(fileToData("/Users/mike/Downloads/skia.google.jpeg")); | 34 SkAutoDataUnref data(fileToData("/Users/mike/Downloads/skia.google.jpeg")); |
| 38 SkImage* image = SkImage::NewEncodedData(data); | 35 SkImage* image = SkImage::NewEncodedData(data); |
| 39 if (image) { | 36 if (image) { |
| 40 SkAutoCanvasRestore acr(canvas, true); | 37 SkAutoCanvasRestore acr(canvas, true); |
| 41 canvas->scale(size.width() * 1.0f / image->width(), | 38 canvas->scale(size.width() * 1.0f / image->width(), |
| 42 size.height() * 1.0f / image->height()); | 39 size.height() * 1.0f / image->height()); |
| 43 image->draw(canvas,0, 0, NULL); | 40 image->draw(canvas,0, 0, NULL); |
| 44 image->unref(); | 41 image->unref(); |
| 45 } | 42 } |
| 46 } | 43 } |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 } | 185 } |
| 189 | 186 |
| 190 private: | 187 private: |
| 191 typedef skiagm::GM INHERITED; | 188 typedef skiagm::GM INHERITED; |
| 192 }; | 189 }; |
| 193 | 190 |
| 194 ////////////////////////////////////////////////////////////////////////////// | 191 ////////////////////////////////////////////////////////////////////////////// |
| 195 | 192 |
| 196 static skiagm::GM* MyFactory(void*) { return new ImageGM; } | 193 static skiagm::GM* MyFactory(void*) { return new ImageGM; } |
| 197 static skiagm::GMRegistry reg(MyFactory); | 194 static skiagm::GMRegistry reg(MyFactory); |
| OLD | NEW |