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

Side by Side Diff: tests/SurfaceTest.cpp

Issue 14263017: Cleanup: Removing unnecessary args/complexity in SkSurface_Base and friends (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 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 | Annotate | Revision Log
« src/image/SkSurface.cpp ('K') | « src/image/SkSurface_Raster.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 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkRRect.h" 9 #include "SkRRect.h"
10 #include "SkSurface.h" 10 #include "SkSurface.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 // This test succeeds by not triggering an assertion. 139 // This test succeeds by not triggering an assertion.
140 // The test verifies that the surface remains writable (usable) after 140 // The test verifies that the surface remains writable (usable) after
141 // acquiring and releasing a snapshot without triggering a copy on write. 141 // acquiring and releasing a snapshot without triggering a copy on write.
142 SkSurface* surface = createSurface(surfaceType, context); 142 SkSurface* surface = createSurface(surfaceType, context);
143 SkAutoTUnref<SkSurface> aur_surface(surface); 143 SkAutoTUnref<SkSurface> aur_surface(surface);
144 SkCanvas* canvas = surface->getCanvas(); 144 SkCanvas* canvas = surface->getCanvas();
145 canvas->clear(1); 145 canvas->clear(1);
146 surface->newImageSnapshot()->unref(); // Create and destroy SkImage 146 surface->newImageSnapshot()->unref(); // Create and destroy SkImage
147 canvas->clear(2); 147 canvas->clear(2);
148 } 148 }
149 static void TestSurfaceNoCanvas(skiatest::Reporter* reporter,
150 SurfaceType surfaceType,
151 GrContext* context) {
152 // Verifies the robustness of SkSurface for handling use cases where calls
153 // are made before a canvas is created.
154 {
155 // Test passes by not asserting
156 SkSurface* surface = createSurface(surfaceType, context);
157 SkAutoTUnref<SkSurface> aur_surface(surface);
158 surface->notifyContentChanged();
159 surface->validate();
160 }
161 {
162 // Test passes by not asserting
163 SkSurface* surface = createSurface(surfaceType, context);
164 SkAutoTUnref<SkSurface> aur_surface(surface);
165 SkImage* image = surface->newImageSnapshot();
166 SkAutoTUnref<SkImage> aur_image(image);
167 image->validate();
168 surface->validate();
169 surface->notifyContentChanged();
170 image->validate();
171 surface->validate();
172 }
173
174 }
149 175
150 static void TestSurface(skiatest::Reporter* reporter, GrContextFactory* factory) { 176 static void TestSurface(skiatest::Reporter* reporter, GrContextFactory* factory) {
151 TestSurfaceCopyOnWrite(reporter, kRaster_SurfaceType, NULL); 177 TestSurfaceCopyOnWrite(reporter, kRaster_SurfaceType, NULL);
152 TestSurfaceCopyOnWrite(reporter, kPicture_SurfaceType, NULL); 178 TestSurfaceCopyOnWrite(reporter, kPicture_SurfaceType, NULL);
153 TestSurfaceWritableAfterSnapshotRelease(reporter, kRaster_SurfaceType, NULL) ; 179 TestSurfaceWritableAfterSnapshotRelease(reporter, kRaster_SurfaceType, NULL) ;
154 TestSurfaceWritableAfterSnapshotRelease(reporter, kPicture_SurfaceType, NULL ); 180 TestSurfaceWritableAfterSnapshotRelease(reporter, kPicture_SurfaceType, NULL );
181 TestSurfaceNoCanvas(reporter, kRaster_SurfaceType, NULL);
182 TestSurfaceNoCanvas(reporter, kPicture_SurfaceType, NULL);
155 #if SK_SUPPORT_GPU 183 #if SK_SUPPORT_GPU
156 if (NULL != factory) { 184 if (NULL != factory) {
157 GrContext* context = factory->get(GrContextFactory::kNative_GLContextTyp e); 185 GrContext* context = factory->get(GrContextFactory::kNative_GLContextTyp e);
158 TestSurfaceCopyOnWrite(reporter, kGpu_SurfaceType, context); 186 TestSurfaceCopyOnWrite(reporter, kGpu_SurfaceType, context);
159 TestSurfaceWritableAfterSnapshotRelease(reporter, kGpu_SurfaceType, cont ext); 187 TestSurfaceWritableAfterSnapshotRelease(reporter, kGpu_SurfaceType, cont ext);
188 TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context);
160 } 189 }
161 #endif 190 #endif
162 } 191 }
163 192
164 #include "TestClassDef.h" 193 #include "TestClassDef.h"
165 DEFINE_GPUTESTCLASS("Surface", SurfaceTestClass, TestSurface) 194 DEFINE_GPUTESTCLASS("Surface", SurfaceTestClass, TestSurface)
OLDNEW
« src/image/SkSurface.cpp ('K') | « src/image/SkSurface_Raster.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698