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

Side by Side Diff: tests/SerializationTest.cpp

Issue 195763025: fix a leak (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: AnotherPatchSet Created 6 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 | « no previous file | no next file » | 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 "SkBitmapDevice.h" 8 #include "SkBitmapDevice.h"
9 #include "SkBitmapSource.h" 9 #include "SkBitmapSource.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkMallocPixelRef.h" 11 #include "SkMallocPixelRef.h"
12 #include "SkTemplates.h"
12 #include "SkWriteBuffer.h" 13 #include "SkWriteBuffer.h"
13 #include "SkValidatingReadBuffer.h" 14 #include "SkValidatingReadBuffer.h"
14 #include "SkXfermodeImageFilter.h" 15 #include "SkXfermodeImageFilter.h"
15 #include "Test.h" 16 #include "Test.h"
16 17
17 static const uint32_t kArraySize = 64; 18 static const uint32_t kArraySize = 64;
18 static const int kBitmapSize = 256; 19 static const int kBitmapSize = 256;
19 20
20 template<typename T> 21 template<typename T>
21 static void TestAlignment(T* testObj, skiatest::Reporter* reporter) { 22 static void TestAlignment(T* testObj, skiatest::Reporter* reporter) {
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 SkPicture* pict = new SkPicture; 372 SkPicture* pict = new SkPicture;
372 SkAutoUnref aur(pict); 373 SkAutoUnref aur(pict);
373 bool didDraw = drawSomething(pict->beginRecording(kBitmapSize, kBitmapSi ze)); 374 bool didDraw = drawSomething(pict->beginRecording(kBitmapSize, kBitmapSi ze));
374 REPORTER_ASSERT(reporter, didDraw); 375 REPORTER_ASSERT(reporter, didDraw);
375 pict->endRecording(); 376 pict->endRecording();
376 377
377 // Serialize picture 378 // Serialize picture
378 SkWriteBuffer writer(SkWriteBuffer::kValidation_Flag); 379 SkWriteBuffer writer(SkWriteBuffer::kValidation_Flag);
379 pict->flatten(writer); 380 pict->flatten(writer);
380 size_t size = writer.bytesWritten(); 381 size_t size = writer.bytesWritten();
381 void* data = sk_malloc_throw(size); 382 SkAutoTMalloc<unsigned char> data(size);
382 writer.writeToMemory(data); 383 writer.writeToMemory(static_cast<void*>(data.get()));
383 384
384 // Deserialize picture 385 // Deserialize picture
385 SkValidatingReadBuffer reader(data, size); 386 SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size);
386 SkAutoTUnref<SkPicture> readPict( 387 SkAutoTUnref<SkPicture> readPict(
387 SkPicture::CreateFromBuffer(reader)); 388 SkPicture::CreateFromBuffer(reader));
388 REPORTER_ASSERT(reporter, NULL != readPict.get()); 389 REPORTER_ASSERT(reporter, NULL != readPict.get());
389 } 390 }
390 } 391 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698