Flutter Engine
The 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
5#include "flutter/flow/layers/texture_layer.h"
6
7#include "flutter/common/graphics/texture.h"
8
9namespace flutter {
10
12 const SkSize& 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
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(SkRect::MakeXYWH(offset_.x(), offset_.y(),
39 size_.width(), size_.height()));
40 context->SetLayerPaintRegion(this, context->CurrentSubtreeRegion());
41}
42
44 set_paint_bounds(SkRect::MakeXYWH(offset_.x(), offset_.y(), size_.width(),
45 size_.height()));
46 context->has_texture_layer = true;
48}
49
50void TextureLayer::Paint(PaintContext& context) const {
51 FML_DCHECK(needs_painting(context));
52
53 std::shared_ptr<Texture> texture =
54 context.texture_registry
55 ? context.texture_registry->GetTexture(texture_id_)
56 : nullptr;
57 if (!texture) {
58 TRACE_EVENT_INSTANT0("flutter", "null texture");
59 return;
60 }
63 .canvas = context.canvas,
64 .gr_context = context.gr_context,
65 .aiks_context = context.aiks_context,
66 .paint = context.state_stack.fill(paint),
67 };
68 texture->Paint(ctx, paint_bounds(), freeze_, sampling_);
69}
70
71} // namespace flutter
static float prev(float f)
void AddLayerBounds(const SkRect &rect)
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 fill(MutatorsStack *mutators)
static constexpr int kCallerCanApplyOpacity
const SkRect & paint_bounds() const
Definition layer.h:209
bool needs_painting(PaintContext &context) const
Definition layer.h:231
virtual const TextureLayer * as_texture_layer() const
Definition layer.h:259
void set_paint_bounds(const SkRect &paint_bounds)
Definition layer.h:222
void Paint(PaintContext &context) const override
TextureLayer(const SkPoint &offset, const SkSize &size, int64_t texture_id, bool freeze, DlImageSampling sampling)
void Preroll(PrerollContext *context) override
void Diff(DiffContext *context, const Layer *old_layer) override
const Paint & paint
#define FML_DCHECK(condition)
Definition logging.h:103
FlTexture * texture
it will be possible to load the file into Perfetto s trace viewer 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
Definition switches.h:259
Point offset
constexpr float y() const
constexpr float x() const
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition SkRect.h:659
SkScalar width() const
Definition SkSize.h:76
SkScalar height() const
Definition SkSize.h:77
impeller::AiksContext * aiks_context
Definition layer.h:121
std::shared_ptr< TextureRegistry > texture_registry
Definition layer.h:113
DlCanvas * canvas
Definition layer.h:101
GrDirectContext * gr_context
Definition layer.h:108
LayerStateStack & state_stack
Definition layer.h:100
int64_t texture_id
#define TRACE_EVENT_INSTANT0(category_group, name)