Flutter Engine
 
Loading...
Searching...
No Matches
texture_layer.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
8
9namespace flutter {
10
12 const DlSize& size,
13 int64_t texture_id,
14 bool freeze,
15 DlImageSampling sampling)
16 : offset_(offset),
17 size_(size),
18 texture_id_(texture_id),
19 freeze_(freeze),
20 sampling_(sampling) {}
21
22void TextureLayer::Diff(DiffContext* context, const Layer* old_layer) {
23 DiffContext::AutoSubtreeRestore subtree(context);
24 if (!context->IsSubtreeDirty()) {
25 FML_DCHECK(old_layer);
26 auto prev = old_layer->as_texture_layer();
27 // TODO(knopp) It would be nice to be able to determine that a texture is
28 // dirty
29 context->MarkSubtreeDirty(context->GetOldLayerPaintRegion(prev));
30 }
31
32 // Make sure DiffContext knows there is a TextureLayer in this subtree.
33 // This prevents ContainerLayer from skipping TextureLayer diffing when
34 // TextureLayer is inside retained layer.
35 // See ContainerLayer::DiffChildren
36 // https://github.com/flutter/flutter/issues/92925
38 context->AddLayerBounds(DlRect::MakeOriginSize(offset_, size_));
39 context->SetLayerPaintRegion(this, context->CurrentSubtreeRegion());
40}
41
47
48void TextureLayer::Paint(PaintContext& context) const {
49 FML_DCHECK(needs_painting(context));
50
51 std::shared_ptr<Texture> texture =
52 context.texture_registry
53 ? context.texture_registry->GetTexture(texture_id_)
54 : nullptr;
55 if (!texture) {
56 TRACE_EVENT_INSTANT0("flutter", "null texture");
57 return;
58 }
59 DlPaint paint;
61 .canvas = context.canvas,
62 .gr_context = context.gr_context,
63 .aiks_context = context.aiks_context,
64 .paint = context.state_stack.fill(paint),
65 };
66 texture->Paint(ctx, paint_bounds(), freeze_, sampling_);
67}
68
69} // namespace flutter
void SetLayerPaintRegion(const Layer *layer, const PaintRegion &region)
void MarkSubtreeDirty(const PaintRegion &previous_paint_region=PaintRegion())
PaintRegion CurrentSubtreeRegion() const
PaintRegion GetOldLayerPaintRegion(const Layer *layer) const
bool IsSubtreeDirty() const
void AddLayerBounds(const DlRect &rect)
void set_paint_bounds(const DlRect &paint_bounds)
Definition layer.h:209
bool needs_painting(PaintContext &context) const
Definition layer.h:218
const DlRect & paint_bounds() const
Definition layer.h:196
virtual const TextureLayer * as_texture_layer() const
Definition layer.h:248
void fill(MutatorsStack *mutators)
static constexpr int kCallerCanApplyOpacity
void Paint(PaintContext &context) const override
TextureLayer(const DlPoint &offset, const DlSize &size, int64_t texture_id, bool freeze, DlImageSampling sampling)
void Preroll(PrerollContext *context) override
void Diff(DiffContext *context, const Layer *old_layer) override
#define FML_DCHECK(condition)
Definition logging.h:122
FlTexture * texture
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
impeller::AiksContext * aiks_context
Definition layer.h:108
std::shared_ptr< TextureRegistry > texture_registry
Definition layer.h:104
DlCanvas * canvas
Definition layer.h:92
GrDirectContext * gr_context
Definition layer.h:99
LayerStateStack & state_stack
Definition layer.h:91
static constexpr TRect MakeOriginSize(const TPoint< Type > &origin, const TSize< Type > &size)
Definition rect.h:144
int64_t texture_id
#define TRACE_EVENT_INSTANT0(category_group, name)