Skip to content

Commit

Permalink
JDK-8201539 Fix DirectWrite crash on Monocle.
Browse files Browse the repository at this point in the history
  • Loading branch information
brcolow committed Aug 16, 2018
1 parent 9eff5fd commit bdc94a1
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ build_script:
$env:VSVARS32FILE = "$env:VCINSTALLDIR\vcvars32.bat"
refreshenv
# Must invoke gradle with cmd.exe so stderr output doesn't fail the build:
- cmd: gradlew all test -PCOMPILE_WEBKIT=false -PCONF=DebugNative --stacktrace -x :web:test --info --no-daemon
- cmd: gradlew all test -PCOMPILE_WEBKIT=false -PCONF=DebugNative -PFULL_TEST=true -PUSE_ROBOT=true -PHEADLESS_TEST=true -PUNSTABLE_TEST=true --stacktrace -x :web:test --info --no-daemon

on_finish:
- ps: |
Expand Down
1 change: 1 addition & 0 deletions buildSrc/win.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ WIN.compileSwing = true;
WIN.compileSWT = true;
WIN.compileFXPackager = true;

WIN.includeMonocle = true;
WIN.includeNull3d = true

// Lambda for naming the generated libs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,32 @@

package com.sun.javafx.font.directwrite;

import com.sun.javafx.font.Disposer;

class IWICImagingFactory extends IUnknown {

DWDisposer disposer;

IWICImagingFactory(long ptr) {
super(ptr);
disposer = new IWICImagingFactoryDisposer(this);
Disposer.addRecord(this, disposer);
}

IWICBitmap CreateBitmap(int uiWidth, int uiHeight, int pixelFormat, int options) {
long result = OS.CreateBitmap(ptr, uiWidth, uiHeight, pixelFormat, options);
return result != 0 ? new IWICBitmap(result) : null;
}

private static class IWICImagingFactoryDisposer extends DWDisposer {

IWICImagingFactoryDisposer(IUnknown resource) {
super(resource);
}

public synchronized void dispose() {
super.dispose();
OS.UninitializeCOM(resource.ptr);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ static final native int GetGlyphPlacements(long ptr,

//IWICImagingFactory
static final native long CreateBitmap(long ptr, int uiWidth, int uiHeight, int pixelFormat, int options);
static final native void UninitializeCOM(long ptr);

//IWICBitmap
static final native long Lock(long ptr, int x, int y, int width, int height, int flags);
Expand Down
8 changes: 6 additions & 2 deletions modules/javafx.graphics/src/main/native-font/directwrite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,8 +867,6 @@ JNIEXPORT jlong JNICALL OS_NATIVE(_1WICCreateImagingFactory)
IID_PPV_ARGS(&result)
);

/* Unload COM as no other COM objects will be create directly */
CoUninitialize();
return SUCCEEDED(hr) ? (jlong)result : NULL;
}

Expand Down Expand Up @@ -2359,6 +2357,12 @@ JNIEXPORT jlong JNICALL OS_NATIVE(CreateBitmap)
return SUCCEEDED(hr) ? (jlong)result : NULL;
}

JNIEXPORT void JNICALL OS_NATIVE(UninitializeCOM)
(JNIEnv *env, jclass that, jlong arg0)
{
CoUninitialize();
}

/*IWICBitmap*/
JNIEXPORT jlong JNICALL OS_NATIVE(Lock)
(JNIEnv *env, jclass that, jlong arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5)
Expand Down

0 comments on commit bdc94a1

Please sign in to comment.