summaryrefslogtreecommitdiff
path: root/platform/win32
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2015-12-09 17:57:20 +0000
committerTor Andersson <tor.andersson@artifex.com>2016-02-29 16:03:34 +0100
commita6e15a6c904f700543429d94c703a4d1911e1ac2 (patch)
treec071a9eafc5834a04aad312e961b6099d0919b77 /platform/win32
parent7621953bf3f8534ce53ae5611f6cbd2ef4cc869a (diff)
downloadmupdf-a6e15a6c904f700543429d94c703a4d1911e1ac2.tar.xz
jni: First attempt at generic JNI bindings.
The purpose of JNI bindings is to allow MuPDF to be driven from Java. There are several possible use cases here. Firstly, and most simply a java application can ask the core of MuPDF to open a document and render it using the existing devices to produce output on a standard Java bitmap. Secondly, a java application might want to drive the device interface itself, making use of the standard MuPDF devices (such as using the rendering engine to render high quality graphics). Thirdly, a java application might want to implement its own device and then call MuPDF to run the document to that device (perhaps to do custom text or image extraction). The first of these cases requires a simple reflection of the main document and standard device classes in JNI. The second of these cases requires the actual device interface itself to be made available as a java interface, together with the ability to construct and manipulate data types like paths, text and fonts so the Java code can build the required objects to pass to implementers of the device interface. The final case requires a reflection layer whereby calls through the device interface in C can be turned into method calls to a Java interface. All of this is attempted in this commit. Some highlights: For each type in the C (such as fz_colorspace) we have a corresponding java class (such as ColorSpace). Where the 'fz_' types are reference counted (such as an fz_colorspace), the java objects (such as ColorSpace) simply take a reference to a pointer to the underlying fz type. Java accessor methods are then provided to manipulate these types. Where the 'fz_' types are not reference counted (such as an fz_rect), the data is actually contained within the Java object itself (such as Rect, RectI and Transform). We add a VS jni project. This doesn't do anything except make the files accessible for editing in the IDE. As much as possible, the Java layers do nothing (other than some programmer friendly type overloading), construction (unavoidable, as can't be done in JNI) and boiler-plate destruction. All the smartness is done in the C. Due to Java and C's differing approach to constness, we need to be careful that a java device does not destructively alter objects passed to it. For example, consider running a display list through a device implemented in java. If the java device were to change a Font object passed to it, this might affect other objects in the display list that shared the same underlying fz_font. Possibly we can achieve this by having an 'isConst' flag on java objects that are created from device calls and passed to the Java device (see the Text class, for an attempt at this currently). This could alternatively be achieved by cloning every such piece of data (see the path code for an example of this approach), but this is probably slow. Better to clone 'just in time' as the first write operation is done to the object.
Diffstat (limited to 'platform/win32')
-rw-r--r--platform/win32/jni.vcproj441
-rw-r--r--platform/win32/mupdf.sln17
2 files changed, 458 insertions, 0 deletions
diff --git a/platform/win32/jni.vcproj b/platform/win32/jni.vcproj
new file mode 100644
index 00000000..241fabb4
--- /dev/null
+++ b/platform/win32/jni.vcproj
@@ -0,0 +1,441 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="jni"
+ ProjectGUID="{05A1CA5B-9807-4B3A-9954-EFAB8ADE7757}"
+ RootNamespace="jni"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="java"
+ >
+ <File
+ RelativePath="..\android\src\com\artifex\mupdf\fitz\AndroidDrawDevice.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdf\fitz\Annotation.java"
+ >
+ </File>
+ <File
+ RelativePath="..\android\src\com\artifex\mupdf\fitz\AwtDrawDevice.java"
+ >
+ </File>
+ <File
+ RelativePath="..\android\src\com\artifex\mupdf\fitz\CDevice.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdf\fitz\ColorSpace.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdf\fitz\Context.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdf\fitz\Cookie.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdf\fitz\Device.java"
+ >
+ </File>
+ <File
+ RelativePath="..\android\src\com\artifex\mupdf\fitz\DisplayList.java"
+ >
+ </File>
+ <File
+ RelativePath="..\android\src\com\artifex\mupdf\fitz\DisplayListDevice.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdf\fitz\Document.java"
+ >
+ </File>
+ <File
+ RelativePath="..\android\src\com\artifex\mupdf\fitz\Font.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdf\fitz\Image.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdf\fitz\Link.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdf\fitz\Matrix.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdf\fitz\Outline.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdf\fitz\Page.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdf\fitz\Path.java"
+ >
+ </File>
+ <File
+ RelativePath="..\android\src\com\artifex\mupdf\fitz\PathProcessor.java"
+ >
+ </File>
+ <File
+ RelativePath="..\android\src\com\artifex\mupdf\fitz\Point.java"
+ >
+ </File>
+ <File
+ RelativePath="..\android\src\com\artifex\mupdf\fitz\Rect.java"
+ >
+ </File>
+ <File
+ RelativePath="..\android\src\com\artifex\mupdf\fitz\RectI.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdf\fitz\Shade.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdf\fitz\StrokeState.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdf\fitz\Text.java"
+ >
+ </File>
+ <File
+ RelativePath="..\android\src\com\artifex\mupdf\fitz\TryLaterException.java"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="javaapp"
+ >
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\Annotation.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\ArrayDeque.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\AsyncTask.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\ChoosePDFActivity.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\ChoosePDFAdapter.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\ChoosePDFItem.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\Deque.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\FilePicker.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\LinkInfo.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\LinkInfoExternal.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\LinkInfoInternal.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\LinkInfoRemote.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\LinkInfoVisitor.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\MuPDFActivity.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\MuPDFAlert.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\MuPDFAlertInternal.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\MuPDFCore.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\MuPDFPageAdapter.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\MuPDFPageView.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\MuPDFReaderView.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\MuPDFReflowAdapter.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\MuPDFReflowView.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\MuPDFView.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\OutlineActivity.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\OutlineActivityData.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\OutlineAdapter.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\OutlineItem.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\PageView.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\PrintDialogActivity.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\ReaderView.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\SafeAnimatorInflater.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\SearchTask.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\SearchTaskResult.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\TextChar.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\TextWord.java"
+ >
+ </File>
+ <File
+ RelativePath="..\..\platform\android\src\com\artifex\mupdfdemo\WidgetType.java"
+ >
+ </File>
+ </Filter>
+ <File
+ RelativePath="..\..\platform\android\jni\mupdf.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\platform\android\jni\mupdf_native.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/platform/win32/mupdf.sln b/platform/win32/mupdf.sln
index b614da1b..8894689d 100644
--- a/platform/win32/mupdf.sln
+++ b/platform/win32/mupdf.sln
@@ -52,6 +52,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mupdf-gl", "mupdf-gl.vcproj
{5EDCF4FD-0291-4FB9-8D96-D58957CA5E3C} = {5EDCF4FD-0291-4FB9-8D96-D58957CA5E3C}
EndProjectSection
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jni", "jni.vcproj", "{05A1CA5B-9807-4B3A-9954-EFAB8ADE7757}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -286,6 +288,21 @@ Global
{CE3A76A8-A28F-4991-8FB9-C9453D922037}.ReleaseOpenssl|Win32.Build.0 = Release|Win32
{CE3A76A8-A28F-4991-8FB9-C9453D922037}.ReleaseOpenssl|x64.ActiveCfg = Release|x64
{CE3A76A8-A28F-4991-8FB9-C9453D922037}.ReleaseOpenssl|x64.Build.0 = Release|x64
+ {05A1CA5B-9807-4B3A-9954-EFAB8ADE7757}.Debug|Win32.ActiveCfg = Debug|Win32
+ {05A1CA5B-9807-4B3A-9954-EFAB8ADE7757}.Debug|Win32.Build.0 = Debug|Win32
+ {05A1CA5B-9807-4B3A-9954-EFAB8ADE7757}.Debug|x64.ActiveCfg = Debug|Win32
+ {05A1CA5B-9807-4B3A-9954-EFAB8ADE7757}.DebugOpenssl|Win32.ActiveCfg = Debug|Win32
+ {05A1CA5B-9807-4B3A-9954-EFAB8ADE7757}.DebugOpenssl|Win32.Build.0 = Debug|Win32
+ {05A1CA5B-9807-4B3A-9954-EFAB8ADE7757}.DebugOpenssl|x64.ActiveCfg = Debug|Win32
+ {05A1CA5B-9807-4B3A-9954-EFAB8ADE7757}.Memento|Win32.ActiveCfg = Release|Win32
+ {05A1CA5B-9807-4B3A-9954-EFAB8ADE7757}.Memento|Win32.Build.0 = Release|Win32
+ {05A1CA5B-9807-4B3A-9954-EFAB8ADE7757}.Memento|x64.ActiveCfg = Release|Win32
+ {05A1CA5B-9807-4B3A-9954-EFAB8ADE7757}.Release|Win32.ActiveCfg = Release|Win32
+ {05A1CA5B-9807-4B3A-9954-EFAB8ADE7757}.Release|Win32.Build.0 = Release|Win32
+ {05A1CA5B-9807-4B3A-9954-EFAB8ADE7757}.Release|x64.ActiveCfg = Release|Win32
+ {05A1CA5B-9807-4B3A-9954-EFAB8ADE7757}.ReleaseOpenssl|Win32.ActiveCfg = Release|Win32
+ {05A1CA5B-9807-4B3A-9954-EFAB8ADE7757}.ReleaseOpenssl|Win32.Build.0 = Release|Win32
+ {05A1CA5B-9807-4B3A-9954-EFAB8ADE7757}.ReleaseOpenssl|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE