Flutter Engine
The Flutter Engine
SkTestCanvas.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8// SkTestCanvas is a simple way to make a testing canvas which is allowed to use private
9// facilities of SkCanvas without having to add a friend to SkCanvas.h.
10//
11// You create a Key (a simple empty struct) to make a template specialization class. You need to
12// make a key for each of the different Canvases you need. The implementations of the canvases
13// are in SkCanvas.cpp, which allows the use of helper classes.
14
15#ifndef SkTestCanvas_DEFINED
16#define SkTestCanvas_DEFINED
17
21
22#include <memory>
23
24class SkPaint;
25
26namespace sktext { class GlyphRunList; }
27
28// You can only make template specializations of SkTestCanvas.
29template <typename Key> class SkTestCanvas;
30
31// A test canvas to test using slug rendering instead of text blob rendering.
32struct SkSlugTestKey {};
33template <>
35public:
36 SkTestCanvas(SkCanvas* canvas);
37 void onDrawGlyphRunList(
38 const sktext::GlyphRunList& glyphRunList, const SkPaint& paint) override;
39};
40
42template <>
44public:
45 SkTestCanvas(SkCanvas* canvas);
46 void onDrawGlyphRunList(
47 const sktext::GlyphRunList& glyphRunList, const SkPaint& paint) override;
48};
49
51template <>
53public:
54 SkTestCanvas(SkCanvas* canvas);
55 ~SkTestCanvas() override;
56 void onDrawGlyphRunList(
57 const sktext::GlyphRunList& glyphRunList, const SkPaint& paint) override;
58
59private:
60 std::unique_ptr<SkStrikeServer::DiscardableHandleManager> fServerHandleManager;
62 SkStrikeServer fStrikeServer;
63 SkStrikeClient fStrikeClient;
64};
65
66#endif // SkTestCanvas_DEFINED
const Paint & paint
Definition: color_source.cc:38