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

Side by Side Diff: tests/CanvasTest.cpp

Issue 1784563002: unify peekPixels around pixmap parameter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update GrUploadPixmapToTexture to know about the new desc if readPixels was called Created 4 years, 9 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 | « src/image/SkSurface.cpp ('k') | tests/ImageTest.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 2012 Google Inc. 2 * Copyright 2012 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 /* Description: 8 /* Description:
9 * This test defines a series of elementatry test steps that perform 9 * This test defines a series of elementatry test steps that perform
10 * a single or a small group of canvas API calls. Each test step is 10 * a single or a small group of canvas API calls. Each test step is
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10); 639 SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10);
640 const size_t minRowBytes = info.minRowBytes(); 640 const size_t minRowBytes = info.minRowBytes();
641 const size_t size = info.getSafeSize(minRowBytes); 641 const size_t size = info.getSafeSize(minRowBytes);
642 SkAutoTMalloc<SkPMColor> storage(size); 642 SkAutoTMalloc<SkPMColor> storage(size);
643 SkPMColor* baseAddr = storage.get(); 643 SkPMColor* baseAddr = storage.get();
644 sk_bzero(baseAddr, size); 644 sk_bzero(baseAddr, size);
645 645
646 SkCanvas* canvas = SkCanvas::NewRasterDirect(info, baseAddr, minRowBytes); 646 SkCanvas* canvas = SkCanvas::NewRasterDirect(info, baseAddr, minRowBytes);
647 REPORTER_ASSERT(reporter, canvas); 647 REPORTER_ASSERT(reporter, canvas);
648 648
649 SkImageInfo info2; 649 SkPixmap pmap;
650 size_t rowBytes; 650 const SkPMColor* addr = canvas->peekPixels(&pmap) ? pmap.addr32() : nullptr;
651 const SkPMColor* addr = (const SkPMColor*)canvas->peekPixels(&info2, &rowByt es);
652 REPORTER_ASSERT(reporter, addr); 651 REPORTER_ASSERT(reporter, addr);
653 REPORTER_ASSERT(reporter, info == info2); 652 REPORTER_ASSERT(reporter, info == pmap.info());
654 REPORTER_ASSERT(reporter, minRowBytes == rowBytes); 653 REPORTER_ASSERT(reporter, minRowBytes == pmap.rowBytes());
655 for (int y = 0; y < info.height(); ++y) { 654 for (int y = 0; y < info.height(); ++y) {
656 for (int x = 0; x < info.width(); ++x) { 655 for (int x = 0; x < info.width(); ++x) {
657 REPORTER_ASSERT(reporter, 0 == addr[x]); 656 REPORTER_ASSERT(reporter, 0 == addr[x]);
658 } 657 }
659 addr = (const SkPMColor*)((const char*)addr + rowBytes); 658 addr = (const SkPMColor*)((const char*)addr + pmap.rowBytes());
660 } 659 }
661 delete canvas; 660 delete canvas;
662 661
663 // now try a deliberately bad info 662 // now try a deliberately bad info
664 info = info.makeWH(-1, info.height()); 663 info = info.makeWH(-1, info.height());
665 REPORTER_ASSERT(reporter, nullptr == SkCanvas::NewRasterDirect(info, baseAdd r, minRowBytes)); 664 REPORTER_ASSERT(reporter, nullptr == SkCanvas::NewRasterDirect(info, baseAdd r, minRowBytes));
666 665
667 // too big 666 // too big
668 info = info.makeWH(1 << 30, 1 << 30); 667 info = info.makeWH(1 << 30, 1 << 30);
669 REPORTER_ASSERT(reporter, nullptr == SkCanvas::NewRasterDirect(info, baseAdd r, minRowBytes)); 668 REPORTER_ASSERT(reporter, nullptr == SkCanvas::NewRasterDirect(info, baseAdd r, minRowBytes));
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix()); 752 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix());
754 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2)); 753 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2));
755 REPORTER_ASSERT(reporter, clip1 == clip2); 754 REPORTER_ASSERT(reporter, clip1 == clip2);
756 755
757 filterCanvas.clipRect(SkRect::MakeXYWH(30.5f, 30.7f, 100, 100)); 756 filterCanvas.clipRect(SkRect::MakeXYWH(30.5f, 30.7f, 100, 100));
758 filterCanvas.scale(0.75f, 0.5f); 757 filterCanvas.scale(0.75f, 0.5f);
759 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix()); 758 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix());
760 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2)); 759 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2));
761 REPORTER_ASSERT(reporter, clip1 == clip2); 760 REPORTER_ASSERT(reporter, clip1 == clip2);
762 } 761 }
OLDNEW
« no previous file with comments | « src/image/SkSurface.cpp ('k') | tests/ImageTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698