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 "SkBitmapDevice.h" | 8 #include "SkBitmapDevice.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 r = SkMulDiv255Ceiling(r, a); | 89 r = SkMulDiv255Ceiling(r, a); |
90 g = SkMulDiv255Ceiling(g, a); | 90 g = SkMulDiv255Ceiling(g, a); |
91 b = SkMulDiv255Ceiling(b, a); | 91 b = SkMulDiv255Ceiling(b, a); |
92 } | 92 } |
93 return SkPackARGB32(a, r, g, b); | 93 return SkPackARGB32(a, r, g, b); |
94 } | 94 } |
95 | 95 |
96 static void fillCanvas(SkCanvas* canvas) { | 96 static void fillCanvas(SkCanvas* canvas) { |
97 static SkBitmap bmp; | 97 static SkBitmap bmp; |
98 if (bmp.isNull()) { | 98 if (bmp.isNull()) { |
99 SkDEBUGCODE(bool alloc =) bmp.allocN32Pixels(DEV_W, DEV_H); | 99 bmp.allocN32Pixels(DEV_W, DEV_H); |
100 SkASSERT(alloc); | |
101 SkAutoLockPixels alp(bmp); | |
102 intptr_t pixels = reinterpret_cast<intptr_t>(bmp.getPixels()); | 100 intptr_t pixels = reinterpret_cast<intptr_t>(bmp.getPixels()); |
103 for (int y = 0; y < DEV_H; ++y) { | 101 for (int y = 0; y < DEV_H; ++y) { |
104 for (int x = 0; x < DEV_W; ++x) { | 102 for (int x = 0; x < DEV_W; ++x) { |
105 SkPMColor* pixel = reinterpret_cast<SkPMColor*>(pixels + y * bmp
.rowBytes() + x * bmp.bytesPerPixel()); | 103 SkPMColor* pixel = reinterpret_cast<SkPMColor*>(pixels + y * bmp
.rowBytes() + x * bmp.bytesPerPixel()); |
106 *pixel = getCanvasColor(x, y); | 104 *pixel = getCanvasColor(x, y); |
107 } | 105 } |
108 } | 106 } |
109 } | 107 } |
110 canvas->save(); | 108 canvas->save(); |
111 canvas->setMatrix(SkMatrix::I()); | 109 canvas->setMatrix(SkMatrix::I()); |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 checkRead(reporter, wkbmp, clippedRect.fLeft, | 384 checkRead(reporter, wkbmp, clippedRect.fLeft, |
387 clippedRect.fTop, true, false); | 385 clippedRect.fTop, true, false); |
388 } else { | 386 } else { |
389 REPORTER_ASSERT(reporter, !success); | 387 REPORTER_ASSERT(reporter, !success); |
390 } | 388 } |
391 } | 389 } |
392 } | 390 } |
393 } | 391 } |
394 } | 392 } |
395 } | 393 } |
OLD | NEW |