Flutter Engine
The Flutter Engine
third_party
skia
tests
StrikeForGPUTest.cpp
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
#include "
include/core/SkData.h
"
9
#include "
include/core/SkFont.h
"
10
#include "
include/core/SkRefCnt.h
"
11
#include "
src/core/SkReadBuffer.h
"
12
#include "
src/core/SkStrike.h
"
13
#include "
src/core/SkStrikeCache.h
"
14
#include "
src/core/SkStrikeSpec.h
"
15
#include "
src/core/SkWriteBuffer.h
"
16
#include "
src/text/StrikeForGPU.h
"
17
#include "
tests/Test.h
"
18
#include "
tools/fonts/FontToolUtils.h
"
19
20
#include <cstdint>
21
#include <memory>
22
#include <optional>
23
#include <utility>
24
25
using namespace
sktext
;
26
27
DEF_TEST
(SkStrikePromise_Basic,
reporter
) {
28
auto
strikeCache = std::make_unique<SkStrikeCache>();
29
auto
[strikeSpec, _] =
SkStrikeSpec::MakeCanonicalized
(
ToolUtils::DefaultFont
());
30
31
class
Pinner :
public
::SkStrikePinner
{
32
public
:
33
// Changing canDelete to return true causes this test to expectedly fail.
34
bool
canDelete
()
override
{
return
false
; }
35
};
36
37
intptr_t toCompareWith;
38
sk_sp<SkData>
data
;
39
40
// Ensure that the ref in srcPromise is dropped.
41
{
42
// Make a strike with a Pinner.
43
auto
strike = strikeCache->createStrike(strikeSpec,
nullptr
, std::make_unique<Pinner>());
44
toCompareWith =
reinterpret_cast<
intptr_t
>
(strike.get());
45
SkStrikePromise
srcPromise(std::move(strike));
46
SkBinaryWriteBuffer
writeBuffer({});
47
srcPromise.
flatten
(writeBuffer);
48
data
= writeBuffer.snapshotAsData();
49
}
50
51
// Remove all unpinned strikes.
52
strikeCache->purgeAll();
53
54
SkReadBuffer
readBuffer{
data
->data(),
data
->size()};
55
std::optional<SkStrikePromise> dstPromise = SkStrikePromise::MakeFromBuffer(
56
readBuffer,
nullptr
, strikeCache.get());
57
58
REPORTER_ASSERT
(
reporter
, dstPromise.has_value());
59
REPORTER_ASSERT
(
reporter
,
60
reinterpret_cast<
intptr_t
>
(dstPromise->strike()) == toCompareWith);
61
}
reporter
reporter
Definition:
FontMgrTest.cpp:39
FontToolUtils.h
SkData.h
SkFont.h
SkReadBuffer.h
SkRefCnt.h
SkStrikeCache.h
SkStrikeSpec.h
SkStrike.h
SkWriteBuffer.h
DEF_TEST
DEF_TEST(SkStrikePromise_Basic, reporter)
Definition:
StrikeForGPUTest.cpp:27
StrikeForGPU.h
Test.h
REPORTER_ASSERT
#define REPORTER_ASSERT(r, cond,...)
Definition:
Test.h:286
SkBinaryWriteBuffer
Definition:
SkWriteBuffer.h:97
SkReadBuffer
Definition:
SkReadBuffer.h:52
SkStrikePinner
Definition:
SkStrike.h:36
SkStrikePinner::canDelete
virtual bool canDelete()=0
SkStrikeSpec::MakeCanonicalized
static std::tuple< SkStrikeSpec, SkScalar > MakeCanonicalized(const SkFont &font, const SkPaint *paint=nullptr)
Definition:
SkStrikeSpec.cpp:71
sk_sp< SkData >
sktext::SkStrikePromise
Definition:
StrikeForGPU.h:39
sktext::SkStrikePromise::flatten
void flatten(SkWriteBuffer &buffer) const
Definition:
StrikeForGPU.cpp:50
ToolUtils::DefaultFont
SkFont DefaultFont()
Definition:
FontToolUtils.cpp:323
sktext
Definition:
SkCanvas.h:45
data
std::shared_ptr< const fml::Mapping > data
Definition:
texture_gles.cc:63
Generated on Sun Jun 23 2024 21:56:48 for Flutter Engine by
1.9.4