Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Side by Side Diff: gm/image.cpp

Issue 15740024: Reland 'Add path utils, plus a test for it.' (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698