Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
StrikeForGPU.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
9
11#include "src/core/SkStrike.h"
14
15#include <memory>
16#include <utility>
17
18namespace sktext {
19// -- SkStrikePromise ------------------------------------------------------------------------------
21SkStrikePromise& SkStrikePromise::operator=(sktext::SkStrikePromise&&) = default;
23 : fStrikeOrSpec{std::move(strike)} {}
25 : fStrikeOrSpec{std::make_unique<SkStrikeSpec>(spec)} {}
26
28 if (std::holds_alternative<std::unique_ptr<SkStrikeSpec>>(fStrikeOrSpec)) {
29 // Turn the strike spec into a strike.
30 std::unique_ptr<SkStrikeSpec> spec =
31 std::exchange(std::get<std::unique_ptr<SkStrikeSpec>>(fStrikeOrSpec), nullptr);
32
34 }
35 return std::get<sk_sp<SkStrike>>(fStrikeOrSpec).get();
36}
37
39 fStrikeOrSpec = sk_sp<SkStrike>();
40}
41
43 if (std::holds_alternative<std::unique_ptr<SkStrikeSpec>>(fStrikeOrSpec)) {
44 return std::get<std::unique_ptr<SkStrikeSpec>>(fStrikeOrSpec)->descriptor();
45 }
46
47 return std::get<sk_sp<SkStrike>>(fStrikeOrSpec)->getDescriptor();
48}
49
51 this->descriptor().flatten(buffer);
52}
53
54// -- StrikeMutationMonitor ------------------------------------------------------------------------
56 : fStrike{strike} {
57 fStrike->lock();
58}
59
63} // namespace sktext
void flatten(SkWriteBuffer &buffer) const
sk_sp< SkStrike > findOrCreateStrike(const SkStrikeSpec &strikeSpec) SK_EXCLUDES(fLock)
static SkStrikeCache * GlobalStrikeCache()
void flatten(SkWriteBuffer &buffer) const
const SkDescriptor & descriptor() const
SkStrikePromise & operator=(const SkStrikePromise &)=delete
virtual void unlock()=0
virtual void lock()=0
StrikeMutationMonitor(StrikeForGPU *strike)
static const uint8_t buffer[]
Definition ref_ptr.h:256