Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: tools/vulkan/Window.cpp

Issue 1945103003: Rename VulkanViewer to Viewer, take 2. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix android path Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/vulkan/Window.h ('k') | tools/vulkan/android/VulkanTestContext_android.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "Window.h"
9
10 #include "SkSurface.h"
11 #include "SkCanvas.h"
12 #include "VulkanTestContext.h"
13
14 static bool default_char_func(SkUnichar c, uint32_t modifiers, void* userData) {
15 return false;
16 }
17
18 static bool default_key_func(Window::Key key, Window::InputState state, uint32_t modifiers,
19 void* userData) {
20 return false;
21 }
22
23 static bool default_mouse_func(int x, int y, Window::InputState state, uint32_t modifiers,
24 void* userData) {
25 return false;
26 }
27
28 static void default_paint_func(SkCanvas*, void* userData) {}
29
30 Window::Window() : fCharFunc(default_char_func)
31 , fKeyFunc(default_key_func)
32 , fMouseFunc(default_mouse_func)
33 , fPaintFunc(default_paint_func) {
34 }
35
36 void Window::detach() {
37 delete fTestContext;
38 fTestContext = nullptr;
39 }
40
41 bool Window::onChar(SkUnichar c, uint32_t modifiers) {
42 return fCharFunc(c, modifiers, fCharUserData);
43 }
44
45 bool Window::onKey(Key key, InputState state, uint32_t modifiers) {
46 return fKeyFunc(key, state, modifiers, fKeyUserData);
47 }
48
49 bool Window::onMouse(int x, int y, InputState state, uint32_t modifiers) {
50 return fMouseFunc(x, y, state, modifiers, fMouseUserData);
51 }
52
53 void Window::onPaint() {
54 SkSurface* backbuffer = fTestContext->getBackbufferSurface();
55 if (backbuffer) {
56 // draw into the canvas of this surface
57 SkCanvas* canvas = backbuffer->getCanvas();
58
59 fPaintFunc(canvas, fPaintUserData);
60
61 canvas->flush();
62
63 fTestContext->swapBuffers();
64 } else {
65 // try recreating testcontext
66 }
67
68 }
69
70 void Window::onResize(uint32_t w, uint32_t h) {
71 fWidth = w;
72 fHeight = h;
73 fTestContext->resize(w, h);
74 }
OLDNEW
« no previous file with comments | « tools/vulkan/Window.h ('k') | tools/vulkan/android/VulkanTestContext_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698