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

Unified Diff: tests/SerializationTest.cpp

Issue 1128913008: Revert of Font variations. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/FontConfigParser.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/SerializationTest.cpp
diff --git a/tests/SerializationTest.cpp b/tests/SerializationTest.cpp
index 31dbbe8ad93c00af466b4c3f8a632c44121d5284..f7e298305f86fc5741b7d07422485785c95dbbe1 100644
--- a/tests/SerializationTest.cpp
+++ b/tests/SerializationTest.cpp
@@ -8,8 +8,6 @@
#include "Resources.h"
#include "SkBitmapSource.h"
#include "SkCanvas.h"
-#include "SkFixed.h"
-#include "SkFontDescriptor.h"
#include "SkMallocPixelRef.h"
#include "SkOSFile.h"
#include "SkPictureRecorder.h"
@@ -317,14 +315,21 @@
}
REPORTER_ASSERT(reporter, 0 == pixelErrors);
}
-static void serialize_and_compare_typeface(SkTypeface* typeface, const char* text,
- skiatest::Reporter* reporter)
-{
- // Create a paint with the typeface.
+
+static void TestPictureTypefaceSerialization(skiatest::Reporter* reporter) {
+ // Load typeface form file to test CreateFromFile with index.
+ SkString filename = GetResourcePath("/fonts/test.ttc");
+ SkTypeface* typeface = SkTypeface::CreateFromFile(filename.c_str(), 1);
+ if (!typeface) {
+ SkDebugf("Could not run fontstream test because test.ttc not found.");
+ return;
+ }
+
+ // Create a paint with the typeface we loaded.
SkPaint paint;
paint.setColor(SK_ColorGRAY);
paint.setTextSize(SkIntToScalar(30));
- paint.setTypeface(typeface);
+ SkSafeUnref(paint.setTypeface(typeface));
// Paint some text.
SkPictureRecorder recorder;
@@ -333,7 +338,7 @@
SkIntToScalar(canvasRect.height()),
NULL, 0);
canvas->drawColor(SK_ColorWHITE);
- canvas->drawText(text, 2, 24, 32, paint);
+ canvas->drawText("A!", 2, 24, 32, paint);
SkAutoTUnref<SkPicture> picture(recorder.endRecording());
// Serlialize picture and create its clone from stream.
@@ -346,36 +351,6 @@
SkBitmap origBitmap = draw_picture(*picture);
SkBitmap destBitmap = draw_picture(*loadedPicture);
compare_bitmaps(reporter, origBitmap, destBitmap);
-}
-
-static void TestPictureTypefaceSerialization(skiatest::Reporter* reporter) {
- {
- // Load typeface from file to test CreateFromFile with index.
- SkString filename = GetResourcePath("/fonts/test.ttc");
- SkAutoTUnref<SkTypeface> typeface(SkTypeface::CreateFromFile(filename.c_str(), 1));
- if (!typeface) {
- SkDebugf("Could not run fontstream test because test.ttc not found.");
- } else {
- serialize_and_compare_typeface(typeface, "A!", reporter);
- }
- }
-
- {
- // Load typeface as stream to create with axis settings.
- SkAutoTDelete<SkStreamAsset> distortable(GetResourceAsStream("/fonts/Distortable.ttf"));
- if (!distortable) {
- SkDebugf("Could not run fontstream test because Distortable.ttf not found.");
- } else {
- SkFixed axis = SK_FixedSqrt2;
- SkAutoTUnref<SkTypeface> typeface(SkTypeface::CreateFromFontData(
- new SkFontData(distortable.detach(), 0, &axis, 1)));
- if (!typeface) {
- SkDebugf("Could not run fontstream test because Distortable.ttf not created.");
- } else {
- serialize_and_compare_typeface(typeface, "abc", reporter);
- }
- }
- }
}
static void setup_bitmap_for_canvas(SkBitmap* bitmap) {
« no previous file with comments | « tests/FontConfigParser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698