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 "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 sk_sp<SkImage> image(surface->makeImageSnapshot()); | 70 sk_sp<SkImage> image(surface->makeImageSnapshot()); |
71 | 71 |
72 srcRect.setXYWH(1, 1, 3, 3); | 72 srcRect.setXYWH(1, 1, 3, 3); |
73 dstRect.setXYWH(405, 5, 305, 305); | 73 dstRect.setXYWH(405, 5, 305, 305); |
74 canvas->drawImageRect(image, srcRect, dstRect, &paint); | 74 canvas->drawImageRect(image, srcRect, dstRect, &paint); |
75 | 75 |
76 // Test that bitmap blurring using a subrect | 76 // Test that bitmap blurring using a subrect |
77 // renders correctly | 77 // renders correctly |
78 srcRect.setXYWH(1, 1, 3, 3); | 78 srcRect.setXYWH(1, 1, 3, 3); |
79 dstRect.setXYWH(5, 405, 305, 305); | 79 dstRect.setXYWH(5, 405, 305, 305); |
80 SkMaskFilter* mf = SkBlurMaskFilter::Create( | 80 paint.setMaskFilter(SkBlurMaskFilter::Make( |
81 kNormal_SkBlurStyle, | 81 kNormal_SkBlurStyle, |
82 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)), | 82 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)), |
83 SkBlurMaskFilter::kHighQuality_BlurFlag | | 83 SkBlurMaskFilter::kHighQuality_BlurFlag | |
84 SkBlurMaskFilter::kIgnoreTransform_BlurFlag); | 84 SkBlurMaskFilter::kIgnoreTransform_BlurFlag)); |
85 paint.setMaskFilter(mf)->unref(); | |
86 canvas->drawImageRect(image, srcRect, dstRect, &paint); | 85 canvas->drawImageRect(image, srcRect, dstRect, &paint); |
87 | 86 |
88 // Blur and a rotation + nullptr src rect | 87 // Blur and a rotation + nullptr src rect |
89 // This should not trigger the texture domain code | 88 // This should not trigger the texture domain code |
90 // but it will test a code path in SkGpuDevice::drawBitmap | 89 // but it will test a code path in SkGpuDevice::drawBitmap |
91 // that handles blurs with rects transformed to non- | 90 // that handles blurs with rects transformed to non- |
92 // orthogonal rects. It also tests the nullptr src rect handling | 91 // orthogonal rects. It also tests the nullptr src rect handling |
93 mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle, | 92 paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, |
94 SkBlurMask::ConvertRadiusToSigma(5), | 93 SkBlurMask::ConvertRadiusToSi
gma(5), |
95 SkBlurMaskFilter::kHighQuality_BlurFlag); | 94 SkBlurMaskFilter::kHighQualit
y_BlurFlag)); |
96 paint.setMaskFilter(mf)->unref(); | |
97 | 95 |
98 dstRect.setXYWH(-150, -150, 300, 300); | 96 dstRect.setXYWH(-150, -150, 300, 300); |
99 canvas->translate(550, 550); | 97 canvas->translate(550, 550); |
100 canvas->rotate(45); | 98 canvas->rotate(45); |
101 canvas->drawBitmapRect(fBM, dstRect, &paint); | 99 canvas->drawBitmapRect(fBM, dstRect, &paint); |
102 } | 100 } |
103 private: | 101 private: |
104 typedef SkView INHERITED; | 102 typedef SkView INHERITED; |
105 }; | 103 }; |
106 | 104 |
107 ////////////////////////////////////////////////////////////////////////////// | 105 ////////////////////////////////////////////////////////////////////////////// |
108 | 106 |
109 static SkView* MyFactory() { return new TextureDomainView; } | 107 static SkView* MyFactory() { return new TextureDomainView; } |
110 static SkViewRegister reg(MyFactory); | 108 static SkViewRegister reg(MyFactory); |
OLD | NEW |