2016-04-06 13:08:59 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2018-11-20 22:12:36 +00:00
|
|
|
#include "vk/GrVkVulkan.h"
|
|
|
|
|
2016-04-06 13:08:59 +00:00
|
|
|
#include "Window_win.h"
|
|
|
|
|
|
|
|
#include <tchar.h>
|
|
|
|
#include <windows.h>
|
|
|
|
#include <windowsx.h>
|
|
|
|
|
2016-04-06 19:08:51 +00:00
|
|
|
#include "SkUtils.h"
|
2017-03-08 22:10:24 +00:00
|
|
|
#include "../WindowContext.h"
|
2016-07-26 19:02:50 +00:00
|
|
|
#include "WindowContextFactory_win.h"
|
2016-06-17 16:29:14 +00:00
|
|
|
#ifdef SK_VULKAN
|
2016-05-20 13:01:06 +00:00
|
|
|
#include "../VulkanWindowContext.h"
|
2016-06-17 16:29:14 +00:00
|
|
|
#endif
|
2016-04-06 13:08:59 +00:00
|
|
|
|
2016-05-04 20:49:13 +00:00
|
|
|
namespace sk_app {
|
|
|
|
|
2017-03-08 20:36:30 +00:00
|
|
|
static int gWindowX = CW_USEDEFAULT;
|
|
|
|
static int gWindowY = 0;
|
|
|
|
static int gWindowWidth = CW_USEDEFAULT;
|
|
|
|
static int gWindowHeight = 0;
|
|
|
|
|
2016-04-06 13:08:59 +00:00
|
|
|
Window* Window::CreateNativeWindow(void* platformData) {
|
|
|
|
HINSTANCE hInstance = (HINSTANCE)platformData;
|
|
|
|
|
|
|
|
Window_win* window = new Window_win();
|
|
|
|
if (!window->init(hInstance)) {
|
|
|
|
delete window;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return window;
|
|
|
|
}
|
|
|
|
|
2017-03-08 22:10:24 +00:00
|
|
|
void Window_win::closeWindow() {
|
2017-03-08 20:36:30 +00:00
|
|
|
RECT r;
|
|
|
|
if (GetWindowRect(fHWnd, &r)) {
|
|
|
|
gWindowX = r.left;
|
|
|
|
gWindowY = r.top;
|
|
|
|
gWindowWidth = r.right - r.left;
|
|
|
|
gWindowHeight = r.bottom - r.top;
|
|
|
|
}
|
|
|
|
DestroyWindow(fHWnd);
|
|
|
|
}
|
|
|
|
|
2017-03-08 22:10:24 +00:00
|
|
|
Window_win::~Window_win() {
|
|
|
|
this->closeWindow();
|
|
|
|
}
|
|
|
|
|
2016-04-06 13:08:59 +00:00
|
|
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
|
|
|
|
2016-07-27 21:29:18 +00:00
|
|
|
|
2016-04-06 13:08:59 +00:00
|
|
|
bool Window_win::init(HINSTANCE hInstance) {
|
|
|
|
fHInstance = hInstance ? hInstance : GetModuleHandle(nullptr);
|
|
|
|
|
|
|
|
// The main window class name
|
|
|
|
static const TCHAR gSZWindowClass[] = _T("SkiaApp");
|
|
|
|
|
2016-07-27 21:29:18 +00:00
|
|
|
static WNDCLASSEX wcex;
|
|
|
|
static bool wcexInit = false;
|
|
|
|
if (!wcexInit) {
|
|
|
|
wcex.cbSize = sizeof(WNDCLASSEX);
|
|
|
|
|
|
|
|
wcex.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
|
|
|
wcex.lpfnWndProc = WndProc;
|
|
|
|
wcex.cbClsExtra = 0;
|
|
|
|
wcex.cbWndExtra = 0;
|
|
|
|
wcex.hInstance = fHInstance;
|
|
|
|
wcex.hIcon = LoadIcon(fHInstance, (LPCTSTR)IDI_WINLOGO);
|
2019-01-04 14:49:47 +00:00
|
|
|
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
2016-07-27 21:29:18 +00:00
|
|
|
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
|
|
|
wcex.lpszMenuName = nullptr;
|
|
|
|
wcex.lpszClassName = gSZWindowClass;
|
2019-01-04 14:49:47 +00:00
|
|
|
wcex.hIconSm = LoadIcon(fHInstance, (LPCTSTR)IDI_WINLOGO);
|
2016-07-27 21:29:18 +00:00
|
|
|
|
|
|
|
if (!RegisterClassEx(&wcex)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
wcexInit = true;
|
2016-04-06 13:08:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
if (fullscreen)
|
|
|
|
{
|
|
|
|
DEVMODE dmScreenSettings;
|
|
|
|
// If full screen set the screen to maximum size of the users desktop and 32bit.
|
|
|
|
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
|
|
|
|
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
|
|
|
|
dmScreenSettings.dmPelsWidth = (unsigned long)width;
|
|
|
|
dmScreenSettings.dmPelsHeight = (unsigned long)height;
|
|
|
|
dmScreenSettings.dmBitsPerPel = 32;
|
|
|
|
dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
|
|
|
|
|
|
|
// Change the display settings to full screen.
|
|
|
|
ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN);
|
|
|
|
|
|
|
|
// Set the position of the window to the top left corner.
|
|
|
|
posX = posY = 0;
|
2017-10-09 19:45:33 +00:00
|
|
|
}
|
2016-04-06 13:08:59 +00:00
|
|
|
*/
|
|
|
|
// gIsFullscreen = fullscreen;
|
|
|
|
|
|
|
|
fHWnd = CreateWindow(gSZWindowClass, nullptr, WS_OVERLAPPEDWINDOW,
|
2017-03-08 20:36:30 +00:00
|
|
|
gWindowX, gWindowY, gWindowWidth, gWindowHeight,
|
|
|
|
nullptr, nullptr, fHInstance, nullptr);
|
2016-04-06 13:08:59 +00:00
|
|
|
if (!fHWnd)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetWindowLongPtr(fHWnd, GWLP_USERDATA, (LONG_PTR)this);
|
2017-06-07 14:00:30 +00:00
|
|
|
RegisterTouchWindow(fHWnd, 0);
|
2016-04-06 13:08:59 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-04-06 19:08:51 +00:00
|
|
|
static Window::Key get_key(WPARAM vk) {
|
|
|
|
static const struct {
|
|
|
|
WPARAM fVK;
|
|
|
|
Window::Key fKey;
|
|
|
|
} gPair[] = {
|
2016-05-10 13:50:49 +00:00
|
|
|
{ VK_BACK, Window::Key::kBack },
|
|
|
|
{ VK_CLEAR, Window::Key::kBack },
|
|
|
|
{ VK_RETURN, Window::Key::kOK },
|
|
|
|
{ VK_UP, Window::Key::kUp },
|
|
|
|
{ VK_DOWN, Window::Key::kDown },
|
|
|
|
{ VK_LEFT, Window::Key::kLeft },
|
Integrate the ImGui library with viewer
Code and docs are at: https://github.com/ocornut/imgui
ImGui is an open source immediate mode GUI library that's
lightweight and fairly simply to integrate. Widget functions
return their state, and the library emits vertex and index
data to render everything. It's got a huge set of built-in
widgets and really robust layout control.
For the initial integration, I had to fix up event handling
in the viewer's app framework (to get mouse wheel and more
keys, etc...).
The new viewer 'Debug' window is toggled with the space bar.
For this change, I've added one feature to that window: the
slide picker. It's got a list of all slides, with filtering
support, and the ability to click to switch slides.
I also included the ImGui 'Demo' window (toggled with 'g').
This is nicely laid out, and includes examples of pretty
much everything the library can do. It also serves as good
documentation - find something that looks like what you want,
and then go look at the corresponding code (all of it is in
imgui_demo.cpp).
I have other CLs with other features (like directly editing
the primaries of the working color space), but I wanted to
land this chunk first, then start adding more features.
Other than adding new debugging features, there are few
more outstanding work items:
1) Raster doesn't render the GUI correctly, due to non-
invertible pos -> UV matrices. Florin is working on that.
2) Touch inputs aren't being routed yet, so the GUI isn't
usable on Android yet. Might also be tough to work with,
given the size.
3) ImGui has clipboard integration (that's why it wants
the C, X, and V keys), but we need to wire it up to the
OS' clipboard functions.
4) Draw commands can carry a void* payload to support
drawing images (using whatever mechanism the engine has).
I'd like to set that up (probably using SkImage*), which
makes it really easy to add visualization of off-screen
images in GMs, etc...
BUG=skia:
Change-Id: Iac2a63e37228d33141cb55b7e4d60bf11b7e9ae1
Reviewed-on: https://skia-review.googlesource.com/7702
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2017-02-10 18:36:16 +00:00
|
|
|
{ VK_RIGHT, Window::Key::kRight },
|
|
|
|
{ VK_TAB, Window::Key::kTab },
|
|
|
|
{ VK_PRIOR, Window::Key::kPageUp },
|
|
|
|
{ VK_NEXT, Window::Key::kPageDown },
|
|
|
|
{ VK_HOME, Window::Key::kHome },
|
|
|
|
{ VK_END, Window::Key::kEnd },
|
|
|
|
{ VK_DELETE, Window::Key::kDelete },
|
|
|
|
{ VK_ESCAPE, Window::Key::kEscape },
|
|
|
|
{ VK_SHIFT, Window::Key::kShift },
|
|
|
|
{ VK_CONTROL, Window::Key::kCtrl },
|
|
|
|
{ VK_MENU, Window::Key::kOption },
|
|
|
|
{ 'A', Window::Key::kA },
|
|
|
|
{ 'C', Window::Key::kC },
|
|
|
|
{ 'V', Window::Key::kV },
|
|
|
|
{ 'X', Window::Key::kX },
|
|
|
|
{ 'Y', Window::Key::kY },
|
|
|
|
{ 'Z', Window::Key::kZ },
|
2016-04-06 19:08:51 +00:00
|
|
|
};
|
|
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(gPair); i++) {
|
|
|
|
if (gPair[i].fVK == vk) {
|
|
|
|
return gPair[i].fKey;
|
|
|
|
}
|
|
|
|
}
|
2016-05-10 13:50:49 +00:00
|
|
|
return Window::Key::kNONE;
|
2016-04-06 19:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t get_modifiers(UINT message, WPARAM wParam, LPARAM lParam) {
|
|
|
|
uint32_t modifiers = 0;
|
|
|
|
|
|
|
|
switch (message) {
|
|
|
|
case WM_UNICHAR:
|
|
|
|
case WM_CHAR:
|
|
|
|
if (0 == (lParam & (1 << 30))) {
|
|
|
|
modifiers |= Window::kFirstPress_ModifierKey;
|
|
|
|
}
|
|
|
|
if (lParam & (1 << 29)) {
|
|
|
|
modifiers |= Window::kOption_ModifierKey;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_KEYDOWN:
|
|
|
|
case WM_SYSKEYDOWN:
|
|
|
|
if (0 == (lParam & (1 << 30))) {
|
|
|
|
modifiers |= Window::kFirstPress_ModifierKey;
|
|
|
|
}
|
|
|
|
if (lParam & (1 << 29)) {
|
|
|
|
modifiers |= Window::kOption_ModifierKey;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_KEYUP:
|
|
|
|
case WM_SYSKEYUP:
|
|
|
|
if (lParam & (1 << 29)) {
|
|
|
|
modifiers |= Window::kOption_ModifierKey;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
case WM_LBUTTONUP:
|
|
|
|
case WM_MOUSEMOVE:
|
Integrate the ImGui library with viewer
Code and docs are at: https://github.com/ocornut/imgui
ImGui is an open source immediate mode GUI library that's
lightweight and fairly simply to integrate. Widget functions
return their state, and the library emits vertex and index
data to render everything. It's got a huge set of built-in
widgets and really robust layout control.
For the initial integration, I had to fix up event handling
in the viewer's app framework (to get mouse wheel and more
keys, etc...).
The new viewer 'Debug' window is toggled with the space bar.
For this change, I've added one feature to that window: the
slide picker. It's got a list of all slides, with filtering
support, and the ability to click to switch slides.
I also included the ImGui 'Demo' window (toggled with 'g').
This is nicely laid out, and includes examples of pretty
much everything the library can do. It also serves as good
documentation - find something that looks like what you want,
and then go look at the corresponding code (all of it is in
imgui_demo.cpp).
I have other CLs with other features (like directly editing
the primaries of the working color space), but I wanted to
land this chunk first, then start adding more features.
Other than adding new debugging features, there are few
more outstanding work items:
1) Raster doesn't render the GUI correctly, due to non-
invertible pos -> UV matrices. Florin is working on that.
2) Touch inputs aren't being routed yet, so the GUI isn't
usable on Android yet. Might also be tough to work with,
given the size.
3) ImGui has clipboard integration (that's why it wants
the C, X, and V keys), but we need to wire it up to the
OS' clipboard functions.
4) Draw commands can carry a void* payload to support
drawing images (using whatever mechanism the engine has).
I'd like to set that up (probably using SkImage*), which
makes it really easy to add visualization of off-screen
images in GMs, etc...
BUG=skia:
Change-Id: Iac2a63e37228d33141cb55b7e4d60bf11b7e9ae1
Reviewed-on: https://skia-review.googlesource.com/7702
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2017-02-10 18:36:16 +00:00
|
|
|
case WM_MOUSEWHEEL:
|
2016-04-06 19:08:51 +00:00
|
|
|
if (wParam & MK_CONTROL) {
|
|
|
|
modifiers |= Window::kControl_ModifierKey;
|
|
|
|
}
|
|
|
|
if (wParam & MK_SHIFT) {
|
|
|
|
modifiers |= Window::kShift_ModifierKey;
|
|
|
|
}
|
2017-06-07 14:00:30 +00:00
|
|
|
break;
|
2016-04-06 19:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return modifiers;
|
|
|
|
}
|
2016-04-06 13:08:59 +00:00
|
|
|
|
|
|
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
HDC hdc;
|
|
|
|
|
|
|
|
Window_win* window = (Window_win*) GetWindowLongPtr(hWnd, GWLP_USERDATA);
|
|
|
|
|
2016-04-06 19:08:51 +00:00
|
|
|
bool eventHandled = false;
|
|
|
|
|
|
|
|
switch (message) {
|
|
|
|
case WM_PAINT:
|
|
|
|
hdc = BeginPaint(hWnd, &ps);
|
|
|
|
window->onPaint();
|
|
|
|
EndPaint(hWnd, &ps);
|
|
|
|
eventHandled = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_CLOSE:
|
|
|
|
PostQuitMessage(0);
|
|
|
|
eventHandled = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_ACTIVATE:
|
|
|
|
// disable/enable rendering here, depending on wParam != WA_INACTIVE
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_SIZE:
|
|
|
|
window->onResize(LOWORD(lParam), HIWORD(lParam));
|
|
|
|
eventHandled = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_UNICHAR:
|
2017-10-09 19:45:33 +00:00
|
|
|
eventHandled = window->onChar((SkUnichar)wParam,
|
2016-04-06 19:08:51 +00:00
|
|
|
get_modifiers(message, wParam, lParam));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_CHAR: {
|
|
|
|
const uint16_t* c = reinterpret_cast<uint16_t*>(&wParam);
|
2017-10-09 19:45:33 +00:00
|
|
|
eventHandled = window->onChar(SkUTF16_NextUnichar(&c),
|
2016-04-06 19:08:51 +00:00
|
|
|
get_modifiers(message, wParam, lParam));
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case WM_KEYDOWN:
|
|
|
|
case WM_SYSKEYDOWN:
|
2017-10-09 19:45:33 +00:00
|
|
|
eventHandled = window->onKey(get_key(wParam), Window::kDown_InputState,
|
2016-04-06 19:08:51 +00:00
|
|
|
get_modifiers(message, wParam, lParam));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_KEYUP:
|
|
|
|
case WM_SYSKEYUP:
|
|
|
|
eventHandled = window->onKey(get_key(wParam), Window::kUp_InputState,
|
|
|
|
get_modifiers(message, wParam, lParam));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
case WM_LBUTTONUP: {
|
2016-04-06 13:08:59 +00:00
|
|
|
int xPos = GET_X_LPARAM(lParam);
|
|
|
|
int yPos = GET_Y_LPARAM(lParam);
|
2016-04-06 19:08:51 +00:00
|
|
|
|
2016-04-06 13:08:59 +00:00
|
|
|
//if (!gIsFullscreen)
|
|
|
|
//{
|
|
|
|
// RECT rc = { 0, 0, 640, 480 };
|
|
|
|
// AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE);
|
|
|
|
// xPos -= rc.left;
|
|
|
|
// yPos -= rc.top;
|
|
|
|
//}
|
|
|
|
|
2016-04-06 19:08:51 +00:00
|
|
|
Window::InputState istate = ((wParam & MK_LBUTTON) != 0) ? Window::kDown_InputState
|
|
|
|
: Window::kUp_InputState;
|
|
|
|
|
2017-10-09 19:45:33 +00:00
|
|
|
eventHandled = window->onMouse(xPos, yPos, istate,
|
2016-04-06 19:08:51 +00:00
|
|
|
get_modifiers(message, wParam, lParam));
|
|
|
|
} break;
|
|
|
|
|
Integrate the ImGui library with viewer
Code and docs are at: https://github.com/ocornut/imgui
ImGui is an open source immediate mode GUI library that's
lightweight and fairly simply to integrate. Widget functions
return their state, and the library emits vertex and index
data to render everything. It's got a huge set of built-in
widgets and really robust layout control.
For the initial integration, I had to fix up event handling
in the viewer's app framework (to get mouse wheel and more
keys, etc...).
The new viewer 'Debug' window is toggled with the space bar.
For this change, I've added one feature to that window: the
slide picker. It's got a list of all slides, with filtering
support, and the ability to click to switch slides.
I also included the ImGui 'Demo' window (toggled with 'g').
This is nicely laid out, and includes examples of pretty
much everything the library can do. It also serves as good
documentation - find something that looks like what you want,
and then go look at the corresponding code (all of it is in
imgui_demo.cpp).
I have other CLs with other features (like directly editing
the primaries of the working color space), but I wanted to
land this chunk first, then start adding more features.
Other than adding new debugging features, there are few
more outstanding work items:
1) Raster doesn't render the GUI correctly, due to non-
invertible pos -> UV matrices. Florin is working on that.
2) Touch inputs aren't being routed yet, so the GUI isn't
usable on Android yet. Might also be tough to work with,
given the size.
3) ImGui has clipboard integration (that's why it wants
the C, X, and V keys), but we need to wire it up to the
OS' clipboard functions.
4) Draw commands can carry a void* payload to support
drawing images (using whatever mechanism the engine has).
I'd like to set that up (probably using SkImage*), which
makes it really easy to add visualization of off-screen
images in GMs, etc...
BUG=skia:
Change-Id: Iac2a63e37228d33141cb55b7e4d60bf11b7e9ae1
Reviewed-on: https://skia-review.googlesource.com/7702
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2017-02-10 18:36:16 +00:00
|
|
|
case WM_MOUSEMOVE: {
|
|
|
|
int xPos = GET_X_LPARAM(lParam);
|
|
|
|
int yPos = GET_Y_LPARAM(lParam);
|
|
|
|
|
|
|
|
//if (!gIsFullscreen)
|
|
|
|
//{
|
|
|
|
// RECT rc = { 0, 0, 640, 480 };
|
|
|
|
// AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE);
|
|
|
|
// xPos -= rc.left;
|
|
|
|
// yPos -= rc.top;
|
|
|
|
//}
|
|
|
|
|
|
|
|
eventHandled = window->onMouse(xPos, yPos, Window::kMove_InputState,
|
|
|
|
get_modifiers(message, wParam, lParam));
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case WM_MOUSEWHEEL:
|
|
|
|
eventHandled = window->onMouseWheel(GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f,
|
|
|
|
get_modifiers(message, wParam, lParam));
|
2016-04-06 19:08:51 +00:00
|
|
|
break;
|
2016-04-06 13:08:59 +00:00
|
|
|
|
2017-06-07 14:00:30 +00:00
|
|
|
case WM_TOUCH: {
|
|
|
|
uint16_t numInputs = LOWORD(wParam);
|
|
|
|
std::unique_ptr<TOUCHINPUT[]> inputs(new TOUCHINPUT[numInputs]);
|
|
|
|
if (GetTouchInputInfo((HTOUCHINPUT)lParam, numInputs, inputs.get(),
|
|
|
|
sizeof(TOUCHINPUT))) {
|
2018-02-21 19:06:06 +00:00
|
|
|
POINT topLeft = {0, 0};
|
|
|
|
ClientToScreen(hWnd, &topLeft);
|
2017-06-07 14:00:30 +00:00
|
|
|
for (uint16_t i = 0; i < numInputs; ++i) {
|
|
|
|
TOUCHINPUT ti = inputs[i];
|
|
|
|
Window::InputState state;
|
|
|
|
if (ti.dwFlags & TOUCHEVENTF_DOWN) {
|
|
|
|
state = Window::kDown_InputState;
|
|
|
|
} else if (ti.dwFlags & TOUCHEVENTF_MOVE) {
|
|
|
|
state = Window::kMove_InputState;
|
|
|
|
} else if (ti.dwFlags & TOUCHEVENTF_UP) {
|
|
|
|
state = Window::kUp_InputState;
|
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// TOUCHINPUT coordinates are in 100ths of pixels
|
|
|
|
// Adjust for that, and make them window relative
|
2018-02-21 19:06:06 +00:00
|
|
|
LONG tx = (ti.x / 100) - topLeft.x;
|
|
|
|
LONG ty = (ti.y / 100) - topLeft.y;
|
2017-06-07 14:00:30 +00:00
|
|
|
eventHandled = window->onTouch(ti.dwID, state, tx, ty) || eventHandled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
2016-04-06 19:08:51 +00:00
|
|
|
default:
|
|
|
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
2016-04-06 13:08:59 +00:00
|
|
|
}
|
|
|
|
|
2016-04-06 19:08:51 +00:00
|
|
|
return eventHandled ? 0 : 1;
|
2016-04-06 13:08:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Window_win::setTitle(const char* title) {
|
|
|
|
SetWindowTextA(fHWnd, title);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Window_win::show() {
|
|
|
|
ShowWindow(fHWnd, SW_SHOW);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-24 23:04:47 +00:00
|
|
|
bool Window_win::attach(BackendType attachType) {
|
2017-03-08 22:10:24 +00:00
|
|
|
fBackend = attachType;
|
|
|
|
|
2016-05-20 13:01:06 +00:00
|
|
|
switch (attachType) {
|
|
|
|
case kNativeGL_BackendType:
|
2017-02-24 23:04:47 +00:00
|
|
|
fWindowContext = window_context_factory::NewGLForWin(fHWnd, fRequestedDisplayParams);
|
2016-05-20 13:01:06 +00:00
|
|
|
break;
|
2017-08-17 18:37:06 +00:00
|
|
|
#if SK_ANGLE
|
|
|
|
case kANGLE_BackendType:
|
|
|
|
fWindowContext = window_context_factory::NewANGLEForWin(fHWnd, fRequestedDisplayParams);
|
|
|
|
break;
|
|
|
|
#endif
|
2016-07-27 15:50:12 +00:00
|
|
|
case kRaster_BackendType:
|
2017-02-24 23:04:47 +00:00
|
|
|
fWindowContext = window_context_factory::NewRasterForWin(fHWnd,
|
|
|
|
fRequestedDisplayParams);
|
2016-07-27 15:50:12 +00:00
|
|
|
break;
|
2016-06-17 16:29:14 +00:00
|
|
|
#ifdef SK_VULKAN
|
2016-05-20 13:01:06 +00:00
|
|
|
case kVulkan_BackendType:
|
2017-02-24 23:04:47 +00:00
|
|
|
fWindowContext = window_context_factory::NewVulkanForWin(fHWnd,
|
|
|
|
fRequestedDisplayParams);
|
2016-05-20 13:01:06 +00:00
|
|
|
break;
|
2016-06-17 16:29:14 +00:00
|
|
|
#endif
|
2016-05-20 13:01:06 +00:00
|
|
|
}
|
2017-02-24 20:22:53 +00:00
|
|
|
this->onBackendCreated();
|
2016-04-06 13:08:59 +00:00
|
|
|
|
2016-05-05 19:32:03 +00:00
|
|
|
return (SkToBool(fWindowContext));
|
2016-04-06 13:08:59 +00:00
|
|
|
}
|
2016-04-08 19:51:45 +00:00
|
|
|
|
2016-05-23 17:52:34 +00:00
|
|
|
void Window_win::onInval() {
|
2016-04-08 19:51:45 +00:00
|
|
|
InvalidateRect(fHWnd, nullptr, false);
|
|
|
|
}
|
2016-05-04 20:49:13 +00:00
|
|
|
|
2017-06-23 17:32:29 +00:00
|
|
|
void Window_win::setRequestedDisplayParams(const DisplayParams& params, bool allowReattach) {
|
2017-03-08 22:10:24 +00:00
|
|
|
// GL on Windows doesn't let us change MSAA after the window is created
|
2017-06-23 17:32:29 +00:00
|
|
|
if (params.fMSAASampleCount != this->getRequestedDisplayParams().fMSAASampleCount
|
|
|
|
&& allowReattach) {
|
2017-03-08 22:10:24 +00:00
|
|
|
// Need to change these early, so attach() creates the window context correctly
|
|
|
|
fRequestedDisplayParams = params;
|
|
|
|
|
|
|
|
delete fWindowContext;
|
|
|
|
this->closeWindow();
|
|
|
|
this->init(fHInstance);
|
|
|
|
this->attach(fBackend);
|
|
|
|
}
|
|
|
|
|
2017-06-23 17:32:29 +00:00
|
|
|
INHERITED::setRequestedDisplayParams(params, allowReattach);
|
2017-03-08 22:10:24 +00:00
|
|
|
}
|
|
|
|
|
2016-05-04 20:49:13 +00:00
|
|
|
} // namespace sk_app
|