| 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 "SkBitmapSource.h" | 9 #include "SkBitmapSource.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 for (int y = 0; y < b2.height(); ++y) { | 310 for (int y = 0; y < b2.height(); ++y) { |
| 311 for (int x = 0; x < b2.width(); ++x) { | 311 for (int x = 0; x < b2.width(); ++x) { |
| 312 if (b1.getColor(x, y) != b2.getColor(x, y)) | 312 if (b1.getColor(x, y) != b2.getColor(x, y)) |
| 313 ++pixelErrors; | 313 ++pixelErrors; |
| 314 } | 314 } |
| 315 } | 315 } |
| 316 REPORTER_ASSERT(reporter, 0 == pixelErrors); | 316 REPORTER_ASSERT(reporter, 0 == pixelErrors); |
| 317 } | 317 } |
| 318 | 318 |
| 319 static void TestPictureTypefaceSerialization(skiatest::Reporter* reporter) { | 319 static void TestPictureTypefaceSerialization(skiatest::Reporter* reporter) { |
| 320 // Load typeface form file. | 320 // Load typeface form file to test CreateFromFile with index. |
| 321 // This test cannot run if there is no resource path. | 321 SkString filename = GetResourcePath("/fonts/test.ttc"); |
| 322 SkString resourcePath = GetResourcePath(); | |
| 323 if (resourcePath.isEmpty()) { | |
| 324 SkDebugf("Could not run fontstream test because resourcePath not specifi
ed."); | |
| 325 return; | |
| 326 } | |
| 327 SkString filename = SkOSPath::Join(resourcePath.c_str(), "test.ttc"); | |
| 328 SkTypeface* typeface = SkTypeface::CreateFromFile(filename.c_str(), 1); | 322 SkTypeface* typeface = SkTypeface::CreateFromFile(filename.c_str(), 1); |
| 329 if (!typeface) { | 323 if (!typeface) { |
| 330 SkDebugf("Could not run fontstream test because test.ttc not found."); | 324 SkDebugf("Could not run fontstream test because test.ttc not found."); |
| 331 return; | 325 return; |
| 332 } | 326 } |
| 333 | 327 |
| 334 // Create a paint with the typeface we loaded. | 328 // Create a paint with the typeface we loaded. |
| 335 SkPaint paint; | 329 SkPaint paint; |
| 336 paint.setColor(SK_ColorGRAY); | 330 paint.setColor(SK_ColorGRAY); |
| 337 paint.setTextSize(SkIntToScalar(30)); | 331 paint.setTextSize(SkIntToScalar(30)); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 | 511 |
| 518 // Deserialize picture | 512 // Deserialize picture |
| 519 SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size); | 513 SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size); |
| 520 SkAutoTUnref<SkPicture> readPict( | 514 SkAutoTUnref<SkPicture> readPict( |
| 521 SkPicture::CreateFromBuffer(reader)); | 515 SkPicture::CreateFromBuffer(reader)); |
| 522 REPORTER_ASSERT(reporter, readPict.get()); | 516 REPORTER_ASSERT(reporter, readPict.get()); |
| 523 } | 517 } |
| 524 | 518 |
| 525 TestPictureTypefaceSerialization(reporter); | 519 TestPictureTypefaceSerialization(reporter); |
| 526 } | 520 } |
| OLD | NEW |