skia2/tools/viewer/sk_app/unix/Window_unix.h
csmartdalton 578f064a60 Add msaa flag and UI to viewer
BUG=skia:

Change-Id: I0a24d5e6a4271f84ea5c82eb6d9ede9a1e63f86a
Reviewed-on: https://skia-review.googlesource.com/8787
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2017-02-27 16:46:34 +00:00

94 lines
2.0 KiB
C++

/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef Window_unix_DEFINED
#define Window_unix_DEFINED
#include <X11/Xlib.h>
#include <GL/glx.h>
#include "../Window.h"
#include "SkChecksum.h"
#include "SkTDynamicHash.h"
typedef Window XWindow;
namespace sk_app {
class Window_unix : public Window {
public:
Window_unix() : Window()
, fDisplay(nullptr)
, fWindow(0)
, fGC(nullptr)
, fVisualInfo(nullptr)
, fMSAASampleCount(0) {}
~Window_unix() override { this->closeWindow(); }
bool initWindow(Display* display);
void setTitle(const char*) override;
void show() override;
bool attach(BackendType) override;
void onInval() override;
bool handleEvent(const XEvent& event);
static const XWindow& GetKey(const Window_unix& w) {
return w.fWindow;
}
static uint32_t Hash(const XWindow& w) {
return SkChecksum::Mix(w);
}
static SkTDynamicHash<Window_unix, XWindow> gWindowMap;
void markPendingPaint() { fPendingPaint = true; }
void finishPaint() {
if (fPendingPaint) {
this->onPaint();
fPendingPaint = false;
}
}
void markPendingResize(int width, int height) {
if (width != this->width() || height != this->height()){
fPendingResize = true;
fPendingWidth = width;
fPendingHeight = height;
}
}
void finishResize() {
if (fPendingResize) {
this->onResize(fPendingWidth, fPendingHeight);
fPendingResize = false;
}
}
private:
void closeWindow();
Display* fDisplay;
XWindow fWindow;
GC fGC;
XVisualInfo* fVisualInfo;
int fMSAASampleCount;
Atom fWmDeleteMessage;
bool fPendingPaint;
int fPendingWidth;
int fPendingHeight;
bool fPendingResize;
};
} // namespace sk_app
#endif