Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
sk_app::Window_win Class Reference

#include <Window_win.h>

Inheritance diagram for sk_app::Window_win:
sk_app::Window

Public Member Functions

 Window_win ()
 
 ~Window_win () override
 
bool init (HINSTANCE instance)
 
void setTitle (const char *) override
 
void show () override
 
bool attach (BackendType) override
 
void onInval () override
 
void setRequestedDisplayParams (const DisplayParams &, bool allowReattach) override
 
- Public Member Functions inherited from sk_app::Window
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
 

Additional Inherited Members

- Public Types inherited from sk_app::Window
enum  BackendType { kRaster_BackendType , kLast_BackendType = kRaster_BackendType }
 
enum  { kBackendTypeCount = kLast_BackendType + 1 }
 
- Static Public Member Functions inherited from sk_app::Window
static WindowCreateNativeWindow (void *platformData)
 
- Protected Member Functions inherited from sk_app::Window
 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 inherited from sk_app::Window
SkTDArray< Layer * > fLayers
 
DisplayParams fRequestedDisplayParams
 
bool fIsActive = true
 
std::unique_ptr< skwindow::WindowContextfWindowContext
 
bool fIsContentInvalidated = false
 

Detailed Description

Definition at line 17 of file Window_win.h.

Constructor & Destructor Documentation

◆ Window_win()

sk_app::Window_win::Window_win ( )
inline

Definition at line 19 of file Window_win.h.

19: Window() {}

◆ ~Window_win()

sk_app::Window_win::~Window_win ( )
override

Definition at line 53 of file Window_win.cpp.

53 {
54 this->closeWindow();
55}

Member Function Documentation

◆ attach()

bool sk_app::Window_win::attach ( BackendType  attachType)
overridevirtual

Implements sk_app::Window.

Definition at line 350 of file Window_win.cpp.

350 {
351 fBackend = attachType;
352 fInitializedBackend = true;
353
354 switch (attachType) {
355#ifdef SK_GL
356 case kNativeGL_BackendType:
358 break;
359#endif
360#if SK_ANGLE
361 case kANGLE_BackendType:
363 break;
364#endif
365#ifdef SK_DAWN
366#if defined(SK_GRAPHITE)
367 case kGraphiteDawn_BackendType:
369 break;
370#endif
371#endif
374 break;
375#ifdef SK_VULKAN
376 case kVulkan_BackendType:
378 break;
379#if defined(SK_GRAPHITE)
380 case kGraphiteVulkan_BackendType:
382 break;
383#endif
384#endif
385#ifdef SK_DIRECT3D
386 case kDirect3D_BackendType:
388 break;
389#endif
390 }
391 this->onBackendCreated();
392
393 return (SkToBool(fWindowContext));
394}
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
@ kRaster_BackendType
Definition: Window.h:90
DisplayParams fRequestedDisplayParams
Definition: Window.h:176
std::unique_ptr< skwindow::WindowContext > fWindowContext
Definition: Window.h:179
void onBackendCreated()
Definition: Window.cpp:44
std::unique_ptr< WindowContext > MakeVulkanForWin(HWND hwnd, const DisplayParams &params)
std::unique_ptr< WindowContext > MakeD3D12ForWin(HWND hwnd, const DisplayParams &params)
std::unique_ptr< WindowContext > MakeRasterForWin(HWND wnd, const DisplayParams &params)
std::unique_ptr< WindowContext > MakeANGLEForWin(HWND wnd, const DisplayParams &params)
std::unique_ptr< WindowContext > MakeGLForWin(HWND wnd, const DisplayParams &params)
std::unique_ptr< WindowContext > MakeGraphiteDawnD3D12ForWin(HWND hwnd, const DisplayParams &params)
std::unique_ptr< WindowContext > MakeGraphiteVulkanForWin(HWND hwnd, const DisplayParams &params)

◆ init()

bool sk_app::Window_win::init ( HINSTANCE  instance)

Definition at line 60 of file Window_win.cpp.

60 {
61 fHInstance = hInstance ? hInstance : GetModuleHandle(nullptr);
62
63 // The main window class name
64 static const TCHAR gSZWindowClass[] = _T("SkiaApp");
65
66 static WNDCLASSEX wcex;
67 static bool wcexInit = false;
68 if (!wcexInit) {
69 wcex.cbSize = sizeof(WNDCLASSEX);
70
71 wcex.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
72 wcex.lpfnWndProc = WndProc;
73 wcex.cbClsExtra = 0;
74 wcex.cbWndExtra = 0;
75 wcex.hInstance = fHInstance;
76 wcex.hIcon = LoadIcon(fHInstance, (LPCTSTR)IDI_WINLOGO);
77 wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
78 wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
79 wcex.lpszMenuName = nullptr;
80 wcex.lpszClassName = gSZWindowClass;
81 wcex.hIconSm = LoadIcon(fHInstance, (LPCTSTR)IDI_WINLOGO);
82
83 if (!RegisterClassEx(&wcex)) {
84 return false;
85 }
86 wcexInit = true;
87 }
88
89 /*
90 if (fullscreen)
91 {
92 DEVMODE dmScreenSettings;
93 // If full screen set the screen to maximum size of the users desktop and 32bit.
94 memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
95 dmScreenSettings.dmSize = sizeof(dmScreenSettings);
96 dmScreenSettings.dmPelsWidth = (unsigned long)width;
97 dmScreenSettings.dmPelsHeight = (unsigned long)height;
98 dmScreenSettings.dmBitsPerPel = 32;
99 dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
100
101 // Change the display settings to full screen.
102 ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN);
103
104 // Set the position of the window to the top left corner.
105 posX = posY = 0;
106 }
107 */
108 // gIsFullscreen = fullscreen;
109
110 fHWnd = CreateWindow(gSZWindowClass, nullptr, WS_OVERLAPPEDWINDOW,
112 nullptr, nullptr, fHInstance, nullptr);
113 if (!fHWnd)
114 {
115 return false;
116 }
117
118 SetWindowLongPtr(fHWnd, GWLP_USERDATA, (LONG_PTR)this);
119 RegisterTouchWindow(fHWnd, 0);
120
121 return true;
122}
static int gWindowY
Definition: Window_win.cpp:26
static int gWindowX
Definition: Window_win.cpp:25
static int gWindowWidth
Definition: Window_win.cpp:27
static int gWindowHeight
Definition: Window_win.cpp:28
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: Window_win.cpp:208
__w64 long LONG_PTR
Definition: windows_types.h:55
#define LoadIcon

◆ onInval()

void sk_app::Window_win::onInval ( )
overridevirtual

Implements sk_app::Window.

Definition at line 396 of file Window_win.cpp.

396 {
397 InvalidateRect(fHWnd, nullptr, false);
398}

◆ setRequestedDisplayParams()

void sk_app::Window_win::setRequestedDisplayParams ( const DisplayParams params,
bool  allowReattach 
)
overridevirtual

Reimplemented from sk_app::Window.

Definition at line 400 of file Window_win.cpp.

400 {
401 // GL on Windows doesn't let us change MSAA after the window is created
402 if (params.fMSAASampleCount != this->getRequestedDisplayParams().fMSAASampleCount
403 && allowReattach) {
404 // Need to change these early, so attach() creates the window context correctly
406
407 fWindowContext = nullptr;
408 this->closeWindow();
409 this->init(fHInstance);
410 if (fInitializedBackend) {
411 this->attach(fBackend);
412 }
413 }
414
416}
bool init(HINSTANCE instance)
Definition: Window_win.cpp:60
bool attach(BackendType) override
Definition: Window_win.cpp:350
virtual void setRequestedDisplayParams(const DisplayParams &, bool allowReattach=true)
Definition: Window.cpp:137
const EmbeddedViewParams * params

◆ setTitle()

void sk_app::Window_win::setTitle ( const char *  title)
overridevirtual

Implements sk_app::Window.

Definition at line 341 of file Window_win.cpp.

341 {
342 SetWindowTextA(fHWnd, title);
343}

◆ show()

void sk_app::Window_win::show ( )
overridevirtual

Implements sk_app::Window.

Definition at line 345 of file Window_win.cpp.

345 {
346 ShowWindow(fHWnd, SW_SHOW);
347}

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