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

Side by Side Diff: tests/BitmapCopyTest.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/ARGBImageEncoderTest.cpp ('k') | tests/CanvasTest.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 2011 Google Inc. 2 * Copyright 2011 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkRect.h" 9 #include "SkRect.h"
10 #include "SkTemplates.h"
10 #include "Test.h" 11 #include "Test.h"
11 12
12 static const char* boolStr(bool value) { 13 static const char* boolStr(bool value) {
13 return value ? "true" : "false"; 14 return value ? "true" : "false";
14 } 15 }
15 16
16 // these are in the same order as the SkColorType enum 17 // these are in the same order as the SkColorType enum
17 static const char* gColorTypeName[] = { 18 static const char* gColorTypeName[] = {
18 "None", "A8", "565", "4444", "RGBA", "BGRA", "Index8" 19 "None", "A8", "565", "4444", "RGBA", "BGRA", "Index8"
19 }; 20 };
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 414
414 // Not all configurations will generate a valid 'subset'. 415 // Not all configurations will generate a valid 'subset'.
415 if (srcReady) { 416 if (srcReady) {
416 417
417 // Allocate our target buffer 'buf' for all copies. 418 // Allocate our target buffer 'buf' for all copies.
418 // To simplify verifying correctness of copies attach 419 // To simplify verifying correctness of copies attach
419 // buf to a SkBitmap, but copies are done using the 420 // buf to a SkBitmap, but copies are done using the
420 // raw buffer pointer. 421 // raw buffer pointer.
421 const size_t bufSize = subH * 422 const size_t bufSize = subH *
422 SkColorTypeMinRowBytes(src.colorType(), subW) * 2; 423 SkColorTypeMinRowBytes(src.colorType(), subW) * 2;
423 SkAutoMalloc autoBuf (bufSize); 424 SkAutoTMalloc<uint8_t> autoBuf (bufSize);
424 uint8_t* buf = static_cast<uint8_t*>(autoBuf.get()); 425 uint8_t* buf = autoBuf.get();
425 426
426 SkBitmap bufBm; // Attach buf to this bitmap. 427 SkBitmap bufBm; // Attach buf to this bitmap.
427 bool successExpected; 428 bool successExpected;
428 429
429 // Set up values for each pixel being copied. 430 // Set up values for each pixel being copied.
430 Coordinates coords(subW * subH); 431 Coordinates coords(subW * subH);
431 for (int x = 0; x < subW; ++x) 432 for (int x = 0; x < subW; ++x)
432 for (int y = 0; y < subH; ++y) 433 for (int y = 0; y < subH; ++y)
433 { 434 {
434 int index = y * subW + x; 435 int index = y * subW + x;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 REPORTER_ASSERT(reporter, check_4x4_pixel(dstC, sx, sy)) ; 625 REPORTER_ASSERT(reporter, check_4x4_pixel(dstC, sx, sy)) ;
625 } else { 626 } else {
626 REPORTER_ASSERT(reporter, 0 == dstC); 627 REPORTER_ASSERT(reporter, 0 == dstC);
627 } 628 }
628 } 629 }
629 } 630 }
630 } 631 }
631 } 632 }
632 } 633 }
633 634
OLDNEW
« no previous file with comments | « tests/ARGBImageEncoderTest.cpp ('k') | tests/CanvasTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698