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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkFixed.h" | 10 #include "SkFixed.h" |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 SkBitmap destBitmap = draw_picture(*loadedPicture); | 350 SkBitmap destBitmap = draw_picture(*loadedPicture); |
351 compare_bitmaps(reporter, origBitmap, destBitmap); | 351 compare_bitmaps(reporter, origBitmap, destBitmap); |
352 } | 352 } |
353 | 353 |
354 static void TestPictureTypefaceSerialization(skiatest::Reporter* reporter) { | 354 static void TestPictureTypefaceSerialization(skiatest::Reporter* reporter) { |
355 { | 355 { |
356 // Load typeface from file to test CreateFromFile with index. | 356 // Load typeface from file to test CreateFromFile with index. |
357 SkString filename = GetResourcePath("/fonts/test.ttc"); | 357 SkString filename = GetResourcePath("/fonts/test.ttc"); |
358 SkAutoTUnref<SkTypeface> typeface(SkTypeface::CreateFromFile(filename.c_
str(), 1)); | 358 SkAutoTUnref<SkTypeface> typeface(SkTypeface::CreateFromFile(filename.c_
str(), 1)); |
359 if (!typeface) { | 359 if (!typeface) { |
360 SkDebugf("Could not run fontstream test because test.ttc not found."
); | 360 INFOF(reporter, "Could not run fontstream test because test.ttc not
found."); |
361 } else { | 361 } else { |
362 serialize_and_compare_typeface(typeface, "A!", reporter); | 362 serialize_and_compare_typeface(typeface, "A!", reporter); |
363 } | 363 } |
364 } | 364 } |
365 | 365 |
366 { | 366 { |
367 // Load typeface as stream to create with axis settings. | 367 // Load typeface as stream to create with axis settings. |
368 SkAutoTDelete<SkStreamAsset> distortable(GetResourceAsStream("/fonts/Dis
tortable.ttf")); | 368 SkAutoTDelete<SkStreamAsset> distortable(GetResourceAsStream("/fonts/Dis
tortable.ttf")); |
369 if (!distortable) { | 369 if (!distortable) { |
370 SkDebugf("Could not run fontstream test because Distortable.ttf not
found."); | 370 INFOF(reporter, "Could not run fontstream test because Distortable.t
tf not found."); |
371 } else { | 371 } else { |
372 SkFixed axis = SK_FixedSqrt2; | 372 SkFixed axis = SK_FixedSqrt2; |
373 SkAutoTUnref<SkTypeface> typeface(SkTypeface::CreateFromFontData( | 373 SkAutoTUnref<SkTypeface> typeface(SkTypeface::CreateFromFontData( |
374 new SkFontData(distortable.detach(), 0, &axis, 1))); | 374 new SkFontData(distortable.detach(), 0, &axis, 1))); |
375 if (!typeface) { | 375 if (!typeface) { |
376 SkDebugf("Could not run fontstream test because Distortable.ttf
not created."); | 376 INFOF(reporter, "Could not run fontstream test because Distortab
le.ttf not created."); |
377 } else { | 377 } else { |
378 serialize_and_compare_typeface(typeface, "abc", reporter); | 378 serialize_and_compare_typeface(typeface, "abc", reporter); |
379 } | 379 } |
380 } | 380 } |
381 } | 381 } |
382 } | 382 } |
383 | 383 |
384 static void setup_bitmap_for_canvas(SkBitmap* bitmap) { | 384 static void setup_bitmap_for_canvas(SkBitmap* bitmap) { |
385 bitmap->allocN32Pixels(kBitmapSize, kBitmapSize); | 385 bitmap->allocN32Pixels(kBitmapSize, kBitmapSize); |
386 } | 386 } |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 | 539 |
540 // Deserialize picture | 540 // Deserialize picture |
541 SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size); | 541 SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size); |
542 SkAutoTUnref<SkPicture> readPict( | 542 SkAutoTUnref<SkPicture> readPict( |
543 SkPicture::CreateFromBuffer(reader)); | 543 SkPicture::CreateFromBuffer(reader)); |
544 REPORTER_ASSERT(reporter, readPict.get()); | 544 REPORTER_ASSERT(reporter, readPict.get()); |
545 } | 545 } |
546 | 546 |
547 TestPictureTypefaceSerialization(reporter); | 547 TestPictureTypefaceSerialization(reporter); |
548 } | 548 } |
OLD | NEW |