OLD | NEW |
---|---|
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 "SkWriteBuffer.h" | 12 #include "SkWriteBuffer.h" |
13 #include "SkValidatingReadBuffer.h" | 13 #include "SkValidatingReadBuffer.h" |
bungeman-skia
2014/03/14 18:49:06
Should #include "SkTemplates.h" here for the SkAut
| |
14 #include "SkXfermodeImageFilter.h" | 14 #include "SkXfermodeImageFilter.h" |
15 #include "Test.h" | 15 #include "Test.h" |
16 | 16 |
17 static const uint32_t kArraySize = 64; | 17 static const uint32_t kArraySize = 64; |
18 static const int kBitmapSize = 256; | 18 static const int kBitmapSize = 256; |
19 | 19 |
20 template<typename T> | 20 template<typename T> |
21 static void TestAlignment(T* testObj, skiatest::Reporter* reporter) { | 21 static void TestAlignment(T* testObj, skiatest::Reporter* reporter) { |
22 // Test memory read/write functions directly | 22 // Test memory read/write functions directly |
23 unsigned char dataWritten[1024]; | 23 unsigned char dataWritten[1024]; |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
371 SkPicture* pict = new SkPicture; | 371 SkPicture* pict = new SkPicture; |
372 SkAutoUnref aur(pict); | 372 SkAutoUnref aur(pict); |
373 bool didDraw = drawSomething(pict->beginRecording(kBitmapSize, kBitmapSi ze)); | 373 bool didDraw = drawSomething(pict->beginRecording(kBitmapSize, kBitmapSi ze)); |
374 REPORTER_ASSERT(reporter, didDraw); | 374 REPORTER_ASSERT(reporter, didDraw); |
375 pict->endRecording(); | 375 pict->endRecording(); |
376 | 376 |
377 // Serialize picture | 377 // Serialize picture |
378 SkWriteBuffer writer(SkWriteBuffer::kValidation_Flag); | 378 SkWriteBuffer writer(SkWriteBuffer::kValidation_Flag); |
379 pict->flatten(writer); | 379 pict->flatten(writer); |
380 size_t size = writer.bytesWritten(); | 380 size_t size = writer.bytesWritten(); |
381 void* data = sk_malloc_throw(size); | 381 SkAutoTMalloc<unsigned char> data(size); |
382 writer.writeToMemory(data); | 382 writer.writeToMemory(static_cast<void*>(data.get())); |
383 | 383 |
384 // Deserialize picture | 384 // Deserialize picture |
385 SkValidatingReadBuffer reader(data, size); | 385 SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size); |
386 SkAutoTUnref<SkPicture> readPict( | 386 SkAutoTUnref<SkPicture> readPict( |
387 SkPicture::CreateFromBuffer(reader)); | 387 SkPicture::CreateFromBuffer(reader)); |
388 REPORTER_ASSERT(reporter, NULL != readPict.get()); | 388 REPORTER_ASSERT(reporter, NULL != readPict.get()); |
389 } | 389 } |
390 } | 390 } |
OLD | NEW |