From e70d0e1b7c23f1df0c14023232a97d2cc72a8a8d Mon Sep 17 00:00:00 2001 From: liyuqian Date: Thu, 6 Sep 2018 13:44:47 -0700 Subject: [PATCH] Always serialize fonts during skp capturing (#6160) This fixes flutter/flutter#20788 --- shell/common/rasterizer.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/shell/common/rasterizer.cc b/shell/common/rasterizer.cc index d3d78c6d72..6f08b2afd0 100644 --- a/shell/common/rasterizer.cc +++ b/shell/common/rasterizer.cc @@ -9,6 +9,7 @@ #include "third_party/skia/include/core/SkEncodedImageFormat.h" #include "third_party/skia/include/core/SkImageEncoder.h" #include "third_party/skia/include/core/SkPictureRecorder.h" +#include "third_party/skia/include/core/SkSerialProcs.h" #include "third_party/skia/include/core/SkSurface.h" #include "third_party/skia/include/core/SkSurfaceCharacterization.h" #include "third_party/skia/include/utils/SkBase64.h" @@ -130,7 +131,11 @@ bool Rasterizer::DrawToSurface(flow::LayerTree& layer_tree) { return false; } -static sk_sp ScreenshotLayerTreeAsPicture( +static sk_sp SerializeTypeface(SkTypeface* typeface, void* ctx) { + return typeface->serialize(SkTypeface::SerializeBehavior::kDoIncludeData); +} + +static sk_sp ScreenshotLayerTreeAsPicture( flow::LayerTree* tree, flow::CompositorContext& compositor_context) { FML_DCHECK(tree != nullptr); @@ -147,7 +152,10 @@ static sk_sp ScreenshotLayerTreeAsPicture( frame->Raster(*tree, true); - return recorder.finishRecordingAsPicture(); + SkSerialProcs procs = {0}; + procs.fTypefaceProc = SerializeTypeface; + + return recorder.finishRecordingAsPicture()->serialize(&procs); } static sk_sp CreateSnapshotSurface(GrContext* surface_context, @@ -240,8 +248,7 @@ Rasterizer::Screenshot Rasterizer::ScreenshotLastLayerTree( switch (type) { case ScreenshotType::SkiaPicture: - data = ScreenshotLayerTreeAsPicture(layer_tree, *compositor_context_) - ->serialize(); + data = ScreenshotLayerTreeAsPicture(layer_tree, *compositor_context_); break; case ScreenshotType::UncompressedImage: data = ScreenshotLayerTreeAsImage(layer_tree, *compositor_context_, -- GitLab