OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPathUtils.h" | 10 #include "SkPathUtils.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 std::cout << 1; | 53 std::cout << 1; |
54 } | 54 } |
55 std::cout << std::endl; | 55 std::cout << std::endl; |
56 } | 56 } |
57 } | 57 } |
58 */ | 58 */ |
59 | 59 |
60 static void binary_to_skbitmap(const char* bin_bmp, SkBitmap* sk_bmp, | 60 static void binary_to_skbitmap(const char* bin_bmp, SkBitmap* sk_bmp, |
61 int w, int h, int rowBytes){ | 61 int w, int h, int rowBytes){ |
62 //init the SkBitmap | 62 //init the SkBitmap |
63 sk_bmp->setConfig(SkBitmap::kARGB_8888_Config, w, h); | 63 sk_bmp->allocN32Pixels(w, h); |
64 sk_bmp->allocPixels(); | |
65 | 64 |
66 for (int y = 0; y < h; ++y) { // for every row | 65 for (int y = 0; y < h; ++y) { // for every row |
67 | 66 |
68 const char* curLine = &bin_bmp[y * rowBytes]; | 67 const char* curLine = &bin_bmp[y * rowBytes]; |
69 for (int x = 0; x < w; ++x) {// for every pixel | 68 for (int x = 0; x < w; ++x) {// for every pixel |
70 if (get_bit(curLine, x)) { | 69 if (get_bit(curLine, x)) { |
71 *sk_bmp->getAddr32(x,y) = SK_ColorBLACK; | 70 *sk_bmp->getAddr32(x,y) = SK_ColorBLACK; |
72 } | 71 } |
73 else { | 72 else { |
74 *sk_bmp->getAddr32(x,y) = SK_ColorWHITE; | 73 *sk_bmp->getAddr32(x,y) = SK_ColorWHITE; |
(...skipping 16 matching lines...) Expand all Loading... |
91 static void test_path_eq(skiatest::Reporter* reporter, const SkPath* path, | 90 static void test_path_eq(skiatest::Reporter* reporter, const SkPath* path, |
92 const SkBitmap* truth, int w, int h){ | 91 const SkBitmap* truth, int w, int h){ |
93 // make paint | 92 // make paint |
94 SkPaint bmpPaint; | 93 SkPaint bmpPaint; |
95 bmpPaint.setAntiAlias(true); // Black paint for bitmap | 94 bmpPaint.setAntiAlias(true); // Black paint for bitmap |
96 bmpPaint.setStyle(SkPaint::kFill_Style); | 95 bmpPaint.setStyle(SkPaint::kFill_Style); |
97 bmpPaint.setColor(SK_ColorBLACK); | 96 bmpPaint.setColor(SK_ColorBLACK); |
98 | 97 |
99 // make bmp | 98 // make bmp |
100 SkBitmap bmp; | 99 SkBitmap bmp; |
101 bmp.setConfig(SkBitmap::kARGB_8888_Config, w, h); | 100 bmp.allocN32Pixels(w, h); |
102 bmp.allocPixels(); | |
103 SkCanvas canvas(bmp); | 101 SkCanvas canvas(bmp); |
104 canvas.clear(SK_ColorWHITE); | 102 canvas.clear(SK_ColorWHITE); |
105 canvas.drawPath(*path, bmpPaint); | 103 canvas.drawPath(*path, bmpPaint); |
106 | 104 |
107 // test bmp | 105 // test bmp |
108 test_bmp(reporter, truth, &bmp, w, h); | 106 test_bmp(reporter, truth, &bmp, w, h); |
109 } | 107 } |
110 | 108 |
111 static void test_path(skiatest::Reporter* reporter, const SkBitmap* truth, | 109 static void test_path(skiatest::Reporter* reporter, const SkBitmap* truth, |
112 const char* bin_bmp, int w, int h, int rowBytes){ | 110 const char* bin_bmp, int w, int h, int rowBytes){ |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 for (unsigned int i = 0; i < SK_ARRAY_COUNT(w); ++i) { | 143 for (unsigned int i = 0; i < SK_ARRAY_COUNT(w); ++i) { |
146 // generate truth bitmap | 144 // generate truth bitmap |
147 SkBitmap bmpTruth; | 145 SkBitmap bmpTruth; |
148 binary_to_skbitmap(binBmp, &bmpTruth, w[i], h, rowBytes); | 146 binary_to_skbitmap(binBmp, &bmpTruth, w[i], h, rowBytes); |
149 | 147 |
150 test_path(reporter, &bmpTruth, binBmp, w[i], h, rowBytes); | 148 test_path(reporter, &bmpTruth, binBmp, w[i], h, rowBytes); |
151 test_region(reporter, &bmpTruth, binBmp, w[i], h, rowBytes); | 149 test_region(reporter, &bmpTruth, binBmp, w[i], h, rowBytes); |
152 } | 150 } |
153 } | 151 } |
154 } | 152 } |
OLD | NEW |