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

Side by Side Diff: tests/SurfaceTest.cpp

Issue 13226002: Fixed bug with SkImage leaving canvas backing store in an immutable state after destroy. (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/SkImage_Raster.cpp ('K') | « src/image/SkImage_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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 EXPECT_COPY_ON_WRITE(drawBitmapMatrix(testBitmap, testMatrix, NULL)) 126 EXPECT_COPY_ON_WRITE(drawBitmapMatrix(testBitmap, testMatrix, NULL))
127 EXPECT_COPY_ON_WRITE(drawBitmapNine(testBitmap, testIRect, testRect, NULL)) 127 EXPECT_COPY_ON_WRITE(drawBitmapNine(testBitmap, testIRect, testRect, NULL))
128 EXPECT_COPY_ON_WRITE(drawSprite(testBitmap, 0, 0, NULL)) 128 EXPECT_COPY_ON_WRITE(drawSprite(testBitmap, 0, 0, NULL))
129 EXPECT_COPY_ON_WRITE(drawText(testText.c_str(), testText.size(), 0, 1, testP aint)) 129 EXPECT_COPY_ON_WRITE(drawText(testText.c_str(), testText.size(), 0, 1, testP aint))
130 EXPECT_COPY_ON_WRITE(drawPosText(testText.c_str(), testText.size(), testPoin ts2, \ 130 EXPECT_COPY_ON_WRITE(drawPosText(testText.c_str(), testText.size(), testPoin ts2, \
131 testPaint)) 131 testPaint))
132 EXPECT_COPY_ON_WRITE(drawTextOnPath(testText.c_str(), testText.size(), testP ath, NULL, \ 132 EXPECT_COPY_ON_WRITE(drawTextOnPath(testText.c_str(), testText.size(), testP ath, NULL, \
133 testPaint)) 133 testPaint))
134 } 134 }
135 135
136 static void TestSurfaceWritableAfterSnapshotRelease(skiatest::Reporter* reporter ,
137 SurfaceType surfaceType,
138 GrContext* context) {
139 // This test succeeds by not triggering an assertion.
140 // The test verifies that the surface remains writable (usable) after
141 // acquiring and releasing a snapshot without triggering a copy on write.
142 SkSurface* surface = createSurface(surfaceType, context);
143 SkAutoTUnref<SkSurface> aur_surface(surface);
144 SkCanvas* canvas = surface->getCanvas();
145 canvas->clear(1);
146 surface->newImageShapshot()->unref(); // Create and destroy SkImage
147 canvas->clear(2);
148 }
149
136 static void TestSurface(skiatest::Reporter* reporter) { 150 static void TestSurface(skiatest::Reporter* reporter) {
bsalomon 2013/04/03 14:13:43 Just noting that TestSurface and TestSurfaceGpu co
137 TestSurfaceCopyOnWrite(reporter, kRaster_SurfaceType, NULL); 151 TestSurfaceCopyOnWrite(reporter, kRaster_SurfaceType, NULL);
138 TestSurfaceCopyOnWrite(reporter, kPicture_SurfaceType, NULL); 152 TestSurfaceCopyOnWrite(reporter, kPicture_SurfaceType, NULL);
153 TestSurfaceWritableAfterSnapshotRelease(reporter, kRaster_SurfaceType, NULL) ;
154 TestSurfaceWritableAfterSnapshotRelease(reporter, kPicture_SurfaceType, NULL );
139 } 155 }
140 156
141 static void TestSurfaceGpu(skiatest::Reporter* reporter, GrContextFactory* facto ry) { 157 static void TestSurfaceGpu(skiatest::Reporter* reporter, GrContextFactory* facto ry) {
142 #if SK_SUPPORT_GPU 158 #if SK_SUPPORT_GPU
143 GrContext* context = factory->get(GrContextFactory::kNative_GLContextType); 159 GrContext* context = factory->get(GrContextFactory::kNative_GLContextType);
144 TestSurfaceCopyOnWrite(reporter, kGpu_SurfaceType, context); 160 TestSurfaceCopyOnWrite(reporter, kGpu_SurfaceType, context);
161 TestSurfaceWritableAfterSnapshotRelease(reporter, kGpu_SurfaceType, context) ;
145 #endif 162 #endif
146 } 163 }
147 164
148 #include "TestClassDef.h" 165 #include "TestClassDef.h"
149 DEFINE_TESTCLASS("Surface", SurfaceTestClass, TestSurface) 166 DEFINE_TESTCLASS("Surface", SurfaceTestClass, TestSurface)
150 DEFINE_GPUTESTCLASS("SurfaceGpu", SurfaceGpuTestClass, TestSurfaceGpu) 167 DEFINE_GPUTESTCLASS("SurfaceGpu", SurfaceGpuTestClass, TestSurfaceGpu)
OLDNEW
« src/image/SkImage_Raster.cpp ('K') | « src/image/SkImage_Raster.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698