forked from chromiumembedded/java-cef
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjni_util_linux.cpp
More file actions
53 lines (43 loc) · 1.26 KB
/
jni_util_linux.cpp
File metadata and controls
53 lines (43 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "jni_util.h"
#include <assert.h>
#include <jawt.h>
#include <jawt_md.h>
unsigned long GetDrawableOfCanvas(jobject canvas, JNIEnv* env) {
JAWT awt;
JAWT_DrawingSurface* ds;
JAWT_DrawingSurfaceInfo* dsi;
JAWT_X11DrawingSurfaceInfo* dsi_x11;
jint lock;
// Get the AWT.
awt.version = JAWT_VERSION_1_4;
JAWT_GetAWT(env, &awt);
// Get the drawing surface.
ds = awt.GetDrawingSurface(env, canvas);
assert(ds != nullptr);
// Lock the drawing surface.
// May fail during shutdown.
lock = ds->Lock(ds);
if (lock & JAWT_LOCK_ERROR) {
return 0;
}
// Get the drawing surface info.
dsi = ds->GetDrawingSurfaceInfo(ds);
if (dsi == nullptr) {
// Unlock the drawing surface
ds->Unlock(ds);
return 0;
}
// Get the platform-specific drawing info.
dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
Drawable result = dsi_x11->drawable;
// Free the drawing surface info
ds->FreeDrawingSurfaceInfo(dsi);
// Unlock the drawing surface
ds->Unlock(ds);
// Free the drawing surface
awt.FreeDrawingSurface(ds);
return result;
}