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

Side by Side Diff: samplecode/SampleApp.cpp

Issue 510423005: make allocPixels throw on failure (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 3 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
« no previous file with comments | « include/core/SkBitmap.h ('k') | samplecode/SampleFilterFuzz.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "SampleApp.h" 8 #include "SampleApp.h"
9 9
10 #include "OverView.h" 10 #include "OverView.h"
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 void SampleWindow::listTitles() { 992 void SampleWindow::listTitles() {
993 int count = fSamples.count(); 993 int count = fSamples.count();
994 SkDebugf("All Slides:\n"); 994 SkDebugf("All Slides:\n");
995 for (int i = 0; i < count; i++) { 995 for (int i = 0; i < count; i++) {
996 SkDebugf(" %s\n", getSampleTitle(i).c_str()); 996 SkDebugf(" %s\n", getSampleTitle(i).c_str());
997 } 997 }
998 } 998 }
999 999
1000 static SkBitmap capture_bitmap(SkCanvas* canvas) { 1000 static SkBitmap capture_bitmap(SkCanvas* canvas) {
1001 SkBitmap bm; 1001 SkBitmap bm;
1002 if (bm.allocPixels(canvas->imageInfo())) { 1002 if (bm.tryAllocPixels(canvas->imageInfo())) {
1003 canvas->readPixels(&bm, 0, 0); 1003 canvas->readPixels(&bm, 0, 0);
1004 } 1004 }
1005 return bm; 1005 return bm;
1006 } 1006 }
1007 1007
1008 static bool bitmap_diff(SkCanvas* canvas, const SkBitmap& orig, 1008 static bool bitmap_diff(SkCanvas* canvas, const SkBitmap& orig,
1009 SkBitmap* diff) { 1009 SkBitmap* diff) {
1010 SkBitmap src = capture_bitmap(canvas); 1010 SkBitmap src = capture_bitmap(canvas);
1011 1011
1012 SkAutoLockPixels alp0(src); 1012 SkAutoLockPixels alp0(src);
(...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after
2396 setenv("ANDROID_ROOT", "/android/device/data", 0); 2396 setenv("ANDROID_ROOT", "/android/device/data", 0);
2397 #endif 2397 #endif
2398 SkGraphics::Init(); 2398 SkGraphics::Init();
2399 SkEvent::Init(); 2399 SkEvent::Init();
2400 } 2400 }
2401 2401
2402 void application_term() { 2402 void application_term() {
2403 SkEvent::Term(); 2403 SkEvent::Term();
2404 SkGraphics::Term(); 2404 SkGraphics::Term();
2405 } 2405 }
OLDNEW
« no previous file with comments | « include/core/SkBitmap.h ('k') | samplecode/SampleFilterFuzz.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698