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

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
« no previous file with comments | « 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 SkSurface* surface = createSurface(surfaceType, context);
163 SkAutoTUnref<SkSurface> aur_surface(surface);
164 SkImage* image1 = surface->newImageSnapshot();
165 SkAutoTUnref<SkImage> aur_image1(image1);
166 image1->validate();
167 surface->validate();
168 surface->notifyContentChanged();
169 image1->validate();
170 surface->validate();
171 SkImage* image2 = surface->newImageSnapshot();
172 SkAutoTUnref<SkImage> aur_image2(image2);
173 image2->validate();
174 surface->validate();
175 REPORTER_ASSERT(reporter, image1 != image2);
176 }
177
178 }
149 179
150 static void TestSurface(skiatest::Reporter* reporter, GrContextFactory* factory) { 180 static void TestSurface(skiatest::Reporter* reporter, GrContextFactory* factory) {
151 TestSurfaceCopyOnWrite(reporter, kRaster_SurfaceType, NULL); 181 TestSurfaceCopyOnWrite(reporter, kRaster_SurfaceType, NULL);
152 TestSurfaceCopyOnWrite(reporter, kPicture_SurfaceType, NULL); 182 TestSurfaceCopyOnWrite(reporter, kPicture_SurfaceType, NULL);
153 TestSurfaceWritableAfterSnapshotRelease(reporter, kRaster_SurfaceType, NULL) ; 183 TestSurfaceWritableAfterSnapshotRelease(reporter, kRaster_SurfaceType, NULL) ;
154 TestSurfaceWritableAfterSnapshotRelease(reporter, kPicture_SurfaceType, NULL ); 184 TestSurfaceWritableAfterSnapshotRelease(reporter, kPicture_SurfaceType, NULL );
185 TestSurfaceNoCanvas(reporter, kRaster_SurfaceType, NULL);
155 #if SK_SUPPORT_GPU 186 #if SK_SUPPORT_GPU
156 if (NULL != factory) { 187 if (NULL != factory) {
157 GrContext* context = factory->get(GrContextFactory::kNative_GLContextTyp e); 188 GrContext* context = factory->get(GrContextFactory::kNative_GLContextTyp e);
158 TestSurfaceCopyOnWrite(reporter, kGpu_SurfaceType, context); 189 TestSurfaceCopyOnWrite(reporter, kGpu_SurfaceType, context);
159 TestSurfaceWritableAfterSnapshotRelease(reporter, kGpu_SurfaceType, cont ext); 190 TestSurfaceWritableAfterSnapshotRelease(reporter, kGpu_SurfaceType, cont ext);
191 TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context);
160 } 192 }
161 #endif 193 #endif
162 } 194 }
163 195
164 #include "TestClassDef.h" 196 #include "TestClassDef.h"
165 DEFINE_GPUTESTCLASS("Surface", SurfaceTestClass, TestSurface) 197 DEFINE_GPUTESTCLASS("Surface", SurfaceTestClass, TestSurface)
OLDNEW
« no previous file with comments | « src/image/SkSurface_Raster.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698