Flutter Engine
The Flutter Engine
mock_texture.h
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#ifndef FLUTTER_FLOW_TESTING_MOCK_TEXTURE_H_
6#define FLUTTER_FLOW_TESTING_MOCK_TEXTURE_H_
7
8#include <ostream>
9#include <vector>
10
11#include "flutter/common/graphics/texture.h"
12#include "flutter/testing/assertions_skia.h"
13
14namespace flutter {
15namespace testing {
16
17// Mock implementation of the |Texture| interface that does not interact with
18// the GPU. It simply records the list of various calls made so the test can
19// later verify them against expected data.
20class MockTexture : public Texture {
21 public:
22 static sk_sp<DlImage> MakeTestTexture(int w, int h, int checker_size);
23
24 explicit MockTexture(int64_t textureId,
25 const sk_sp<DlImage>& texture = nullptr);
26
27 // Called from raster thread.
28 void Paint(PaintContext& context,
29 const SkRect& bounds,
30 bool freeze,
31 const DlImageSampling sampling) override;
32
33 void OnGrContextCreated() override { gr_context_created_ = true; }
34 void OnGrContextDestroyed() override { gr_context_destroyed_ = true; }
35 void MarkNewFrameAvailable() override {}
36 void OnTextureUnregistered() override { unregistered_ = true; }
37
38 bool gr_context_created() { return gr_context_created_; }
39 bool gr_context_destroyed() { return gr_context_destroyed_; }
40 bool unregistered() { return unregistered_; }
41
42 private:
43 sk_sp<DlImage> texture_;
44 bool gr_context_created_ = false;
45 bool gr_context_destroyed_ = false;
46 bool unregistered_ = false;
47};
48
49} // namespace testing
50} // namespace flutter
51
52#endif // FLUTTER_FLOW_TESTING_MOCK_TEXTURE_H_
void Paint(PaintContext &context, const SkRect &bounds, bool freeze, const DlImageSampling sampling) override
Definition: mock_texture.cc:35
void OnGrContextDestroyed() override
Definition: mock_texture.h:34
void OnGrContextCreated() override
Definition: mock_texture.h:33
MockTexture(int64_t textureId, const sk_sp< DlImage > &texture=nullptr)
Definition: mock_texture.cc:32
void OnTextureUnregistered() override
Definition: mock_texture.h:36
static sk_sp< DlImage > MakeTestTexture(int w, int h, int checker_size)
Definition: mock_texture.cc:12
void MarkNewFrameAvailable() override
Definition: mock_texture.h:35
FlTexture * texture
Optional< SkRect > bounds
Definition: SkRecords.h:189
SkSamplingOptions sampling
Definition: SkRecords.h:337
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder h
Definition: switches.h:59
SkScalar w