ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

skia 将网页录制成 skp 文件 通过skia的dm或者其他方式重放

2021-06-16 18:04:40  阅读:317  来源: 互联网

标签:tmp dm skp mskp -- filename Skia skia


https://skia.org/docs/user/tips/

1,Use the script experimental/tools/web_to_skp , or do the following:

  1. Launch Chrome or Chromium with --no-sandbox --enable-gpu-benchmarking
  2. Open the JS console (Ctrl+Shift+J (Windows / Linux) or Cmd+Opt+J (MacOS))
  3. Execute: chrome.gpuBenchmarking.printToSkPicture('/tmp') This returns “undefined” on success.

/tmp是个存放的目录。windows可以写成 chrome.gpuBenchmarking.printToSkPicture('d:\\mySkp')

Open the resulting file in the Skia Debugger, rasterize it with dm, or use Skia’s viewer to view it:

out/Release/dm --src skp --skps /tmp/layer_0.skp -w /tmp \
    --config 8888 gpu pdf --verbose
ls -l /tmp/*/skp/layer_0.skp.*

out/Release/viewer --skps /tmp --slide layer_0.skp

 

2, 也可录制多个页面,还原成pdf

Capture a .mskp file on a web page in Chromium

Multipage Skia Picture files capture the commands sent to produce PDFs and printed documents.

Use the script experimental/tools/web_to_mskp , or do the following:

  1. Launch Chrome or Chromium with --no-sandbox --enable-gpu-benchmarking
  2. Open the JS console (Ctrl+Shift+J (Windows / Linux) or Cmd+Opt+J (MacOS))
  3. Execute: chrome.gpuBenchmarking.printPagesToSkPictures('/tmp/filename.mskp') This returns “undefined” on success.

Open the resulting file in the Skia Debugger or process it with dm.

experimental/tools/mskp_parser.py /tmp/filename.mskp /tmp/filename.mskp.skp
ls -l /tmp/filename.mskp.skp
# open filename.mskp.skp in the debugger.

out/Release/dm --src mskp --mskps /tmp/filename.mskp -w /tmp \
    --config pdf --verbose
ls -l /tmp/pdf/mskp/filename.mskp.pdf

How to add hardware acceleration in Skia

There are two ways Skia takes advantage of specific hardware.

  1. Custom bottleneck routines

    There are sets of bottleneck routines inside the blits of Skia that can be replace on a platform in order to take advantage of specific CPU features. One such example is the NEON SIMD instructions on ARM v7 devices. See src/opts/


Does Skia support Font hinting?

Skia has a built-in font cache, but it does not know how to actually render font files like TrueType into its cache. For that it relies on the platform to supply an instance of SkScalerContext. This is Skia’s abstract interface for communicating with a font scaler engine. In src/ports you can see support files for FreeType, macOS, and Windows GDI font engines. Other font engines can easily be supported in a like manner.


Does Skia shape text (kerning)?

Shaping is the process that translates a span of Unicode text into a span of positioned glyphs with the appropriate typefaces.

Skia does not shape text. Skia provides interfaces to draw glyphs, but does not implement a text shaper. Skia’s client’s often use HarfBuzz to generate the glyphs and their positions, including kerning.

Here is an example of how to use Skia and HarfBuzz together. In the example, a SkTypeface and a hb_face_t are created using the same mmap()ed .ttf font file. The HarfBuzz face is used to shape unicode text into a sequence of glyphs and positions, and the SkTypeface can then be used to draw those glyphs.


How do I add drop shadow on text?

void draw(SkCanvas* canvas) {
    const SkScalar sigma = 1.65f;
    const SkScalar xDrop = 2.0f;
    const SkScalar yDrop = 2.0f;
    const SkScalar x = 8.0f;
    const SkScalar y = 52.0f;
    const SkScalar textSize = 48.0f;
    const uint8_t blurAlpha = 127;
    auto blob = SkTextBlob::MakeFromString("Skia", SkFont(nullptr, textSize));
    SkPaint paint;
    paint.setAntiAlias(true);
    SkPaint blur(paint);
    blur.setAlpha(blurAlpha);
    blur.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, sigma, 0));
    canvas->drawColor(SK_ColorWHITE);
    canvas->drawTextBlob(blob.get(), x + xDrop, y + yDrop, blur);
    canvas->drawTextBlob(blob.get(), x,         y,         paint);
}

标签:tmp,dm,skp,mskp,--,filename,Skia,skia
来源: https://www.cnblogs.com/bigben0123/p/14890350.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有