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

Side by Side Diff: tests/LayerRasterizerTest.cpp

Issue 313653006: Return NULL when building empty LayerRasterizer. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 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/SkLayerRasterizer.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 2014 Google Inc. 2 * Copyright 2014 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 "SkDeque.h" 8 #include "SkDeque.h"
9 #include "SkLayerRasterizer.h" 9 #include "SkLayerRasterizer.h"
10 #include "SkPaint.h" 10 #include "SkPaint.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 SkPaint fPaint; 74 SkPaint fPaint;
75 SkVector fOffset; 75 SkVector fOffset;
76 }; 76 };
77 77
78 static bool equals(const SkLayerRasterizer_Rec& rec1, const SkLayerRasterizer_Re c& rec2) { 78 static bool equals(const SkLayerRasterizer_Rec& rec1, const SkLayerRasterizer_Re c& rec2) {
79 return rec1.fPaint == rec2.fPaint && rec1.fOffset == rec2.fOffset; 79 return rec1.fPaint == rec2.fPaint && rec1.fOffset == rec2.fOffset;
80 } 80 }
81 81
82 DEF_TEST(LayerRasterizer_copy, reporter) { 82 DEF_TEST(LayerRasterizer_copy, reporter) {
83 SkLayerRasterizer::Builder builder; 83 SkLayerRasterizer::Builder builder;
84 REPORTER_ASSERT(reporter, NULL == builder.snapshotRasterizer());
84 SkPaint paint; 85 SkPaint paint;
85 // Create a bunch of paints with different flags. 86 // Create a bunch of paints with different flags.
86 for (uint32_t flags = 0x01; flags < SkPaint::kAllFlags; flags <<= 1) { 87 for (uint32_t flags = 0x01; flags < SkPaint::kAllFlags; flags <<= 1) {
87 paint.setFlags(flags); 88 paint.setFlags(flags);
88 builder.addLayer(paint, static_cast<SkScalar>(flags), static_cast<SkScal ar>(flags)); 89 builder.addLayer(paint, static_cast<SkScalar>(flags), static_cast<SkScal ar>(flags));
89 } 90 }
90 91
91 // Create a layer rasterizer with all the existing layers. 92 // Create a layer rasterizer with all the existing layers.
92 SkAutoTUnref<SkLayerRasterizer> firstCopy(builder.snapshotRasterizer()); 93 SkAutoTUnref<SkLayerRasterizer> firstCopy(builder.snapshotRasterizer());
93 94
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 recDetached = static_cast<const SkLayerRasterizer_Rec*>(iterDetached.ne xt()); 130 recDetached = static_cast<const SkLayerRasterizer_Rec*>(iterDetached.ne xt());
130 131
131 REPORTER_ASSERT(reporter, equals(*recOneLarger, *recDetached)); 132 REPORTER_ASSERT(reporter, equals(*recOneLarger, *recDetached));
132 if (smallerCount == i) { 133 if (smallerCount == i) {
133 REPORTER_ASSERT(reporter, recFirstCopy == NULL); 134 REPORTER_ASSERT(reporter, recFirstCopy == NULL);
134 } else { 135 } else {
135 REPORTER_ASSERT(reporter, equals(*recFirstCopy, *recOneLarger)); 136 REPORTER_ASSERT(reporter, equals(*recFirstCopy, *recOneLarger));
136 } 137 }
137 } 138 }
138 } 139 }
140
141 DEF_TEST(LayerRasterizer_detachEmpty, reporter) {
142 SkLayerRasterizer::Builder builder;
143 REPORTER_ASSERT(reporter, NULL == builder.detachRasterizer());
144 }
OLDNEW
« no previous file with comments | « src/effects/SkLayerRasterizer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698