Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
sk_app::Window Class Referenceabstract

#include <Window.h>

Inheritance diagram for sk_app::Window:
sk_app::Window_android sk_app::Window_ios sk_app::Window_mac sk_app::Window_unix sk_app::Window_win

Classes

class  Layer
 

Public Types

enum  BackendType { kRaster_BackendType , kLast_BackendType = kRaster_BackendType }
 
enum  { kBackendTypeCount = kLast_BackendType + 1 }
 

Public Member Functions

virtual ~Window ()
 
virtual void setTitle (const char *)=0
 
virtual void show ()=0
 
virtual void setUIState (const char *)
 
virtual const char * getClipboardText ()
 
virtual void setClipboardText (const char *)
 
void inval ()
 
virtual bool scaleContentToFit () const
 
virtual bool attach (BackendType)=0
 
void detach ()
 
void pushLayer (Layer *layer)
 
void onBackendCreated ()
 
bool onChar (SkUnichar c, skui::ModifierKey modifiers)
 
bool onKey (skui::Key key, skui::InputState state, skui::ModifierKey modifiers)
 
bool onMouse (int x, int y, skui::InputState state, skui::ModifierKey modifiers)
 
bool onMouseWheel (float delta, int x, int y, skui::ModifierKey modifiers)
 
bool onTouch (intptr_t owner, skui::InputState state, float x, float y)
 
bool onFling (skui::InputState state)
 
bool onPinch (skui::InputState state, float scale, float x, float y)
 
void onUIStateChanged (const SkString &stateName, const SkString &stateValue)
 
void onPaint ()
 
void onResize (int width, int height)
 
void onActivate (bool isActive)
 
int width () const
 
int height () const
 
virtual float scaleFactor () const
 
virtual const DisplayParamsgetRequestedDisplayParams ()
 
virtual void setRequestedDisplayParams (const DisplayParams &, bool allowReattach=true)
 
int sampleCount () const
 
int stencilBits () const
 
GrDirectContextdirectContext () const
 
skgpu::graphite::ContextgraphiteContext () const
 
skgpu::graphite::RecordergraphiteRecorder () const
 

Static Public Member Functions

static WindowCreateNativeWindow (void *platformData)
 

Protected Member Functions

 Window ()
 
virtual void onInval ()=0
 
void markInvalProcessed ()
 
void visitLayers (const std::function< void(Layer *)> &visitor)
 
bool signalLayers (const std::function< bool(Layer *)> &visitor)
 

Protected Attributes

SkTDArray< Layer * > fLayers
 
DisplayParams fRequestedDisplayParams
 
bool fIsActive = true
 
std::unique_ptr< skwindow::WindowContextfWindowContext
 
bool fIsContentInvalidated = false
 

Detailed Description

Definition at line 40 of file Window.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
kBackendTypeCount 

Definition at line 94 of file Window.h.

94 {
96 };
@ kBackendTypeCount
Definition: Window.h:95
@ kLast_BackendType
Definition: Window.h:92

◆ BackendType

Enumerator
kRaster_BackendType 
kLast_BackendType 

Definition at line 63 of file Window.h.

63 {
64#ifdef SK_GL
65 kNativeGL_BackendType,
66#endif
67#if SK_ANGLE && (defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_MAC))
68 kANGLE_BackendType,
69#endif
70#ifdef SK_DAWN
71#if defined(SK_GRAPHITE)
72 kGraphiteDawn_BackendType,
73#endif
74#endif
75#ifdef SK_VULKAN
76 kVulkan_BackendType,
77#if defined(SK_GRAPHITE)
78 kGraphiteVulkan_BackendType,
79#endif
80#endif
81#ifdef SK_METAL
82 kMetal_BackendType,
83#if defined(SK_GRAPHITE)
84 kGraphiteMetal_BackendType,
85#endif
86#endif
87#ifdef SK_DIRECT3D
88 kDirect3D_BackendType,
89#endif
91
93 };
@ kRaster_BackendType
Definition: Window.h:90

Constructor & Destructor Documentation

◆ ~Window()

Window::~Window ( )
virtual

Definition at line 23 of file Window.cpp.

23{}

◆ Window()

Window::Window ( )
protected

Definition at line 21 of file Window.cpp.

21{}

Member Function Documentation

◆ attach()

virtual bool sk_app::Window::attach ( BackendType  )
pure virtual

◆ CreateNativeWindow()

Window * Window::CreateNativeWindow ( void *  platformData)
static

Definition at line 14 of file Window_android.cpp.

14 {
15 Window_android* window = new Window_android();
16 if (!window->init((SkiaAndroidApp*)platformData)) {
17 delete window;
18 return nullptr;
19 }
20 return window;
21}
GLFWwindow * window
Definition: main.cc:45

◆ detach()

void Window::detach ( )

Definition at line 25 of file Window.cpp.

25{ fWindowContext = nullptr; }
std::unique_ptr< skwindow::WindowContext > fWindowContext
Definition: Window.h:179

◆ directContext()

GrDirectContext * Window::directContext ( ) const

Definition at line 158 of file Window.cpp.

158 {
159 if (!fWindowContext) {
160 return nullptr;
161 }
162 return fWindowContext->directContext();
163}

◆ getClipboardText()

virtual const char * sk_app::Window::getClipboardText ( )
inlinevirtual

Reimplemented in sk_app::Window_unix.

Definition at line 53 of file Window.h.

53{ return nullptr; }

◆ getRequestedDisplayParams()

virtual const DisplayParams & sk_app::Window::getRequestedDisplayParams ( )
inlinevirtual

Definition at line 155 of file Window.h.

155{ return fRequestedDisplayParams; }
DisplayParams fRequestedDisplayParams
Definition: Window.h:176

◆ graphiteContext()

skgpu::graphite::Context * Window::graphiteContext ( ) const

Definition at line 165 of file Window.cpp.

165 {
166#if defined(SK_GRAPHITE)
167 if (!fWindowContext) {
168 return nullptr;
169 }
170 return fWindowContext->graphiteContext();
171#else
172 return nullptr;
173#endif
174}

◆ graphiteRecorder()

skgpu::graphite::Recorder * Window::graphiteRecorder ( ) const

Definition at line 176 of file Window.cpp.

176 {
177#if defined(SK_GRAPHITE)
178 if (!fWindowContext) {
179 return nullptr;
180 }
181 return fWindowContext->graphiteRecorder();
182#else
183 return nullptr;
184#endif
185}

◆ height()

int Window::height ( ) const

Definition at line 130 of file Window.cpp.

130 {
131 if (!fWindowContext) {
132 return 0;
133 }
134 return fWindowContext->height();
135}

◆ inval()

void Window::inval ( )

Definition at line 195 of file Window.cpp.

195 {
196 if (!fWindowContext) {
197 return;
198 }
201 onInval();
202 }
203}
bool fIsContentInvalidated
Definition: Window.h:186
virtual void onInval()=0

◆ markInvalProcessed()

void Window::markInvalProcessed ( )
protected

Definition at line 205 of file Window.cpp.

205 {
206 fIsContentInvalidated = false;
207}

◆ onActivate()

void Window::onActivate ( bool  isActive)

Definition at line 116 of file Window.cpp.

116 {
117 if (fWindowContext) {
118 fWindowContext->activate(isActive);
119 }
120 fIsActive = isActive;
121}
bool fIsActive
Definition: Window.h:177

◆ onBackendCreated()

void Window::onBackendCreated ( )

Definition at line 44 of file Window.cpp.

44 {
45 this->visitLayers([](Layer* layer) { layer->onBackendCreated(); });
46}
void visitLayers(const std::function< void(Layer *)> &visitor)
Definition: Window.cpp:27

◆ onChar()

bool Window::onChar ( SkUnichar  c,
skui::ModifierKey  modifiers 
)

Definition at line 48 of file Window.cpp.

48 {
49 return this->signalLayers([=](Layer* layer) { return layer->onChar(c, modifiers); });
50}
bool signalLayers(const std::function< bool(Layer *)> &visitor)
Definition: Window.cpp:35

◆ onFling()

bool Window::onFling ( skui::InputState  state)

Definition at line 69 of file Window.cpp.

69 {
70 return this->signalLayers([=](Layer* layer) { return layer->onFling(state); });
71}
AtkStateType state

◆ onInval()

virtual void sk_app::Window::onInval ( )
protectedpure virtual

◆ onKey()

bool Window::onKey ( skui::Key  key,
skui::InputState  state,
skui::ModifierKey  modifiers 
)

Definition at line 52 of file Window.cpp.

52 {
53 return this->signalLayers([=](Layer* layer) { return layer->onKey(key, state, modifiers); });
54}

◆ onMouse()

bool Window::onMouse ( int  x,
int  y,
skui::InputState  state,
skui::ModifierKey  modifiers 
)

Definition at line 56 of file Window.cpp.

56 {
57 return this->signalLayers([=](Layer* layer) { return layer->onMouse(x, y, state, modifiers); });
58}
double y
double x

◆ onMouseWheel()

bool Window::onMouseWheel ( float  delta,
int  x,
int  y,
skui::ModifierKey  modifiers 
)

Definition at line 60 of file Window.cpp.

60 {
61 return this->signalLayers(
62 [=](Layer* layer) { return layer->onMouseWheel(delta, x, y, modifiers); });
63}

◆ onPaint()

void Window::onPaint ( )

Definition at line 81 of file Window.cpp.

81 {
82 if (!fWindowContext) {
83 return;
84 }
85 if (!fIsActive) {
86 return;
87 }
88 sk_sp<SkSurface> backbuffer = fWindowContext->getBackbufferSurface();
89 if (backbuffer == nullptr) {
90 printf("no backbuffer!?\n");
91 // TODO: try recreating testcontext
92 return;
93 }
94
96
97 // draw into the canvas of this surface
98 this->visitLayers([](Layer* layer) { layer->onPrePaint(); });
99 this->visitLayers([=](Layer* layer) { layer->onPaint(backbuffer.get()); });
100
101 if (auto dContext = this->directContext()) {
102 dContext->flushAndSubmit(backbuffer.get(), GrSyncCpu::kNo);
103 }
104
105 fWindowContext->swapBuffers();
106}
void markInvalProcessed()
Definition: Window.cpp:205
GrDirectContext * directContext() const
Definition: Window.cpp:158
T * get() const
Definition: SkRefCnt.h:303
std::string printf(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: SkSLString.cpp:83

◆ onPinch()

bool Window::onPinch ( skui::InputState  state,
float  scale,
float  x,
float  y 
)

Definition at line 73 of file Window.cpp.

73 {
74 return this->signalLayers([=](Layer* layer) { return layer->onPinch(state, scale, x, y); });
75}
const Scalar scale

◆ onResize()

void Window::onResize ( int  width,
int  height 
)

Definition at line 108 of file Window.cpp.

108 {
109 if (!fWindowContext) {
110 return;
111 }
112 fWindowContext->resize(w, h);
113 this->visitLayers([=](Layer* layer) { layer->onResize(w, h); });
114}
SkScalar w
SkScalar h

◆ onTouch()

bool Window::onTouch ( intptr_t  owner,
skui::InputState  state,
float  x,
float  y 
)

Definition at line 65 of file Window.cpp.

65 {
66 return this->signalLayers([=](Layer* layer) { return layer->onTouch(owner, state, x, y); });
67}

◆ onUIStateChanged()

void Window::onUIStateChanged ( const SkString stateName,
const SkString stateValue 
)

Definition at line 77 of file Window.cpp.

77 {
78 this->visitLayers([=](Layer* layer) { layer->onUIStateChanged(stateName, stateValue); });
79}

◆ pushLayer()

void sk_app::Window::pushLayer ( Layer layer)
inline

Definition at line 132 of file Window.h.

132 {
133 layer->onAttach(this);
134 fLayers.push_back(layer);
135 }
SkTDArray< Layer * > fLayers
Definition: Window.h:175

◆ sampleCount()

int Window::sampleCount ( ) const

Definition at line 144 of file Window.cpp.

144 {
145 if (!fWindowContext) {
146 return 0;
147 }
148 return fWindowContext->sampleCount();
149}

◆ scaleContentToFit()

virtual bool sk_app::Window::scaleContentToFit ( ) const
inlinevirtual

Reimplemented in sk_app::Window_android.

Definition at line 61 of file Window.h.

61{ return false; }

◆ scaleFactor()

virtual float sk_app::Window::scaleFactor ( ) const
inlinevirtual

Reimplemented in sk_app::Window_mac.

Definition at line 153 of file Window.h.

153{ return 1.0f; }

◆ setClipboardText()

virtual void sk_app::Window::setClipboardText ( const char *  )
inlinevirtual

Reimplemented in sk_app::Window_unix.

Definition at line 54 of file Window.h.

54{}

◆ setRequestedDisplayParams()

void Window::setRequestedDisplayParams ( const DisplayParams params,
bool  allowReattach = true 
)
virtual

Reimplemented in sk_app::Window_unix, and sk_app::Window_win.

Definition at line 137 of file Window.cpp.

137 {
139 if (fWindowContext) {
140 fWindowContext->setDisplayParams(fRequestedDisplayParams);
141 }
142}
const EmbeddedViewParams * params

◆ setTitle()

virtual void sk_app::Window::setTitle ( const char *  )
pure virtual

◆ setUIState()

virtual void sk_app::Window::setUIState ( const char *  )
inlinevirtual

Reimplemented in sk_app::Window_android.

Definition at line 50 of file Window.h.

50{}

◆ show()

virtual void sk_app::Window::show ( )
pure virtual

◆ signalLayers()

bool Window::signalLayers ( const std::function< bool(Layer *)> &  visitor)
protected

Definition at line 35 of file Window.cpp.

35 {
36 for (int i = fLayers.size() - 1; i >= 0; --i) {
37 if (fLayers[i]->fActive && visitor(fLayers[i])) {
38 return true;
39 }
40 }
41 return false;
42}

◆ stencilBits()

int Window::stencilBits ( ) const

Definition at line 151 of file Window.cpp.

151 {
152 if (!fWindowContext) {
153 return -1;
154 }
155 return fWindowContext->stencilBits();
156}

◆ visitLayers()

void Window::visitLayers ( const std::function< void(Layer *)> &  visitor)
protected

Definition at line 27 of file Window.cpp.

27 {
28 for (int i = 0; i < fLayers.size(); ++i) {
29 if (fLayers[i]->fActive) {
30 visitor(fLayers[i]);
31 }
32 }
33}

◆ width()

int Window::width ( ) const

Definition at line 123 of file Window.cpp.

123 {
124 if (!fWindowContext) {
125 return 0;
126 }
127 return fWindowContext->width();
128}

Member Data Documentation

◆ fIsActive

bool sk_app::Window::fIsActive = true
protected

Definition at line 177 of file Window.h.

◆ fIsContentInvalidated

bool sk_app::Window::fIsContentInvalidated = false
protected

Definition at line 186 of file Window.h.

◆ fLayers

SkTDArray<Layer*> sk_app::Window::fLayers
protected

Definition at line 175 of file Window.h.

◆ fRequestedDisplayParams

DisplayParams sk_app::Window::fRequestedDisplayParams
protected

Definition at line 176 of file Window.h.

◆ fWindowContext

std::unique_ptr<skwindow::WindowContext> sk_app::Window::fWindowContext
protected

Definition at line 179 of file Window.h.


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