forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mock_texture.h
59 lines (48 loc) · 1.88 KB
/
mock_texture.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <ostream>
#include <vector>
#include "flutter/common/graphics/texture.h"
#include "flutter/testing/assertions_skia.h"
namespace flutter {
namespace testing {
// Mock implementation of the |Texture| interface that does not interact with
// the GPU. It simply records the list of various calls made so the test can
// later verify them against expected data.
class MockTexture : public Texture {
public:
struct PaintCall {
SkCanvas& canvas;
SkRect bounds;
bool freeze;
GrDirectContext* context;
SkFilterQuality filter_quality;
};
explicit MockTexture(int64_t textureId);
// Called from raster thread.
void Paint(SkCanvas& canvas,
const SkRect& bounds,
bool freeze,
GrDirectContext* context,
SkFilterQuality filter_quality) override;
void OnGrContextCreated() override { gr_context_created_ = true; }
void OnGrContextDestroyed() override { gr_context_destroyed_ = true; }
void MarkNewFrameAvailable() override {}
void OnTextureUnregistered() override { unregistered_ = true; }
const std::vector<PaintCall>& paint_calls() { return paint_calls_; }
bool gr_context_created() { return gr_context_created_; }
bool gr_context_destroyed() { return gr_context_destroyed_; }
bool unregistered() { return unregistered_; }
private:
std::vector<PaintCall> paint_calls_;
bool gr_context_created_ = false;
bool gr_context_destroyed_ = false;
bool unregistered_ = false;
};
extern bool operator==(const MockTexture::PaintCall& a,
const MockTexture::PaintCall& b);
extern std::ostream& operator<<(std::ostream& os,
const MockTexture::PaintCall& data);
} // namespace testing
} // namespace flutter