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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(), | 74 SkImageInfo info = SkImageInfo::Make(mask->fBounds.width(), |
75 mask->fBounds.height(), | 75 mask->fBounds.height(), |
76 kAlpha_8_SkColorType, | 76 kAlpha_8_SkColorType, |
77 kPremul_SkAlphaType); | 77 kPremul_SkAlphaType); |
78 SkBitmap bitmap; | 78 SkBitmap bitmap; |
79 bitmap.installPixels(info, mask->fImage, mask->fRowBytes, NULL, NULL); | 79 bitmap.installPixels(info, mask->fImage, mask->fRowBytes); |
80 | 80 |
81 // 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 |
82 // 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. |
83 // | 83 // |
84 SkRegion tmpRgn(rgn); | 84 SkRegion tmpRgn(rgn); |
85 tmpRgn.translate(-rgn.getBounds().fLeft, -rgn.getBounds().fTop); | 85 tmpRgn.translate(-rgn.getBounds().fLeft, -rgn.getBounds().fTop); |
86 | 86 |
87 SkCanvas canvas(bitmap); | 87 SkCanvas canvas(bitmap); |
88 canvas.clipRegion(tmpRgn); | 88 canvas.clipRegion(tmpRgn); |
89 canvas.drawColor(SK_ColorBLACK); | 89 canvas.drawColor(SK_ColorBLACK); |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 | 398 |
399 DEF_TEST(AAClip, reporter) { | 399 DEF_TEST(AAClip, reporter) { |
400 test_empty(reporter); | 400 test_empty(reporter); |
401 test_path_bounds(reporter); | 401 test_path_bounds(reporter); |
402 test_irect(reporter); | 402 test_irect(reporter); |
403 test_rgn(reporter); | 403 test_rgn(reporter); |
404 test_path_with_hole(reporter); | 404 test_path_with_hole(reporter); |
405 test_regressions(); | 405 test_regressions(); |
406 test_nearly_integral(reporter); | 406 test_nearly_integral(reporter); |
407 } | 407 } |
OLD | NEW |