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 "SkAAClip.h" | 8 #include "SkAAClip.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkMask.h" | 10 #include "SkMask.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 mask->fRowBytes = 0; | 64 mask->fRowBytes = 0; |
65 mask->fImage = NULL; | 65 mask->fImage = NULL; |
66 return; | 66 return; |
67 } | 67 } |
68 | 68 |
69 mask->fBounds = rgn.getBounds(); | 69 mask->fBounds = rgn.getBounds(); |
70 mask->fRowBytes = mask->fBounds.width(); | 70 mask->fRowBytes = mask->fBounds.width(); |
71 mask->fImage = SkMask::AllocImage(mask->computeImageSize()); | 71 mask->fImage = SkMask::AllocImage(mask->computeImageSize()); |
72 sk_bzero(mask->fImage, mask->computeImageSize()); | 72 sk_bzero(mask->fImage, mask->computeImageSize()); |
73 | 73 |
| 74 SkImageInfo info = SkImageInfo::Make(mask->fBounds.width(), |
| 75 mask->fBounds.height(), |
| 76 kAlpha_8_SkColorType, |
| 77 kPremul_SkAlphaType); |
74 SkBitmap bitmap; | 78 SkBitmap bitmap; |
75 bitmap.setConfig(SkBitmap::kA8_Config, mask->fBounds.width(), | 79 bitmap.installPixels(info, mask->fImage, mask->fRowBytes, NULL, NULL); |
76 mask->fBounds.height(), mask->fRowBytes); | |
77 bitmap.setPixels(mask->fImage); | |
78 | 80 |
79 // canvas expects its coordinate system to always be 0,0 in the top/left | 81 // canvas expects its coordinate system to always be 0,0 in the top/left |
80 // so we translate the rgn to match that before drawing into the mask. | 82 // so we translate the rgn to match that before drawing into the mask. |
81 // | 83 // |
82 SkRegion tmpRgn(rgn); | 84 SkRegion tmpRgn(rgn); |
83 tmpRgn.translate(-rgn.getBounds().fLeft, -rgn.getBounds().fTop); | 85 tmpRgn.translate(-rgn.getBounds().fLeft, -rgn.getBounds().fTop); |
84 | 86 |
85 SkCanvas canvas(bitmap); | 87 SkCanvas canvas(bitmap); |
86 canvas.clipRegion(tmpRgn); | 88 canvas.clipRegion(tmpRgn); |
87 canvas.drawColor(SK_ColorBLACK); | 89 canvas.drawColor(SK_ColorBLACK); |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 | 398 |
397 DEF_TEST(AAClip, reporter) { | 399 DEF_TEST(AAClip, reporter) { |
398 test_empty(reporter); | 400 test_empty(reporter); |
399 test_path_bounds(reporter); | 401 test_path_bounds(reporter); |
400 test_irect(reporter); | 402 test_irect(reporter); |
401 test_rgn(reporter); | 403 test_rgn(reporter); |
402 test_path_with_hole(reporter); | 404 test_path_with_hole(reporter); |
403 test_regressions(); | 405 test_regressions(); |
404 test_nearly_integral(reporter); | 406 test_nearly_integral(reporter); |
405 } | 407 } |
OLD | NEW |