OLD | NEW |
(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_key_func(int key, bool down, void* userData) { |
| 15 return false; |
| 16 } |
| 17 |
| 18 static bool default_mouse_func(int x, int y, bool down, void* userData) { |
| 19 return false; |
| 20 } |
| 21 |
| 22 static void default_paint_func(SkCanvas*, void* userData) {} |
| 23 |
| 24 Window::Window() : fKeyFunc(default_key_func) |
| 25 , fMouseFunc(default_mouse_func) |
| 26 , fPaintFunc(default_paint_func) { |
| 27 } |
| 28 |
| 29 void Window::detach() { |
| 30 delete fTestContext; |
| 31 fTestContext = nullptr; |
| 32 } |
| 33 |
| 34 void Window::onPaint() { |
| 35 SkSurface* backbuffer = fTestContext->getBackbufferSurface(); |
| 36 if (backbuffer) { |
| 37 // draw into the canvas of this surface |
| 38 SkCanvas* canvas = backbuffer->getCanvas(); |
| 39 |
| 40 fPaintFunc(canvas, fPaintUserData); |
| 41 |
| 42 canvas->flush(); |
| 43 |
| 44 fTestContext->swapBuffers(); |
| 45 } |
| 46 |
| 47 } |
| 48 |
| 49 |
| 50 void Window::onSize() { |
| 51 fTestContext->resize(); |
| 52 } |
OLD | NEW |