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

Side by Side Diff: tests/SurfaceTest.cpp

Issue 1219793002: augment surface tests to check legacy genID (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 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 | « no previous file | 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 2013 Google Inc. 2 * Copyright 2013 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkData.h" 9 #include "SkData.h"
10 #include "SkDevice.h" 10 #include "SkDevice.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 SkData* fData; 216 SkData* fData;
217 217
218 static void Release(const void* pixels, void* context) { 218 static void Release(const void* pixels, void* context) {
219 ReleaseDataContext* state = (ReleaseDataContext*)context; 219 ReleaseDataContext* state = (ReleaseDataContext*)context;
220 REPORTER_ASSERT(state->fReporter, state->fData); 220 REPORTER_ASSERT(state->fReporter, state->fData);
221 state->fData->unref(); 221 state->fData->unref();
222 state->fData = NULL; 222 state->fData = NULL;
223 } 223 }
224 }; 224 };
225 225
226 // May we (soon) eliminate the need to keep testing this, by hiding the bloody d evice!
227 #include "SkDevice.h"
228 static uint32_t get_legacy_gen_id(SkSurface* surf) {
229 SkBaseDevice* device = surf->getCanvas()->getDevice_just_for_deprecated_comp atibility_testing();
230 return device->accessBitmap(false).getGenerationID();
231 }
232
226 static void test_texture_handle(skiatest::Reporter* reporter, SkSurface* surf) { 233 static void test_texture_handle(skiatest::Reporter* reporter, SkSurface* surf) {
227 SkAutoTUnref<SkImage> image0(surf->newImageSnapshot()); 234 SkAutoTUnref<SkImage> image0(surf->newImageSnapshot());
235 const uint32_t genID0 = get_legacy_gen_id(surf);
228 GrBackendObject obj = surf->getTextureHandle(SkSurface::kFlushRead_TextureHa ndleAccess); 236 GrBackendObject obj = surf->getTextureHandle(SkSurface::kFlushRead_TextureHa ndleAccess);
229 REPORTER_ASSERT(reporter, obj != 0); 237 REPORTER_ASSERT(reporter, obj != 0);
230 SkAutoTUnref<SkImage> image1(surf->newImageSnapshot()); 238 SkAutoTUnref<SkImage> image1(surf->newImageSnapshot());
239 const uint32_t genID1 = get_legacy_gen_id(surf);
231 // just read access should not affect the snapshot 240 // just read access should not affect the snapshot
232 REPORTER_ASSERT(reporter, image0->uniqueID() == image1->uniqueID()); 241 REPORTER_ASSERT(reporter, image0->uniqueID() == image1->uniqueID());
242 REPORTER_ASSERT(reporter, genID0 == genID1);
233 243
234 obj = surf->getTextureHandle(SkSurface::kFlushWrite_TextureHandleAccess); 244 obj = surf->getTextureHandle(SkSurface::kFlushWrite_TextureHandleAccess);
235 REPORTER_ASSERT(reporter, obj != 0); 245 REPORTER_ASSERT(reporter, obj != 0);
236 SkAutoTUnref<SkImage> image2(surf->newImageSnapshot()); 246 SkAutoTUnref<SkImage> image2(surf->newImageSnapshot());
247 const uint32_t genID2 = get_legacy_gen_id(surf);
237 // expect a new image, since we claimed we would write 248 // expect a new image, since we claimed we would write
238 REPORTER_ASSERT(reporter, image0->uniqueID() != image2->uniqueID()); 249 REPORTER_ASSERT(reporter, image0->uniqueID() != image2->uniqueID());
250 REPORTER_ASSERT(reporter, genID0 != genID2);
239 251
240 obj = surf->getTextureHandle(SkSurface::kDiscardWrite_TextureHandleAccess); 252 obj = surf->getTextureHandle(SkSurface::kDiscardWrite_TextureHandleAccess);
241 REPORTER_ASSERT(reporter, obj != 0); 253 REPORTER_ASSERT(reporter, obj != 0);
242 SkAutoTUnref<SkImage> image3(surf->newImageSnapshot()); 254 SkAutoTUnref<SkImage> image3(surf->newImageSnapshot());
255 const uint32_t genID3 = get_legacy_gen_id(surf);
243 // expect a new(er) image, since we claimed we would write 256 // expect a new(er) image, since we claimed we would write
244 REPORTER_ASSERT(reporter, image0->uniqueID() != image3->uniqueID()); 257 REPORTER_ASSERT(reporter, image0->uniqueID() != image3->uniqueID());
245 REPORTER_ASSERT(reporter, image2->uniqueID() != image3->uniqueID()); 258 REPORTER_ASSERT(reporter, image2->uniqueID() != image3->uniqueID());
259 REPORTER_ASSERT(reporter, genID0 != genID3);
260 REPORTER_ASSERT(reporter, genID2 != genID3);
246 } 261 }
247 262
248 static SkImage* create_image(skiatest::Reporter* reporter, 263 static SkImage* create_image(skiatest::Reporter* reporter,
249 ImageType imageType, GrContext* context, SkColor co lor, 264 ImageType imageType, GrContext* context, SkColor co lor,
250 ReleaseDataContext* releaseContext) { 265 ReleaseDataContext* releaseContext) {
251 const SkPMColor pmcolor = SkPreMultiplyColor(color); 266 const SkPMColor pmcolor = SkPreMultiplyColor(color);
252 const SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10); 267 const SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10);
253 const size_t rowBytes = info.minRowBytes(); 268 const size_t rowBytes = info.minRowBytes();
254 const size_t size = rowBytes * info.height(); 269 const size_t size = rowBytes * info.height();
255 270
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 // We expect the ref'd image to see the new color, but cpy'd one should stil l see the old color 933 // We expect the ref'd image to see the new color, but cpy'd one should stil l see the old color
919 test_image_color(reporter, refImg, expected1); 934 test_image_color(reporter, refImg, expected1);
920 test_image_color(reporter, cpyImg, expected0); 935 test_image_color(reporter, cpyImg, expected0);
921 936
922 // Now exercise the release proc 937 // Now exercise the release proc
923 REPORTER_ASSERT(reporter, !releaseCtx.fIsReleased); 938 REPORTER_ASSERT(reporter, !releaseCtx.fIsReleased);
924 refImg.reset(NULL); // force a release of the image 939 refImg.reset(NULL); // force a release of the image
925 REPORTER_ASSERT(reporter, releaseCtx.fIsReleased); 940 REPORTER_ASSERT(reporter, releaseCtx.fIsReleased);
926 } 941 }
927 #endif 942 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698