| 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 | 7 |
| 8 #include "SkBitmap.h" | 8 #include "SkBitmap.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkColor.h" | 10 #include "SkColor.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 85 |
| 86 SkPoint point = SkPoint::Make(24, 32); | 86 SkPoint point = SkPoint::Make(24, 32); |
| 87 | 87 |
| 88 // Test: origTypeface and streamTypeface from orig data draw the same | 88 // Test: origTypeface and streamTypeface from orig data draw the same |
| 89 drawBG(&origCanvas); | 89 drawBG(&origCanvas); |
| 90 origCanvas.drawText("A", 1, point.fX, point.fY, paint); | 90 origCanvas.drawText("A", 1, point.fX, point.fY, paint); |
| 91 | 91 |
| 92 SkTypeface* origTypeface = paint.getTypeface(); | 92 SkTypeface* origTypeface = paint.getTypeface(); |
| 93 SkAutoTUnref<SkTypeface> aur; | 93 SkAutoTUnref<SkTypeface> aur; |
| 94 if (nullptr == origTypeface) { | 94 if (nullptr == origTypeface) { |
| 95 origTypeface = aur.reset(SkTypeface::RefDefault()); | 95 aur.reset(SkTypeface::RefDefault()); |
| 96 origTypeface = aur.get(); |
| 96 } | 97 } |
| 97 | 98 |
| 98 int ttcIndex; | 99 int ttcIndex; |
| 99 SkAutoTDelete<SkStreamAsset> fontData(origTypeface->openStream(&ttcIndex
)); | 100 SkAutoTDelete<SkStreamAsset> fontData(origTypeface->openStream(&ttcIndex
)); |
| 100 SkTypeface* streamTypeface = SkTypeface::CreateFromStream(fontData.detac
h()); | 101 SkTypeface* streamTypeface = SkTypeface::CreateFromStream(fontData.detac
h()); |
| 101 | 102 |
| 102 SkFontDescriptor desc; | 103 SkFontDescriptor desc; |
| 103 bool isLocalStream = false; | 104 bool isLocalStream = false; |
| 104 streamTypeface->getFontDescriptor(&desc, &isLocalStream); | 105 streamTypeface->getFontDescriptor(&desc, &isLocalStream); |
| 105 REPORTER_ASSERT(reporter, isLocalStream); | 106 REPORTER_ASSERT(reporter, isLocalStream); |
| 106 | 107 |
| 107 SkSafeUnref(paint.setTypeface(streamTypeface)); | 108 SkSafeUnref(paint.setTypeface(streamTypeface)); |
| 108 drawBG(&streamCanvas); | 109 drawBG(&streamCanvas); |
| 109 streamCanvas.drawPosText("A", 1, &point, paint); | 110 streamCanvas.drawPosText("A", 1, &point, paint); |
| 110 | 111 |
| 111 REPORTER_ASSERT(reporter, | 112 REPORTER_ASSERT(reporter, |
| 112 compare(origBitmap, origRect, streamBitmap, streamRect))
; | 113 compare(origBitmap, origRect, streamBitmap, streamRect))
; |
| 113 } | 114 } |
| 114 //Make sure the typeface is deleted and removed. | 115 //Make sure the typeface is deleted and removed. |
| 115 SkGraphics::PurgeFontCache(); | 116 SkGraphics::PurgeFontCache(); |
| 116 } | 117 } |
| OLD | NEW |