c0bd9f9fe5
Current strategy: everything from the top Things to look at first are the manual changes: - added tools/rewrite_includes.py - removed -Idirectives from BUILD.gn - various compile.sh simplifications - tweak tools/embed_resources.py - update gn/find_headers.py to write paths from the top - update gn/gn_to_bp.py SkUserConfig.h layout so that #include "include/config/SkUserConfig.h" always gets the header we want. No-Presubmit: true Change-Id: I73a4b181654e0e38d229bc456c0d0854bae3363e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209706 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Hal Canary <halcanary@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org>
80 lines
1.8 KiB
C++
80 lines
1.8 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 surface_glue_android_DEFINED
|
|
#define surface_glue_android_DEFINED
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <android/native_window_jni.h>
|
|
|
|
#include "include/core/SkString.h"
|
|
|
|
#include "tools/sk_app/Application.h"
|
|
#include "tools/sk_app/Window.h"
|
|
|
|
namespace sk_app {
|
|
|
|
enum MessageType {
|
|
kUndefined,
|
|
kSurfaceCreated,
|
|
kSurfaceChanged,
|
|
kSurfaceDestroyed,
|
|
kDestroyApp,
|
|
kContentInvalidated,
|
|
kKeyPressed,
|
|
kTouched,
|
|
kUIStateChanged,
|
|
};
|
|
|
|
struct Message {
|
|
MessageType fType = kUndefined;
|
|
ANativeWindow* fNativeWindow = nullptr;
|
|
int fKeycode = 0;
|
|
int fTouchOwner, fTouchState;
|
|
float fTouchX, fTouchY;
|
|
|
|
SkString* stateName;
|
|
SkString* stateValue;
|
|
|
|
Message() {}
|
|
Message(MessageType t) : fType(t) {}
|
|
};
|
|
|
|
struct SkiaAndroidApp {
|
|
Application* fApp;
|
|
Window* fWindow;
|
|
jobject fAndroidApp;
|
|
|
|
SkiaAndroidApp(JNIEnv* env, jobject androidApp);
|
|
|
|
void postMessage(const Message& message) const;
|
|
void readMessage(Message* message) const;
|
|
|
|
// These must be called in SkiaAndroidApp's own pthread because the JNIEnv is thread sensitive
|
|
void setTitle(const char* title) const;
|
|
void setUIState(const char* state) const;
|
|
|
|
private:
|
|
pthread_t fThread;
|
|
ANativeWindow* fNativeWindow;
|
|
int fPipes[2]; // 0 is the read message pipe, 1 is the write message pipe
|
|
JavaVM* fJavaVM;
|
|
JNIEnv* fPThreadEnv;
|
|
jmethodID fSetTitleMethodID, fSetStateMethodID;
|
|
|
|
// This must be called in SkiaAndroidApp's own pthread because the JNIEnv is thread sensitive
|
|
~SkiaAndroidApp();
|
|
|
|
static int message_callback(int fd, int events, void* data);
|
|
static void* pthread_main(void*);
|
|
};
|
|
|
|
} // namespace sk_app
|
|
|
|
#endif
|