Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
flutter::testing::MockTexture Class Reference

#include <mock_texture.h>

Inheritance diagram for flutter::testing::MockTexture:
flutter::Texture flutter::Texture flutter::ContextListener flutter::ContextListener

Public Member Functions

 MockTexture (int64_t textureId, const sk_sp< DlImage > &texture=nullptr)
 
void Paint (PaintContext &context, const SkRect &bounds, bool freeze, const DlImageSampling sampling) override
 
void OnGrContextCreated () override
 
void OnGrContextDestroyed () override
 
void MarkNewFrameAvailable () override
 
void OnTextureUnregistered () override
 
bool gr_context_created ()
 
bool gr_context_destroyed ()
 
bool unregistered ()
 
 MockTexture (int64_t textureId, std::shared_ptr< fml::AutoResetWaitableEvent > latch)
 
 ~MockTexture () override=default
 
void Paint (PaintContext &context, const SkRect &bounds, bool freeze, const DlImageSampling) override
 
void OnGrContextCreated () override
 
void OnGrContextDestroyed () override
 
void MarkNewFrameAvailable () override
 
void OnTextureUnregistered () override
 
bool unregistered ()
 
int frames_available ()
 
- Public Member Functions inherited from flutter::Texture
 Texture (int64_t id)
 
virtual ~Texture ()
 
virtual void Paint (PaintContext &context, const SkRect &bounds, bool freeze, const DlImageSampling sampling)=0
 
virtual void MarkNewFrameAvailable ()=0
 
virtual void OnTextureUnregistered ()=0
 
int64_t Id ()
 
- Public Member Functions inherited from flutter::ContextListener
 ContextListener ()
 
 ~ContextListener ()
 
virtual void OnGrContextCreated ()=0
 
virtual void OnGrContextDestroyed ()=0
 

Static Public Member Functions

static sk_sp< DlImageMakeTestTexture (int w, int h, int checker_size)
 

Detailed Description

Definition at line 20 of file mock_texture.h.

Constructor & Destructor Documentation

◆ MockTexture() [1/2]

flutter::testing::MockTexture::MockTexture ( int64_t  textureId,
const sk_sp< DlImage > &  texture = nullptr 
)
explicit

Definition at line 32 of file mock_texture.cc.

33 : Texture(textureId), texture_(texture) {}
Texture(int64_t id)
Definition: texture.cc:13
FlTexture * texture

◆ MockTexture() [2/2]

flutter::testing::MockTexture::MockTexture ( int64_t  textureId,
std::shared_ptr< fml::AutoResetWaitableEvent latch 
)
inline

Definition at line 1966 of file shell_unittests.cc.

1968 : Texture(textureId), latch_(std::move(latch)) {}

◆ ~MockTexture()

flutter::testing::MockTexture::~MockTexture ( )
overridedefault

Member Function Documentation

◆ frames_available()

int flutter::testing::MockTexture::frames_available ( )
inline

Definition at line 1993 of file shell_unittests.cc.

1993{ return frames_available_; }

◆ gr_context_created()

bool flutter::testing::MockTexture::gr_context_created ( )
inline

Definition at line 38 of file mock_texture.h.

38{ return gr_context_created_; }

◆ gr_context_destroyed()

bool flutter::testing::MockTexture::gr_context_destroyed ( )
inline

Definition at line 39 of file mock_texture.h.

39{ return gr_context_destroyed_; }

◆ MakeTestTexture()

sk_sp< DlImage > flutter::testing::MockTexture::MakeTestTexture ( int  w,
int  h,
int  checker_size 
)
static

Definition at line 12 of file mock_texture.cc.

12 {
15 SkCanvas* canvas = surface->getCanvas();
16 SkPaint p0, p1;
21 p1.setAlpha(128);
22 for (int y = 0; y < w; y += checker_size) {
23 for (int x = 0; x < h; x += checker_size) {
24 SkPaint& cellp = ((x + y) & 1) == 0 ? p0 : p1;
25 canvas->drawRect(SkRect::MakeXYWH(x, y, checker_size, checker_size),
26 cellp);
27 }
28 }
29 return DlImage::Make(surface->makeImageSnapshot());
30}
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void setStyle(Style style)
Definition: SkPaint.cpp:105
void setColor(SkColor color)
Definition: SkPaint.cpp:119
@ kFill_Style
set to fill geometry
Definition: SkPaint.h:193
void setAlpha(U8CPU a)
Definition: SkPaint.h:279
static sk_sp< DlImage > Make(const SkImage *image)
Definition: dl_image.cc:11
VkSurfaceKHR surface
Definition: main.cc:49
double y
double x
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
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
static SkImageInfo MakeN32Premul(int width, int height)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ MarkNewFrameAvailable() [1/2]

void flutter::testing::MockTexture::MarkNewFrameAvailable ( )
inlineoverridevirtual

Implements flutter::Texture.

Definition at line 35 of file mock_texture.h.

35{}

◆ MarkNewFrameAvailable() [2/2]

void flutter::testing::MockTexture::MarkNewFrameAvailable ( )
inlineoverridevirtual

Implements flutter::Texture.

Definition at line 1982 of file shell_unittests.cc.

1982 {
1983 frames_available_++;
1984 latch_->Signal();
1985 }

◆ OnGrContextCreated() [1/2]

void flutter::testing::MockTexture::OnGrContextCreated ( )
inlineoverridevirtual

Implements flutter::ContextListener.

Definition at line 33 of file mock_texture.h.

33{ gr_context_created_ = true; }

◆ OnGrContextCreated() [2/2]

void flutter::testing::MockTexture::OnGrContextCreated ( )
inlineoverridevirtual

Implements flutter::ContextListener.

Definition at line 1978 of file shell_unittests.cc.

1978{}

◆ OnGrContextDestroyed() [1/2]

void flutter::testing::MockTexture::OnGrContextDestroyed ( )
inlineoverridevirtual

Implements flutter::ContextListener.

Definition at line 34 of file mock_texture.h.

34{ gr_context_destroyed_ = true; }

◆ OnGrContextDestroyed() [2/2]

void flutter::testing::MockTexture::OnGrContextDestroyed ( )
inlineoverridevirtual

Implements flutter::ContextListener.

Definition at line 1980 of file shell_unittests.cc.

1980{}

◆ OnTextureUnregistered() [1/2]

void flutter::testing::MockTexture::OnTextureUnregistered ( )
inlineoverridevirtual

Implements flutter::Texture.

Definition at line 36 of file mock_texture.h.

36{ unregistered_ = true; }

◆ OnTextureUnregistered() [2/2]

void flutter::testing::MockTexture::OnTextureUnregistered ( )
inlineoverridevirtual

Implements flutter::Texture.

Definition at line 1987 of file shell_unittests.cc.

1987 {
1988 unregistered_ = true;
1989 latch_->Signal();
1990 }

◆ Paint() [1/2]

void flutter::testing::MockTexture::Paint ( PaintContext context,
const SkRect bounds,
bool  freeze,
const DlImageSampling  sampling 
)
overridevirtual

Implements flutter::Texture.

Definition at line 35 of file mock_texture.cc.

38 {
39 // MockTexture objects that are not painted are allowed to have a null
40 // texture, but when we get to this method we must have a non-null texture.
41 FML_DCHECK(texture_ != nullptr);
42 SkRect src = SkRect::Make(texture_->bounds());
43 if (freeze) {
44 FML_DCHECK(src.width() > 2.0f && src.height() > 2.0f);
45 src = src.makeInset(1.0f, 1.0f);
46 }
47 context.canvas->DrawImageRect(texture_, src, bounds, sampling, context.paint);
48}
#define FML_DCHECK(condition)
Definition: logging.h:103
Optional< SkRect > bounds
Definition: SkRecords.h:189
SkSamplingOptions sampling
Definition: SkRecords.h:337
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669

◆ Paint() [2/2]

void flutter::testing::MockTexture::Paint ( PaintContext context,
const SkRect bounds,
bool  freeze,
const  DlImageSampling 
)
inlineoverridevirtual

Implements flutter::Texture.

Definition at line 1973 of file shell_unittests.cc.

1976 {}

◆ unregistered() [1/2]

bool flutter::testing::MockTexture::unregistered ( )
inline

Definition at line 40 of file mock_texture.h.

40{ return unregistered_; }

◆ unregistered() [2/2]

bool flutter::testing::MockTexture::unregistered ( )
inline

Definition at line 1992 of file shell_unittests.cc.

1992{ return unregistered_; }

The documentation for this class was generated from the following files: