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

Side by Side Diff: tests/CanvasTest.cpp

Issue 1516833003: Switch SkAutoMalloc to SkAutoTMalloc to avoid cast (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Go back to patch set 3 Created 5 years 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/BitmapCopyTest.cpp ('k') | tests/TextureCompressionTest.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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "SkPaintFilterCanvas.h" 54 #include "SkPaintFilterCanvas.h"
55 #include "SkPath.h" 55 #include "SkPath.h"
56 #include "SkPicture.h" 56 #include "SkPicture.h"
57 #include "SkPictureRecord.h" 57 #include "SkPictureRecord.h"
58 #include "SkPictureRecorder.h" 58 #include "SkPictureRecorder.h"
59 #include "SkRect.h" 59 #include "SkRect.h"
60 #include "SkRegion.h" 60 #include "SkRegion.h"
61 #include "SkShader.h" 61 #include "SkShader.h"
62 #include "SkStream.h" 62 #include "SkStream.h"
63 #include "SkSurface.h" 63 #include "SkSurface.h"
64 #include "SkTemplates.h"
64 #include "SkTDArray.h" 65 #include "SkTDArray.h"
65 #include "Test.h" 66 #include "Test.h"
66 67
67 static const int kWidth = 2, kHeight = 2; 68 static const int kWidth = 2, kHeight = 2;
68 69
69 static void createBitmap(SkBitmap* bm, SkColor color) { 70 static void createBitmap(SkBitmap* bm, SkColor color) {
70 bm->allocN32Pixels(kWidth, kHeight); 71 bm->allocN32Pixels(kWidth, kHeight);
71 bm->eraseColor(color); 72 bm->eraseColor(color);
72 } 73 }
73 74
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 if (false) { // avoid bit rot, suppress warning 629 if (false) { // avoid bit rot, suppress warning
629 test_clipVisitor(reporter, &referenceCanvas); 630 test_clipVisitor(reporter, &referenceCanvas);
630 } 631 }
631 test_clipstack(reporter); 632 test_clipstack(reporter);
632 } 633 }
633 634
634 static void test_newraster(skiatest::Reporter* reporter) { 635 static void test_newraster(skiatest::Reporter* reporter) {
635 SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10); 636 SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10);
636 const size_t minRowBytes = info.minRowBytes(); 637 const size_t minRowBytes = info.minRowBytes();
637 const size_t size = info.getSafeSize(minRowBytes); 638 const size_t size = info.getSafeSize(minRowBytes);
638 SkAutoMalloc storage(size); 639 SkAutoTMalloc<SkPMColor> storage(size);
639 SkPMColor* baseAddr = static_cast<SkPMColor*>(storage.get()); 640 SkPMColor* baseAddr = storage.get();
640 sk_bzero(baseAddr, size); 641 sk_bzero(baseAddr, size);
641 642
642 SkCanvas* canvas = SkCanvas::NewRasterDirect(info, baseAddr, minRowBytes); 643 SkCanvas* canvas = SkCanvas::NewRasterDirect(info, baseAddr, minRowBytes);
643 REPORTER_ASSERT(reporter, canvas); 644 REPORTER_ASSERT(reporter, canvas);
644 645
645 SkImageInfo info2; 646 SkImageInfo info2;
646 size_t rowBytes; 647 size_t rowBytes;
647 const SkPMColor* addr = (const SkPMColor*)canvas->peekPixels(&info2, &rowByt es); 648 const SkPMColor* addr = (const SkPMColor*)canvas->peekPixels(&info2, &rowByt es);
648 REPORTER_ASSERT(reporter, addr); 649 REPORTER_ASSERT(reporter, addr);
649 REPORTER_ASSERT(reporter, info == info2); 650 REPORTER_ASSERT(reporter, info == info2);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix()); 750 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix());
750 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2)); 751 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2));
751 REPORTER_ASSERT(reporter, clip1 == clip2); 752 REPORTER_ASSERT(reporter, clip1 == clip2);
752 753
753 filterCanvas.clipRect(SkRect::MakeXYWH(30.5f, 30.7f, 100, 100)); 754 filterCanvas.clipRect(SkRect::MakeXYWH(30.5f, 30.7f, 100, 100));
754 filterCanvas.scale(0.75f, 0.5f); 755 filterCanvas.scale(0.75f, 0.5f);
755 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix()); 756 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix());
756 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2)); 757 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2));
757 REPORTER_ASSERT(reporter, clip1 == clip2); 758 REPORTER_ASSERT(reporter, clip1 == clip2);
758 } 759 }
OLDNEW
« no previous file with comments | « tests/BitmapCopyTest.cpp ('k') | tests/TextureCompressionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698