| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #include "SkTypes.h" | |
| 8 | 7 |
| 9 #include "Test.h" | 8 #include "Test.h" |
| 9 #include "TestClassDef.h" |
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| 11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
| 12 #include "SkColor.h" | 12 #include "SkColor.h" |
| 13 #include "SkFontHost.h" | 13 #include "SkFontHost.h" |
| 14 #include "SkGraphics.h" | 14 #include "SkGraphics.h" |
| 15 #include "SkPaint.h" | 15 #include "SkPaint.h" |
| 16 #include "SkPoint.h" | 16 #include "SkPoint.h" |
| 17 #include "SkRect.h" | 17 #include "SkRect.h" |
| 18 #include "SkStream.h" | 18 #include "SkStream.h" |
| 19 #include "SkTypeface.h" | 19 #include "SkTypeface.h" |
| 20 | 20 #include "SkTypes.h" |
| 21 /////////////////////////////////////////////////////////////////////////////// | |
| 22 | 21 |
| 23 static const SkColor bgColor = SK_ColorWHITE; | 22 static const SkColor bgColor = SK_ColorWHITE; |
| 24 | 23 |
| 25 static void create(SkBitmap* bm, SkIRect bound, SkBitmap::Config config) { | 24 static void create(SkBitmap* bm, SkIRect bound, SkBitmap::Config config) { |
| 26 bm->setConfig(config, bound.width(), bound.height()); | 25 bm->setConfig(config, bound.width(), bound.height()); |
| 27 bm->allocPixels(); | 26 bm->allocPixels(); |
| 28 } | 27 } |
| 29 | 28 |
| 30 static void drawBG(SkCanvas* canvas) { | 29 static void drawBG(SkCanvas* canvas) { |
| 31 canvas->drawColor(bgColor); | 30 canvas->drawColor(bgColor); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 59 refColor = bgColor; | 58 refColor = bgColor; |
| 60 } | 59 } |
| 61 if (refColor != testColor) { | 60 if (refColor != testColor) { |
| 62 return false; | 61 return false; |
| 63 } | 62 } |
| 64 } | 63 } |
| 65 } | 64 } |
| 66 return true; | 65 return true; |
| 67 } | 66 } |
| 68 | 67 |
| 69 static void test_fontHostStream(skiatest::Reporter* reporter) { | 68 DEF_TEST(FontHostStream, reporter) { |
| 70 | |
| 71 { | 69 { |
| 72 SkPaint paint; | 70 SkPaint paint; |
| 73 paint.setColor(SK_ColorGRAY); | 71 paint.setColor(SK_ColorGRAY); |
| 74 paint.setTextSize(SkIntToScalar(30)); | 72 paint.setTextSize(SkIntToScalar(30)); |
| 75 | 73 |
| 76 SkTypeface* fTypeface = SkTypeface::CreateFromName("Georgia", | 74 SkTypeface* fTypeface = SkTypeface::CreateFromName("Georgia", |
| 77 SkTypeface::kNormal); | 75 SkTypeface::kNormal); |
| 78 SkSafeUnref(paint.setTypeface(fTypeface)); | 76 SkSafeUnref(paint.setTypeface(fTypeface)); |
| 79 | 77 |
| 80 SkIRect origRect = SkIRect::MakeWH(64, 64); | 78 SkIRect origRect = SkIRect::MakeWH(64, 64); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 105 SkSafeUnref(paint.setTypeface(streamTypeface)); | 103 SkSafeUnref(paint.setTypeface(streamTypeface)); |
| 106 drawBG(&streamCanvas); | 104 drawBG(&streamCanvas); |
| 107 streamCanvas.drawPosText("A", 1, &point, paint); | 105 streamCanvas.drawPosText("A", 1, &point, paint); |
| 108 | 106 |
| 109 REPORTER_ASSERT(reporter, | 107 REPORTER_ASSERT(reporter, |
| 110 compare(origBitmap, origRect, streamBitmap, streamRect))
; | 108 compare(origBitmap, origRect, streamBitmap, streamRect))
; |
| 111 } | 109 } |
| 112 //Make sure the typeface is deleted and removed. | 110 //Make sure the typeface is deleted and removed. |
| 113 SkGraphics::PurgeFontCache(); | 111 SkGraphics::PurgeFontCache(); |
| 114 } | 112 } |
| 115 | |
| 116 #include "TestClassDef.h" | |
| 117 DEFINE_TESTCLASS("FontHost::CreateTypefaceFromStream", FontHostStreamTestClass,
test_fontHostStream) | |
| OLD | NEW |