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

Side by Side Diff: tests/ARGBImageEncoderTest.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 | « src/svg/parser/SkSVG.cpp ('k') | tests/BitmapCopyTest.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 #include "SkImageEncoder.h" 8 #include "SkImageEncoder.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
11 #include "SkCanvas.h" 11 #include "SkCanvas.h"
12 #include "SkStream.h" 12 #include "SkStream.h"
13 #include "SkTemplates.h"
13 #include "Test.h" 14 #include "Test.h"
14 15
15 static SkColorType gColorTypes[] = { 16 static SkColorType gColorTypes[] = {
16 kRGB_565_SkColorType, 17 kRGB_565_SkColorType,
17 kN32_SkColorType, 18 kN32_SkColorType,
18 }; 19 };
19 20
20 DEF_TEST(ARGBImageEncoder, reporter) { 21 DEF_TEST(ARGBImageEncoder, reporter) {
21 // Bytes we expect to get: 22 // Bytes we expect to get:
22 const int kWidth = 3; 23 const int kWidth = 3;
(...skipping 19 matching lines...) Expand all
42 SkCanvas canvas(bitmap); 43 SkCanvas canvas(bitmap);
43 SkPaint paint; 44 SkPaint paint;
44 paint.setColor(SK_ColorRED); 45 paint.setColor(SK_ColorRED);
45 canvas.drawIRect(SkIRect::MakeLTRB(0, 0, kWidth, 1), paint); 46 canvas.drawIRect(SkIRect::MakeLTRB(0, 0, kWidth, 1), paint);
46 paint.setColor(SK_ColorGREEN); 47 paint.setColor(SK_ColorGREEN);
47 canvas.drawIRect(SkIRect::MakeLTRB(0, 1, kWidth, 2), paint); 48 canvas.drawIRect(SkIRect::MakeLTRB(0, 1, kWidth, 2), paint);
48 } 49 }
49 50
50 // Transform the bitmap. 51 // Transform the bitmap.
51 int bufferSize = bitmap.width() * bitmap.height() * 4; 52 int bufferSize = bitmap.width() * bitmap.height() * 4;
52 SkAutoMalloc pixelBufferManager(bufferSize); 53 SkAutoTMalloc<char> pixelBufferManager(bufferSize);
53 char *pixelBuffer = static_cast<char *>(pixelBufferManager.get()); 54 char* pixelBuffer = pixelBufferManager.get();
54 SkMemoryWStream out(pixelBuffer, bufferSize); 55 SkMemoryWStream out(pixelBuffer, bufferSize);
55 REPORTER_ASSERT(reporter, enc->encodeStream(&out, bitmap, SkImageEncoder ::kDefaultQuality)); 56 REPORTER_ASSERT(reporter, enc->encodeStream(&out, bitmap, SkImageEncoder ::kDefaultQuality));
56 57
57 // Confirm we got the expected results. 58 // Confirm we got the expected results.
58 REPORTER_ASSERT(reporter, bufferSize == sizeof(comparisonBuffer)); 59 REPORTER_ASSERT(reporter, bufferSize == sizeof(comparisonBuffer));
59 REPORTER_ASSERT(reporter, memcmp(pixelBuffer, comparisonBuffer, bufferSi ze) == 0); 60 REPORTER_ASSERT(reporter, memcmp(pixelBuffer, comparisonBuffer, bufferSi ze) == 0);
60 } 61 }
61 } 62 }
OLDNEW
« no previous file with comments | « src/svg/parser/SkSVG.cpp ('k') | tests/BitmapCopyTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698