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

Side by Side Diff: tests/PaintTest.cpp

Issue 232913003: Make sure SkDrawLooper objects can only be allocated on the heap. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 8 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
« no previous file with comments | « src/effects/SkLayerDrawLooper.cpp ('k') | no next file » | 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 "SkBlurMask.h" 8 #include "SkBlurMask.h"
9 #include "SkBlurMaskFilter.h" 9 #include "SkBlurMaskFilter.h"
10 #include "SkLayerDrawLooper.h" 10 #include "SkLayerDrawLooper.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } 140 }
141 } 141 }
142 142
143 DEF_TEST(Paint_copy, reporter) { 143 DEF_TEST(Paint_copy, reporter) {
144 SkPaint paint; 144 SkPaint paint;
145 // set a few member variables 145 // set a few member variables
146 paint.setStyle(SkPaint::kStrokeAndFill_Style); 146 paint.setStyle(SkPaint::kStrokeAndFill_Style);
147 paint.setTextAlign(SkPaint::kLeft_Align); 147 paint.setTextAlign(SkPaint::kLeft_Align);
148 paint.setStrokeWidth(SkIntToScalar(2)); 148 paint.setStrokeWidth(SkIntToScalar(2));
149 // set a few pointers 149 // set a few pointers
150 SkLayerDrawLooper* looper = new SkLayerDrawLooper(); 150 SkLayerDrawLooper::Builder looperBuilder;
151 SkLayerDrawLooper* looper = looperBuilder.detachLooper();
151 paint.setLooper(looper)->unref(); 152 paint.setLooper(looper)->unref();
152 SkMaskFilter* mask = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_Blur Style, 153 SkMaskFilter* mask = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_Blur Style,
153 SkBlurMask::ConvertRadiusToSigma(SkIntToSc alar(1))); 154 SkBlurMask::ConvertRadiusToSigma(SkIntToSc alar(1)));
154 paint.setMaskFilter(mask)->unref(); 155 paint.setMaskFilter(mask)->unref();
155 156
156 // copy the paint using the copy constructor and check they are the same 157 // copy the paint using the copy constructor and check they are the same
157 SkPaint copiedPaint = paint; 158 SkPaint copiedPaint = paint;
158 REPORTER_ASSERT(reporter, paint == copiedPaint); 159 REPORTER_ASSERT(reporter, paint == copiedPaint);
159 160
160 #ifdef SK_BUILD_FOR_ANDROID 161 #ifdef SK_BUILD_FOR_ANDROID
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 ASSERT(other.getTextScaleX() == paint.getTextScaleX()); 272 ASSERT(other.getTextScaleX() == paint.getTextScaleX());
272 ASSERT(other.getTextSize() == paint.getTextSize()); 273 ASSERT(other.getTextSize() == paint.getTextSize());
273 ASSERT(other.getLooper() == paint.getLooper()); 274 ASSERT(other.getLooper() == paint.getLooper());
274 275
275 // We have to be a little looser and compare just the modes. Pointers might not be the same. 276 // We have to be a little looser and compare just the modes. Pointers might not be the same.
276 SkXfermode::Mode otherMode, paintMode; 277 SkXfermode::Mode otherMode, paintMode;
277 ASSERT(other.getXfermode()->asMode(&otherMode)); 278 ASSERT(other.getXfermode()->asMode(&otherMode));
278 ASSERT(paint.getXfermode()->asMode(&paintMode)); 279 ASSERT(paint.getXfermode()->asMode(&paintMode));
279 ASSERT(otherMode == paintMode); 280 ASSERT(otherMode == paintMode);
280 } 281 }
OLDNEW
« no previous file with comments | « src/effects/SkLayerDrawLooper.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698