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

Side by Side Diff: tests/SurfaceTest.cpp

Issue 1205643002: Make SkGpuDevice know its alpha type (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix bench pictures :( Created 5 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 | « tests/ReadWriteAlphaTest.cpp ('k') | tools/PictureRenderer.cpp » ('j') | 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 12 matching lines...) Expand all
23 #else 23 #else
24 class GrContextFactory; 24 class GrContextFactory;
25 class GrContext; 25 class GrContext;
26 #endif 26 #endif
27 27
28 enum SurfaceType { 28 enum SurfaceType {
29 kRaster_SurfaceType, 29 kRaster_SurfaceType,
30 kRasterDirect_SurfaceType, 30 kRasterDirect_SurfaceType,
31 kGpu_SurfaceType, 31 kGpu_SurfaceType,
32 kGpuScratch_SurfaceType, 32 kGpuScratch_SurfaceType,
33
34 kLastSurfaceType = kGpuScratch_SurfaceType
33 }; 35 };
36 static const int kSurfaceTypeCnt = kLastSurfaceType + 1;
34 37
35 static void release_storage(void* pixels, void* context) { 38 static void release_storage(void* pixels, void* context) {
36 SkASSERT(pixels == context); 39 SkASSERT(pixels == context);
37 sk_free(pixels); 40 sk_free(pixels);
38 } 41 }
39 42
40 static SkSurface* createSurface(SurfaceType surfaceType, GrContext* context, 43 static SkSurface* create_surface(SurfaceType surfaceType, GrContext* context,
41 SkImageInfo* requestedInfo = NULL) { 44 SkAlphaType at = kPremul_SkAlphaType,
42 static const SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10); 45 SkImageInfo* requestedInfo = NULL) {
46 const SkImageInfo info = SkImageInfo::MakeN32(10, 10, at);
43 47
44 if (requestedInfo) { 48 if (requestedInfo) {
45 *requestedInfo = info; 49 *requestedInfo = info;
46 } 50 }
47 51
48 switch (surfaceType) { 52 switch (surfaceType) {
49 case kRaster_SurfaceType: 53 case kRaster_SurfaceType:
50 return SkSurface::NewRaster(info); 54 return SkSurface::NewRaster(info);
51 case kRasterDirect_SurfaceType: { 55 case kRasterDirect_SurfaceType: {
52 const size_t rowBytes = info.minRowBytes(); 56 const size_t rowBytes = info.minRowBytes();
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 SkData* fData; 216 SkData* fData;
213 217
214 static void Release(const void* pixels, void* context) { 218 static void Release(const void* pixels, void* context) {
215 ReleaseDataContext* state = (ReleaseDataContext*)context; 219 ReleaseDataContext* state = (ReleaseDataContext*)context;
216 REPORTER_ASSERT(state->fReporter, state->fData); 220 REPORTER_ASSERT(state->fReporter, state->fData);
217 state->fData->unref(); 221 state->fData->unref();
218 state->fData = NULL; 222 state->fData = NULL;
219 } 223 }
220 }; 224 };
221 225
222 static SkImage* createImage(ImageType imageType, GrContext* context, SkColor col or, 226 static SkImage* create_image(ImageType imageType, GrContext* context, SkColor co lor,
223 ReleaseDataContext* releaseContext) { 227 ReleaseDataContext* releaseContext) {
224 const SkPMColor pmcolor = SkPreMultiplyColor(color); 228 const SkPMColor pmcolor = SkPreMultiplyColor(color);
225 const SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10); 229 const SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10);
226 const size_t rowBytes = info.minRowBytes(); 230 const size_t rowBytes = info.minRowBytes();
227 const size_t size = rowBytes * info.height(); 231 const size_t size = rowBytes * info.height();
228 232
229 SkAutoTUnref<SkData> data(SkData::NewUninitialized(size)); 233 SkAutoTUnref<SkData> data(SkData::NewUninitialized(size));
230 void* addr = data->writable_data(); 234 void* addr = data->writable_data();
231 sk_memset32((SkPMColor*)addr, pmcolor, SkToInt(size >> 2)); 235 sk_memset32((SkPMColor*)addr, pmcolor, SkToInt(size >> 2));
232 236
233 switch (imageType) { 237 switch (imageType) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 #endif 344 #endif
341 345
342 ReleaseDataContext releaseCtx; 346 ReleaseDataContext releaseCtx;
343 releaseCtx.fReporter = reporter; 347 releaseCtx.fReporter = reporter;
344 348
345 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { 349 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) {
346 SkImageInfo info; 350 SkImageInfo info;
347 size_t rowBytes; 351 size_t rowBytes;
348 352
349 releaseCtx.fData = NULL; 353 releaseCtx.fData = NULL;
350 SkAutoTUnref<SkImage> image(createImage(gRec[i].fType, ctx, color, &rele aseCtx)); 354 SkAutoTUnref<SkImage> image(create_image(gRec[i].fType, ctx, color, &rel easeCtx));
351 if (!image.get()) { 355 if (!image.get()) {
352 SkDebugf("failed to createImage[%d] %s\n", i, gRec[i].fName); 356 SkDebugf("failed to createImage[%d] %s\n", i, gRec[i].fName);
353 continue; // gpu may not be enabled 357 continue; // gpu may not be enabled
354 } 358 }
355 if (kRasterProc_ImageType == gRec[i].fType) { 359 if (kRasterProc_ImageType == gRec[i].fType) {
356 REPORTER_ASSERT(reporter, NULL != releaseCtx.fData); // we are trac king the data 360 REPORTER_ASSERT(reporter, NULL != releaseCtx.fData); // we are trac king the data
357 } else { 361 } else {
358 REPORTER_ASSERT(reporter, NULL == releaseCtx.fData); // we ignored the context 362 REPORTER_ASSERT(reporter, NULL == releaseCtx.fData); // we ignored the context
359 } 363 }
360 364
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 context = factory->get(glCtxType); 414 context = factory->get(glCtxType);
411 415
412 if (NULL == context) { 416 if (NULL == context) {
413 continue; 417 continue;
414 } 418 }
415 #endif 419 #endif
416 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { 420 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) {
417 SkImageInfo info, requestInfo; 421 SkImageInfo info, requestInfo;
418 size_t rowBytes; 422 size_t rowBytes;
419 423
420 SkAutoTUnref<SkSurface> surface(createSurface(gRec[i].fType, context , 424 SkAutoTUnref<SkSurface> surface(create_surface(gRec[i].fType, contex t,
421 &requestInfo)); 425 kPremul_SkAlphaType, &requestInfo));
422 surface->getCanvas()->clear(color); 426 surface->getCanvas()->clear(color);
423 427
424 const void* addr = surface->getCanvas()->peekPixels(&info, &rowBytes ); 428 const void* addr = surface->getCanvas()->peekPixels(&info, &rowBytes );
425 bool success = SkToBool(addr); 429 bool success = SkToBool(addr);
426 REPORTER_ASSERT(reporter, gRec[i].fPeekShouldSucceed == success); 430 REPORTER_ASSERT(reporter, gRec[i].fPeekShouldSucceed == success);
427 431
428 SkImageInfo info2; 432 SkImageInfo info2;
429 size_t rb2; 433 size_t rb2;
430 const void* addr2 = surface->peekPixels(&info2, &rb2); 434 const void* addr2 = surface->peekPixels(&info2, &rb2);
431 435
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 } 481 }
478 context = factory->get(glCtxType); 482 context = factory->get(glCtxType);
479 483
480 if (NULL == context) { 484 if (NULL == context) {
481 continue; 485 continue;
482 } 486 }
483 #endif 487 #endif
484 for (size_t j = 0; j < SK_ARRAY_COUNT(gRec); ++j) { 488 for (size_t j = 0; j < SK_ARRAY_COUNT(gRec); ++j) {
485 SkImageInfo info, requestInfo; 489 SkImageInfo info, requestInfo;
486 490
487 SkAutoTUnref<SkSurface> surface(createSurface(gRec[j].fType, context , 491 SkAutoTUnref<SkSurface> surface(create_surface(gRec[j].fType, contex t,
488 &requestInfo)); 492 kPremul_SkAlphaType, &requestInfo));
489 SkCanvas* canvas = surface->getCanvas(); 493 SkCanvas* canvas = surface->getCanvas();
490 canvas->clear(0); 494 canvas->clear(0);
491 495
492 SkBaseDevice* device = canvas->getDevice_just_for_deprecated_compati bility_testing(); 496 SkBaseDevice* device = canvas->getDevice_just_for_deprecated_compati bility_testing();
493 SkBitmap bm = device->accessBitmap(false); 497 SkBitmap bm = device->accessBitmap(false);
494 uint32_t genID0 = bm.getGenerationID(); 498 uint32_t genID0 = bm.getGenerationID();
495 // Now we draw something, which needs to "dirty" the genID (sorta li ke copy-on-write) 499 // Now we draw something, which needs to "dirty" the genID (sorta li ke copy-on-write)
496 canvas->drawColor(SK_ColorBLUE); 500 canvas->drawColor(SK_ColorBLUE);
497 // Now check that we get a different genID 501 // Now check that we get a different genID
498 uint32_t genID1 = bm.getGenerationID(); 502 uint32_t genID1 = bm.getGenerationID();
499 REPORTER_ASSERT(reporter, genID0 != genID1); 503 REPORTER_ASSERT(reporter, genID0 != genID1);
500 } 504 }
501 } 505 }
502 } 506 }
503 507
508 static void test_snap_alphatype(skiatest::Reporter* reporter, GrContextFactory* factory) {
509 GrContext* context = NULL;
510 #if SK_SUPPORT_GPU
511 context = factory->get(GrContextFactory::kNative_GLContextType);
512 if (NULL == context) {
513 return;
514 }
515 #endif
516 for (int opaque = 0; opaque < 2; ++opaque) {
517 SkAlphaType atype = SkToBool(opaque) ? kOpaque_SkAlphaType : kPremul_SkA lphaType;
518 for (int st = 0; st < kSurfaceTypeCnt; ++st) {
519 SurfaceType stype = (SurfaceType)st;
520 SkAutoTUnref<SkSurface> surface(create_surface(stype, context, atype ));
521 REPORTER_ASSERT(reporter, surface);
522 if (surface) {
523 SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
524 REPORTER_ASSERT(reporter, image);
525 if (image) {
526 REPORTER_ASSERT(reporter, image->isOpaque() == SkToBool(opaq ue));
527 }
528 }
529 }
530 }
531 }
532
504 static void TestSurfaceCopyOnWrite(skiatest::Reporter* reporter, SurfaceType sur faceType, 533 static void TestSurfaceCopyOnWrite(skiatest::Reporter* reporter, SurfaceType sur faceType,
505 GrContext* context) { 534 GrContext* context) {
506 // Verify that the right canvas commands trigger a copy on write 535 // Verify that the right canvas commands trigger a copy on write
507 SkSurface* surface = createSurface(surfaceType, context); 536 SkSurface* surface = create_surface(surfaceType, context);
508 SkAutoTUnref<SkSurface> aur_surface(surface); 537 SkAutoTUnref<SkSurface> aur_surface(surface);
509 SkCanvas* canvas = surface->getCanvas(); 538 SkCanvas* canvas = surface->getCanvas();
510 539
511 const SkRect testRect = 540 const SkRect testRect =
512 SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0), 541 SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0),
513 SkIntToScalar(4), SkIntToScalar(5)); 542 SkIntToScalar(4), SkIntToScalar(5));
514 SkPath testPath; 543 SkPath testPath;
515 testPath.addRect(SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0), 544 testPath.addRect(SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0),
516 SkIntToScalar(2), SkIntToScalar(1))); 545 SkIntToScalar(2), SkIntToScalar(1)));
517 546
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 EXPECT_COPY_ON_WRITE(drawTextOnPath(testText.c_str(), testText.size(), testP ath, NULL, \ 609 EXPECT_COPY_ON_WRITE(drawTextOnPath(testText.c_str(), testText.size(), testP ath, NULL, \
581 testPaint)) 610 testPaint))
582 } 611 }
583 612
584 static void TestSurfaceWritableAfterSnapshotRelease(skiatest::Reporter* reporter , 613 static void TestSurfaceWritableAfterSnapshotRelease(skiatest::Reporter* reporter ,
585 SurfaceType surfaceType, 614 SurfaceType surfaceType,
586 GrContext* context) { 615 GrContext* context) {
587 // This test succeeds by not triggering an assertion. 616 // This test succeeds by not triggering an assertion.
588 // The test verifies that the surface remains writable (usable) after 617 // The test verifies that the surface remains writable (usable) after
589 // acquiring and releasing a snapshot without triggering a copy on write. 618 // acquiring and releasing a snapshot without triggering a copy on write.
590 SkAutoTUnref<SkSurface> surface(createSurface(surfaceType, context)); 619 SkAutoTUnref<SkSurface> surface(create_surface(surfaceType, context));
591 SkCanvas* canvas = surface->getCanvas(); 620 SkCanvas* canvas = surface->getCanvas();
592 canvas->clear(1); 621 canvas->clear(1);
593 surface->newImageSnapshot()->unref(); // Create and destroy SkImage 622 surface->newImageSnapshot()->unref(); // Create and destroy SkImage
594 canvas->clear(2); // Must not assert internally 623 canvas->clear(2); // Must not assert internally
595 } 624 }
596 625
597 #if SK_SUPPORT_GPU 626 #if SK_SUPPORT_GPU
598 static void Test_crbug263329(skiatest::Reporter* reporter, 627 static void Test_crbug263329(skiatest::Reporter* reporter,
599 SurfaceType surfaceType, 628 SurfaceType surfaceType,
600 GrContext* context) { 629 GrContext* context) {
601 // This is a regression test for crbug.com/263329 630 // This is a regression test for crbug.com/263329
602 // Bug was caused by onCopyOnWrite releasing the old surface texture 631 // Bug was caused by onCopyOnWrite releasing the old surface texture
603 // back to the scratch texture pool even though the texture is used 632 // back to the scratch texture pool even though the texture is used
604 // by and active SkImage_Gpu. 633 // by and active SkImage_Gpu.
605 SkAutoTUnref<SkSurface> surface1(createSurface(surfaceType, context)); 634 SkAutoTUnref<SkSurface> surface1(create_surface(surfaceType, context));
606 SkAutoTUnref<SkSurface> surface2(createSurface(surfaceType, context)); 635 SkAutoTUnref<SkSurface> surface2(create_surface(surfaceType, context));
607 SkCanvas* canvas1 = surface1->getCanvas(); 636 SkCanvas* canvas1 = surface1->getCanvas();
608 SkCanvas* canvas2 = surface2->getCanvas(); 637 SkCanvas* canvas2 = surface2->getCanvas();
609 canvas1->clear(1); 638 canvas1->clear(1);
610 SkAutoTUnref<SkImage> image1(surface1->newImageSnapshot()); 639 SkAutoTUnref<SkImage> image1(surface1->newImageSnapshot());
611 // Trigger copy on write, new backing is a scratch texture 640 // Trigger copy on write, new backing is a scratch texture
612 canvas1->clear(2); 641 canvas1->clear(2);
613 SkAutoTUnref<SkImage> image2(surface1->newImageSnapshot()); 642 SkAutoTUnref<SkImage> image2(surface1->newImageSnapshot());
614 // Trigger copy on write, old backing should not be returned to scratch 643 // Trigger copy on write, old backing should not be returned to scratch
615 // pool because it is held by image2 644 // pool because it is held by image2
616 canvas1->clear(3); 645 canvas1->clear(3);
617 646
618 canvas2->clear(4); 647 canvas2->clear(4);
619 SkAutoTUnref<SkImage> image3(surface2->newImageSnapshot()); 648 SkAutoTUnref<SkImage> image3(surface2->newImageSnapshot());
620 // Trigger copy on write on surface2. The new backing store should not 649 // Trigger copy on write on surface2. The new backing store should not
621 // be recycling a texture that is held by an existing image. 650 // be recycling a texture that is held by an existing image.
622 canvas2->clear(5); 651 canvas2->clear(5);
623 SkAutoTUnref<SkImage> image4(surface2->newImageSnapshot()); 652 SkAutoTUnref<SkImage> image4(surface2->newImageSnapshot());
624 REPORTER_ASSERT(reporter, as_IB(image4)->getTexture() != as_IB(image3)->getT exture()); 653 REPORTER_ASSERT(reporter, as_IB(image4)->getTexture() != as_IB(image3)->getT exture());
625 // The following assertion checks crbug.com/263329 654 // The following assertion checks crbug.com/263329
626 REPORTER_ASSERT(reporter, as_IB(image4)->getTexture() != as_IB(image2)->getT exture()); 655 REPORTER_ASSERT(reporter, as_IB(image4)->getTexture() != as_IB(image2)->getT exture());
627 REPORTER_ASSERT(reporter, as_IB(image4)->getTexture() != as_IB(image1)->getT exture()); 656 REPORTER_ASSERT(reporter, as_IB(image4)->getTexture() != as_IB(image1)->getT exture());
628 REPORTER_ASSERT(reporter, as_IB(image3)->getTexture() != as_IB(image2)->getT exture()); 657 REPORTER_ASSERT(reporter, as_IB(image3)->getTexture() != as_IB(image2)->getT exture());
629 REPORTER_ASSERT(reporter, as_IB(image3)->getTexture() != as_IB(image1)->getT exture()); 658 REPORTER_ASSERT(reporter, as_IB(image3)->getTexture() != as_IB(image1)->getT exture());
630 REPORTER_ASSERT(reporter, as_IB(image2)->getTexture() != as_IB(image1)->getT exture()); 659 REPORTER_ASSERT(reporter, as_IB(image2)->getTexture() != as_IB(image1)->getT exture());
631 } 660 }
632 661
633 static void TestGetTexture(skiatest::Reporter* reporter, 662 static void TestGetTexture(skiatest::Reporter* reporter,
634 SurfaceType surfaceType, 663 SurfaceType surfaceType,
635 GrContext* context) { 664 GrContext* context) {
636 SkAutoTUnref<SkSurface> surface(createSurface(surfaceType, context)); 665 SkAutoTUnref<SkSurface> surface(create_surface(surfaceType, context));
637 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); 666 SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
638 GrTexture* texture = as_IB(image)->getTexture(); 667 GrTexture* texture = as_IB(image)->getTexture();
639 if (surfaceType == kGpu_SurfaceType || surfaceType == kGpuScratch_SurfaceTyp e) { 668 if (surfaceType == kGpu_SurfaceType || surfaceType == kGpuScratch_SurfaceTyp e) {
640 REPORTER_ASSERT(reporter, texture); 669 REPORTER_ASSERT(reporter, texture);
641 REPORTER_ASSERT(reporter, 0 != texture->getTextureHandle()); 670 REPORTER_ASSERT(reporter, 0 != texture->getTextureHandle());
642 } else { 671 } else {
643 REPORTER_ASSERT(reporter, NULL == texture); 672 REPORTER_ASSERT(reporter, NULL == texture);
644 } 673 }
645 surface->notifyContentWillChange(SkSurface::kDiscard_ContentChangeMode); 674 surface->notifyContentWillChange(SkSurface::kDiscard_ContentChangeMode);
646 REPORTER_ASSERT(reporter, as_IB(image)->getTexture() == texture); 675 REPORTER_ASSERT(reporter, as_IB(image)->getTexture() == texture);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 #endif 722 #endif
694 723
695 static void TestSurfaceNoCanvas(skiatest::Reporter* reporter, 724 static void TestSurfaceNoCanvas(skiatest::Reporter* reporter,
696 SurfaceType surfaceType, 725 SurfaceType surfaceType,
697 GrContext* context, 726 GrContext* context,
698 SkSurface::ContentChangeMode mode) { 727 SkSurface::ContentChangeMode mode) {
699 // Verifies the robustness of SkSurface for handling use cases where calls 728 // Verifies the robustness of SkSurface for handling use cases where calls
700 // are made before a canvas is created. 729 // are made before a canvas is created.
701 { 730 {
702 // Test passes by not asserting 731 // Test passes by not asserting
703 SkSurface* surface = createSurface(surfaceType, context); 732 SkSurface* surface = create_surface(surfaceType, context);
704 SkAutoTUnref<SkSurface> aur_surface(surface); 733 SkAutoTUnref<SkSurface> aur_surface(surface);
705 surface->notifyContentWillChange(mode); 734 surface->notifyContentWillChange(mode);
706 SkDEBUGCODE(surface->validate();) 735 SkDEBUGCODE(surface->validate();)
707 } 736 }
708 { 737 {
709 SkSurface* surface = createSurface(surfaceType, context); 738 SkSurface* surface = create_surface(surfaceType, context);
710 SkAutoTUnref<SkSurface> aur_surface(surface); 739 SkAutoTUnref<SkSurface> aur_surface(surface);
711 SkImage* image1 = surface->newImageSnapshot(); 740 SkImage* image1 = surface->newImageSnapshot();
712 SkAutoTUnref<SkImage> aur_image1(image1); 741 SkAutoTUnref<SkImage> aur_image1(image1);
713 SkDEBUGCODE(image1->validate();) 742 SkDEBUGCODE(image1->validate();)
714 SkDEBUGCODE(surface->validate();) 743 SkDEBUGCODE(surface->validate();)
715 surface->notifyContentWillChange(mode); 744 surface->notifyContentWillChange(mode);
716 SkDEBUGCODE(image1->validate();) 745 SkDEBUGCODE(image1->validate();)
717 SkDEBUGCODE(surface->validate();) 746 SkDEBUGCODE(surface->validate();)
718 SkImage* image2 = surface->newImageSnapshot(); 747 SkImage* image2 = surface->newImageSnapshot();
719 SkAutoTUnref<SkImage> aur_image2(image2); 748 SkAutoTUnref<SkImage> aur_image2(image2);
(...skipping 13 matching lines...) Expand all
733 TestSurfaceNoCanvas(reporter, kRaster_SurfaceType, NULL, SkSurface::kRetain_ ContentChangeMode); 762 TestSurfaceNoCanvas(reporter, kRaster_SurfaceType, NULL, SkSurface::kRetain_ ContentChangeMode);
734 763
735 test_empty_image(reporter); 764 test_empty_image(reporter);
736 test_empty_surface(reporter, NULL); 765 test_empty_surface(reporter, NULL);
737 766
738 test_imagepeek(reporter, factory); 767 test_imagepeek(reporter, factory);
739 test_canvaspeek(reporter, factory); 768 test_canvaspeek(reporter, factory);
740 769
741 test_accessPixels(reporter, factory); 770 test_accessPixels(reporter, factory);
742 771
772 test_snap_alphatype(reporter, factory);
773
743 #if SK_SUPPORT_GPU 774 #if SK_SUPPORT_GPU
744 TestGetTexture(reporter, kRaster_SurfaceType, NULL); 775 TestGetTexture(reporter, kRaster_SurfaceType, NULL);
745 if (factory) { 776 if (factory) {
746 for (int i= 0; i < GrContextFactory::kGLContextTypeCnt; ++i) { 777 for (int i= 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
747 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLCon textType) i; 778 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLCon textType) i;
748 if (!GrContextFactory::IsRenderingGLContext(glCtxType)) { 779 if (!GrContextFactory::IsRenderingGLContext(glCtxType)) {
749 continue; 780 continue;
750 } 781 }
751 GrContext* context = factory->get(glCtxType); 782 GrContext* context = factory->get(glCtxType);
752 if (context) { 783 if (context) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 // We expect the ref'd image to see the new color, but cpy'd one should stil l see the old color 891 // We expect the ref'd image to see the new color, but cpy'd one should stil l see the old color
861 test_image_color(reporter, refImg, expected1); 892 test_image_color(reporter, refImg, expected1);
862 test_image_color(reporter, cpyImg, expected0); 893 test_image_color(reporter, cpyImg, expected0);
863 894
864 // Now exercise the release proc 895 // Now exercise the release proc
865 REPORTER_ASSERT(reporter, !releaseCtx.fIsReleased); 896 REPORTER_ASSERT(reporter, !releaseCtx.fIsReleased);
866 refImg.reset(NULL); // force a release of the image 897 refImg.reset(NULL); // force a release of the image
867 REPORTER_ASSERT(reporter, releaseCtx.fIsReleased); 898 REPORTER_ASSERT(reporter, releaseCtx.fIsReleased);
868 } 899 }
869 #endif 900 #endif
OLDNEW
« no previous file with comments | « tests/ReadWriteAlphaTest.cpp ('k') | tools/PictureRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698