|
19 | 19 | #include "flutter/shell/common/switches.h" |
20 | 20 | #include "flutter/shell/version/version.h" |
21 | 21 | #include "flutter/testing/testing.h" |
| 22 | +#include "include/core/SkFont.h" |
22 | 23 | #include "include/core/SkPicture.h" |
23 | 24 | #include "include/core/SkPictureRecorder.h" |
24 | 25 | #include "include/core/SkSerialProcs.h" |
| 26 | +#include "include/core/SkTextBlob.h" |
| 27 | + |
| 28 | +#if defined(OS_FUCHSIA) |
| 29 | +#include "lib/sys/cpp/component_context.h" |
| 30 | +#include "third_party/skia/include/ports/SkFontMgr_fuchsia.h" |
25 | 31 |
|
26 | 32 | namespace flutter { |
27 | 33 | namespace testing { |
28 | 34 |
|
29 | | -#if defined(OS_FUCHSIA) |
30 | | - |
31 | 35 | static void WaitForIO(Shell* shell) { |
32 | 36 | std::promise<bool> io_task_finished; |
33 | 37 | shell->GetTaskRunners().GetIOTaskRunner()->PostTask( |
@@ -103,8 +107,13 @@ class SkpWarmupTest : public ShellTest { |
103 | 107 |
|
104 | 108 | SkDeserialProcs procs = {0}; |
105 | 109 | procs.fImageProc = DeserializeImageWithoutData; |
| 110 | + procs.fTypefaceProc = DeserializeTypefaceWithoutData; |
106 | 111 | sk_sp<SkPicture> picture = |
107 | 112 | SkPicture::MakeFromStream(stream.get(), &procs); |
| 113 | + if (!picture) { |
| 114 | + FML_LOG(ERROR) << "Failed to deserialize " << filename; |
| 115 | + return true; |
| 116 | + } |
108 | 117 | pictures.push_back(std::move(picture)); |
109 | 118 | fd.reset(); |
110 | 119 | } |
@@ -242,7 +251,51 @@ TEST_F(SkpWarmupTest, Image) { |
242 | 251 | TestWarmup(draw_size, builder); |
243 | 252 | } |
244 | 253 |
|
245 | | -#endif |
| 254 | +// Re-enable once https://bugs.chromium.org/p/skia/issues/detail?id=10404 |
| 255 | +// is fixed and integrated, or a workaround is found. |
| 256 | +TEST_F(SkpWarmupTest, DISABLED_Text) { |
| 257 | + auto context = sys::ComponentContext::Create(); |
| 258 | + fuchsia::fonts::ProviderSyncPtr sync_font_provider; |
| 259 | + context->svc()->Connect(sync_font_provider.NewRequest()); |
| 260 | + auto font_mgr = SkFontMgr_New_Fuchsia(std::move(sync_font_provider)); |
| 261 | + auto raw_typeface = |
| 262 | + font_mgr->matchFamilyStyle(nullptr, SkFontStyle::Normal()); |
| 263 | + auto typeface = sk_sp<SkTypeface>(raw_typeface); |
| 264 | + |
| 265 | + SkFont font(typeface, 12); |
| 266 | + auto text_blob = |
| 267 | + SkTextBlob::MakeFromString("test", font, SkTextEncoding::kUTF8); |
| 268 | + |
| 269 | + SkISize draw_size = |
| 270 | + SkISize::Make(text_blob->bounds().width(), text_blob->bounds().height()); |
| 271 | + // We reuse this builder to draw the same content sever times in this test |
| 272 | + LayerTreeBuilder builder = [&draw_size, &text_blob, |
| 273 | + this](std::shared_ptr<ContainerLayer> root) { |
| 274 | + SkPictureRecorder recorder; |
| 275 | + |
| 276 | + auto canvas = |
| 277 | + recorder.beginRecording(draw_size.width(), draw_size.height()); |
| 278 | + |
| 279 | + auto color_space = SkColorSpace::MakeSRGB(); |
| 280 | + auto paint = SkPaint(SkColors::kWhite, color_space.get()); |
| 281 | + canvas->drawTextBlob(text_blob, draw_size.width() / 2, |
| 282 | + draw_size.height() / 2, paint); |
| 283 | + |
| 284 | + auto picture = recorder.finishRecordingAsPicture(); |
| 285 | + |
| 286 | + fml::RefPtr<SkiaUnrefQueue> queue = fml::MakeRefCounted<SkiaUnrefQueue>( |
| 287 | + this->GetCurrentTaskRunner(), fml::TimeDelta::FromSeconds(0)); |
| 288 | + auto picture_layer = std::make_shared<PictureLayer>( |
| 289 | + SkPoint::Make(0, 0), SkiaGPUObject<SkPicture>(picture, queue), |
| 290 | + /* is_complex */ false, |
| 291 | + /* will_change */ false); |
| 292 | + root->Add(picture_layer); |
| 293 | + }; |
| 294 | + |
| 295 | + TestWarmup(draw_size, builder); |
| 296 | +} |
246 | 297 |
|
247 | 298 | } // namespace testing |
248 | 299 | } // namespace flutter |
| 300 | + |
| 301 | +#endif |
0 commit comments