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. |
34 SkAutoDataUnref data(fileToData("/Users/mike/Downloads/skia.google.jpeg")); | 37 SkAutoDataUnref data(fileToData("/Users/mike/Downloads/skia.google.jpeg")); |
35 SkImage* image = SkImage::NewEncodedData(data); | 38 SkImage* image = SkImage::NewEncodedData(data); |
36 if (image) { | 39 if (image) { |
37 SkAutoCanvasRestore acr(canvas, true); | 40 SkAutoCanvasRestore acr(canvas, true); |
38 canvas->scale(size.width() * 1.0f / image->width(), | 41 canvas->scale(size.width() * 1.0f / image->width(), |
39 size.height() * 1.0f / image->height()); | 42 size.height() * 1.0f / image->height()); |
40 image->draw(canvas,0, 0, NULL); | 43 image->draw(canvas,0, 0, NULL); |
41 image->unref(); | 44 image->unref(); |
42 } | 45 } |
43 } | 46 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 } | 188 } |
186 | 189 |
187 private: | 190 private: |
188 typedef skiagm::GM INHERITED; | 191 typedef skiagm::GM INHERITED; |
189 }; | 192 }; |
190 | 193 |
191 ////////////////////////////////////////////////////////////////////////////// | 194 ////////////////////////////////////////////////////////////////////////////// |
192 | 195 |
193 static skiagm::GM* MyFactory(void*) { return new ImageGM; } | 196 static skiagm::GM* MyFactory(void*) { return new ImageGM; } |
194 static skiagm::GMRegistry reg(MyFactory); | 197 static skiagm::GMRegistry reg(MyFactory); |
OLD | NEW |