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

Side by Side Diff: tests/WritePixelsTest.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 | « tests/TextureCompressionTest.cpp ('k') | no next file » | 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 "SkBitmapDevice.h" 8 #include "SkBitmapDevice.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 r = SkMulDiv255Ceiling(r, a); 108 r = SkMulDiv255Ceiling(r, a);
109 g = SkMulDiv255Ceiling(g, a); 109 g = SkMulDiv255Ceiling(g, a);
110 b = SkMulDiv255Ceiling(b, a); 110 b = SkMulDiv255Ceiling(b, a);
111 } 111 }
112 return packColorType(ct, a, r, g , b); 112 return packColorType(ct, a, r, g , b);
113 } 113 }
114 114
115 static void fillCanvas(SkCanvas* canvas) { 115 static void fillCanvas(SkCanvas* canvas) {
116 SkBitmap bmp; 116 SkBitmap bmp;
117 if (bmp.isNull()) { 117 if (bmp.isNull()) {
118 SkDEBUGCODE(bool alloc = ) bmp.allocN32Pixels(DEV_W, DEV_H); 118 bmp.allocN32Pixels(DEV_W, DEV_H);
119 SkASSERT(alloc);
120 for (int y = 0; y < DEV_H; ++y) { 119 for (int y = 0; y < DEV_H; ++y) {
121 for (int x = 0; x < DEV_W; ++x) { 120 for (int x = 0; x < DEV_W; ++x) {
122 *bmp.getAddr32(x, y) = getCanvasColor(x, y); 121 *bmp.getAddr32(x, y) = getCanvasColor(x, y);
123 } 122 }
124 } 123 }
125 } 124 }
126 canvas->save(); 125 canvas->save();
127 canvas->setMatrix(SkMatrix::I()); 126 canvas->setMatrix(SkMatrix::I());
128 canvas->clipRect(DEV_RECT_S, SkRegion::kReplace_Op); 127 canvas->clipRect(DEV_RECT_S, SkRegion::kReplace_Op);
129 SkPaint paint; 128 SkPaint paint;
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 SkIRect writeRect = SkIRect::MakeXYWH(rect.fLeft, rect.f Top, 471 SkIRect writeRect = SkIRect::MakeXYWH(rect.fLeft, rect.f Top,
473 bmp.width(), bmp.h eight()); 472 bmp.width(), bmp.h eight());
474 bool intersects = SkIRect::Intersects(canvasRect, writeR ect) ; 473 bool intersects = SkIRect::Intersects(canvasRect, writeR ect) ;
475 REPORTER_ASSERT(reporter, intersects == (idBefore != idA fter)); 474 REPORTER_ASSERT(reporter, intersects == (idBefore != idA fter));
476 } 475 }
477 } 476 }
478 } 477 }
479 } 478 }
480 } 479 }
481 } 480 }
OLDNEW
« no previous file with comments | « tests/TextureCompressionTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698