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

Side by Side Diff: tests/ShaderImageFilterTest.cpp

Issue 162643002: replace setConfig+allocPixels with single call (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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
« no previous file with comments | « tests/SerializationTest.cpp ('k') | tests/ShaderOpacityTest.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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkGradientShader.h" 9 #include "SkGradientShader.h"
10 #include "SkRectShaderImageFilter.h" 10 #include "SkRectShaderImageFilter.h"
11 #include "SkShader.h" 11 #include "SkShader.h"
12 #include "Test.h" 12 #include "Test.h"
13 13
14 DEF_TEST(ShaderImageFilter, reporter) { 14 DEF_TEST(ShaderImageFilter, reporter) {
15 int w = 10, h = 10; 15 int w = 10, h = 10;
16 SkRect r = SkRect::MakeWH(SkIntToScalar(w), SkIntToScalar(h)); // Make small 10x10 gradient 16 SkRect r = SkRect::MakeWH(SkIntToScalar(w), SkIntToScalar(h)); // Make small 10x10 gradient
17 17
18 SkBitmap filterResult, shaderResult; 18 SkBitmap filterResult, shaderResult;
19 19
20 filterResult.setConfig(SkBitmap::kARGB_8888_Config, w, h); 20 filterResult.allocN32Pixels(w, h);
21 filterResult.allocPixels();
22 SkCanvas canvasFilter(filterResult); 21 SkCanvas canvasFilter(filterResult);
23 canvasFilter.clear(0x00000000); 22 canvasFilter.clear(0x00000000);
24 23
25 shaderResult.setConfig(SkBitmap::kARGB_8888_Config, w, h); 24 shaderResult.allocN32Pixels(w, h);
26 shaderResult.allocPixels();
27 SkCanvas canvasShader(shaderResult); 25 SkCanvas canvasShader(shaderResult);
28 canvasShader.clear(0x00000000); 26 canvasShader.clear(0x00000000);
29 27
30 SkPoint center = SkPoint::Make(SkIntToScalar(5), SkIntToScalar(5)); 28 SkPoint center = SkPoint::Make(SkIntToScalar(5), SkIntToScalar(5));
31 SkColor colors[] = {SK_ColorBLUE, SK_ColorRED, SK_ColorGREEN}; 29 SkColor colors[] = {SK_ColorBLUE, SK_ColorRED, SK_ColorGREEN};
32 SkScalar pos[] = {0, SK_ScalarHalf, SK_Scalar1}; 30 SkScalar pos[] = {0, SK_ScalarHalf, SK_Scalar1};
33 SkScalar radius = SkIntToScalar(5); 31 SkScalar radius = SkIntToScalar(5);
34 32
35 // Test using the image filter 33 // Test using the image filter
36 { 34 {
(...skipping 17 matching lines...) Expand all
54 52
55 // Assert that both paths yielded the same result 53 // Assert that both paths yielded the same result
56 for (int y = 0; y < r.height(); ++y) { 54 for (int y = 0; y < r.height(); ++y) {
57 const SkPMColor* filterPtr = filterResult.getAddr32(0, y); 55 const SkPMColor* filterPtr = filterResult.getAddr32(0, y);
58 const SkPMColor* shaderPtr = shaderResult.getAddr32(0, y); 56 const SkPMColor* shaderPtr = shaderResult.getAddr32(0, y);
59 for (int x = 0; x < r.width(); ++x, ++filterPtr, ++shaderPtr) { 57 for (int x = 0; x < r.width(); ++x, ++filterPtr, ++shaderPtr) {
60 REPORTER_ASSERT(reporter, *filterPtr == *shaderPtr); 58 REPORTER_ASSERT(reporter, *filterPtr == *shaderPtr);
61 } 59 }
62 } 60 }
63 } 61 }
OLDNEW
« no previous file with comments | « tests/SerializationTest.cpp ('k') | tests/ShaderOpacityTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698