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 "Resources.h" | 8 #include "Resources.h" |
9 #include "SkAnnotationKeys.h" | 9 #include "SkAnnotationKeys.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
11 #include "SkFixed.h" | 11 #include "SkFixed.h" |
12 #include "SkFontDescriptor.h" | 12 #include "SkFontDescriptor.h" |
13 #include "SkImage.h" | 13 #include "SkImage.h" |
14 #include "SkImageSource.h" | 14 #include "SkImageSource.h" |
15 #include "SkLightingShader.h" | 15 #include "SkLightingShader.h" |
| 16 #include "SkMakeUnique.h" |
16 #include "SkMallocPixelRef.h" | 17 #include "SkMallocPixelRef.h" |
17 #include "SkNormalSource.h" | 18 #include "SkNormalSource.h" |
18 #include "SkOSFile.h" | 19 #include "SkOSFile.h" |
19 #include "SkPictureRecorder.h" | 20 #include "SkPictureRecorder.h" |
20 #include "SkTableColorFilter.h" | 21 #include "SkTableColorFilter.h" |
21 #include "SkTemplates.h" | 22 #include "SkTemplates.h" |
22 #include "SkTypeface.h" | 23 #include "SkTypeface.h" |
23 #include "SkWriteBuffer.h" | 24 #include "SkWriteBuffer.h" |
24 #include "SkValidatingReadBuffer.h" | 25 #include "SkValidatingReadBuffer.h" |
25 #include "SkXfermodeImageFilter.h" | 26 #include "SkXfermodeImageFilter.h" |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 sk_sp<SkTypeface> typeface(SkTypeface::MakeFromFile(filename.c_str(), 1)
); | 364 sk_sp<SkTypeface> typeface(SkTypeface::MakeFromFile(filename.c_str(), 1)
); |
364 if (!typeface) { | 365 if (!typeface) { |
365 INFOF(reporter, "Could not run fontstream test because test.ttc not
found."); | 366 INFOF(reporter, "Could not run fontstream test because test.ttc not
found."); |
366 } else { | 367 } else { |
367 serialize_and_compare_typeface(std::move(typeface), "A!", reporter); | 368 serialize_and_compare_typeface(std::move(typeface), "A!", reporter); |
368 } | 369 } |
369 } | 370 } |
370 | 371 |
371 { | 372 { |
372 // Load typeface as stream to create with axis settings. | 373 // Load typeface as stream to create with axis settings. |
373 SkAutoTDelete<SkStreamAsset> distortable(GetResourceAsStream("/fonts/Dis
tortable.ttf")); | 374 std::unique_ptr<SkStreamAsset> distortable(GetResourceAsStream("/fonts/D
istortable.ttf")); |
374 if (!distortable) { | 375 if (!distortable) { |
375 INFOF(reporter, "Could not run fontstream test because Distortable.t
tf not found."); | 376 INFOF(reporter, "Could not run fontstream test because Distortable.t
tf not found."); |
376 } else { | 377 } else { |
377 SkFixed axis = SK_FixedSqrt2; | 378 SkFixed axis = SK_FixedSqrt2; |
378 sk_sp<SkTypeface> typeface(SkTypeface::MakeFromFontData( | 379 sk_sp<SkTypeface> typeface(SkTypeface::MakeFromFontData( |
379 new SkFontData(distortable.release(), 0, &axis, 1))); | 380 skstd::make_unique<SkFontData>(std::move(distortable), 0, &axis,
1))); |
380 if (!typeface) { | 381 if (!typeface) { |
381 INFOF(reporter, "Could not run fontstream test because Distortab
le.ttf not created."); | 382 INFOF(reporter, "Could not run fontstream test because Distortab
le.ttf not created."); |
382 } else { | 383 } else { |
383 serialize_and_compare_typeface(std::move(typeface), "abc", repor
ter); | 384 serialize_and_compare_typeface(std::move(typeface), "abc", repor
ter); |
384 } | 385 } |
385 } | 386 } |
386 } | 387 } |
387 } | 388 } |
388 | 389 |
389 static void setup_bitmap_for_canvas(SkBitmap* bitmap) { | 390 static void setup_bitmap_for_canvas(SkBitmap* bitmap) { |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 { r1, SkAnnotationKeys::Define_Named_Dest_Key(), std::move(d1) }, | 694 { r1, SkAnnotationKeys::Define_Named_Dest_Key(), std::move(d1) }, |
694 { r2, SkAnnotationKeys::Link_Named_Dest_Key(), std::move(d2) }, | 695 { r2, SkAnnotationKeys::Link_Named_Dest_Key(), std::move(d2) }, |
695 }; | 696 }; |
696 | 697 |
697 sk_sp<SkPicture> pict0(recorder.finishRecordingAsPicture()); | 698 sk_sp<SkPicture> pict0(recorder.finishRecordingAsPicture()); |
698 sk_sp<SkPicture> pict1(copy_picture_via_serialization(pict0.get())); | 699 sk_sp<SkPicture> pict1(copy_picture_via_serialization(pict0.get())); |
699 | 700 |
700 TestAnnotationCanvas canvas(reporter, recs, SK_ARRAY_COUNT(recs)); | 701 TestAnnotationCanvas canvas(reporter, recs, SK_ARRAY_COUNT(recs)); |
701 canvas.drawPicture(pict1); | 702 canvas.drawPicture(pict1); |
702 } | 703 } |
OLD | NEW |