Merge
This commit is contained in:
commit
025ca5d66a
@ -370,7 +370,7 @@ ifeq ($(PLATFORM), windows)
|
||||
# ISHIELD_TEMP_MIN is the difference of an empty C:\TEMP vs. one after a
|
||||
# bundles build on windows.
|
||||
ISHIELD_TEMP_MIN=250000
|
||||
REQUIRED_DXSDK_VER = 0x0700
|
||||
REQUIRED_DXSDK_VER = 0x0900
|
||||
OS_VENDOR = Microsoft
|
||||
# How much RAM does this machine have:
|
||||
ifeq ($(USING_CYGWIN),true)
|
||||
|
@ -92,7 +92,7 @@ ifeq ($(PLATFORM), windows)
|
||||
_WINDOWS_VERSION := Windows 2000 or Unknown (no systeminfo utility)
|
||||
endif
|
||||
WINDOWS_VERSION := $(strip $(_WINDOWS_VERSION))
|
||||
DXSDK_VER := $(shell $(EGREP) DIRECTDRAW_VERSION $(DXSDK_INCLUDE_PATH)/ddraw.h 2>&1 | \
|
||||
DXSDK_VER := $(shell $(EGREP) DIRECT3D_VERSION $(DXSDK_INCLUDE_PATH)/d3d9.h 2>&1 | \
|
||||
$(EGREP) "\#define" | $(NAWK) '{print $$3}')
|
||||
endif
|
||||
|
||||
@ -1258,7 +1258,7 @@ sane-unzip_version:
|
||||
######################################################
|
||||
sane-dxsdk:
|
||||
ifeq ($(PLATFORM), windows)
|
||||
@if [ ! -r $(DXSDK_INCLUDE_PATH)/ddraw.h ]; then \
|
||||
@if [ ! -r $(DXSDK_INCLUDE_PATH)/d3d9.h ]; then \
|
||||
$(ECHO) "ERROR: You do not have access to a valid DirectX SDK Include dir.\n" \
|
||||
" The value of DXSDK_INCLUDE_PATH must point a valid DX SDK dir.\n" \
|
||||
" Please check your access to \n" \
|
||||
@ -1287,7 +1287,7 @@ ifeq ($(PLATFORM), windows)
|
||||
" This may result in a build failure.\n" \
|
||||
" The DirectX SDK Include dir was obtained from the following location:\n" \
|
||||
" $(DXSDK_INCLUDE_PATH) \n" \
|
||||
" Please change your DirectX SDK to version 7 or 9 (Summer 2004 Update or newer).\n" \
|
||||
" Please change your DirectX SDK to version 9 (Summer 2004 Update or newer).\n" \
|
||||
" Microsoft DirectX 9 SDK can be downloaded from the following location:\n" \
|
||||
" http://msdn.microsoft.com/library/default.asp?url=/downloads/list/directx.asp\n" \
|
||||
" Or http://www.microsoft.com/directx\n" \
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
# Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -112,29 +112,11 @@ FILES_cpp = \
|
||||
GDIHashtable.cpp \
|
||||
Devices.cpp \
|
||||
ObjectList.cpp \
|
||||
DDBlitLoops.cpp \
|
||||
DDRenderer.cpp \
|
||||
GDIBlitLoops.cpp \
|
||||
GDIRenderer.cpp \
|
||||
Win32OffScreenSurfaceData.cpp \
|
||||
Win32SurfaceData.cpp \
|
||||
WinBackBufferSurfaceData.cpp \
|
||||
GDIWindowSurfaceData.cpp \
|
||||
WindowsFlags.cpp \
|
||||
WBufferStrategy.cpp \
|
||||
WPrinterJob.cpp \
|
||||
ddrawUtils.cpp \
|
||||
dxCapabilities.cpp \
|
||||
dxInit.cpp \
|
||||
RegistryKey.cpp \
|
||||
D3DBlitLoops.cpp \
|
||||
D3DContext.cpp \
|
||||
D3DMaskFill.cpp \
|
||||
D3DRenderer.cpp \
|
||||
D3DRuntimeTest.cpp \
|
||||
D3DSurfaceData.cpp \
|
||||
D3DTextRenderer_md.cpp \
|
||||
D3DUtils.cpp \
|
||||
ddrawObject.cpp \
|
||||
awt_AWTEvent.cpp \
|
||||
awt_BitmapUtil.cpp \
|
||||
awt_Brush.cpp \
|
||||
@ -199,6 +181,23 @@ FILES_cpp = \
|
||||
awt_Mlib.cpp \
|
||||
awt_new.cpp \
|
||||
awt_TrayIcon.cpp \
|
||||
ShaderList.cpp \
|
||||
D3DBlitLoops.cpp \
|
||||
D3DBufImgOps.cpp \
|
||||
D3DContext.cpp \
|
||||
D3DGlyphCache.cpp \
|
||||
D3DGraphicsDevice.cpp \
|
||||
D3DMaskBlit.cpp \
|
||||
D3DMaskCache.cpp \
|
||||
D3DMaskFill.cpp \
|
||||
D3DPipelineManager.cpp \
|
||||
D3DPaints.cpp \
|
||||
D3DRenderer.cpp \
|
||||
D3DRenderQueue.cpp \
|
||||
D3DResourceManager.cpp \
|
||||
D3DSurfaceData.cpp \
|
||||
D3DTextRenderer.cpp \
|
||||
D3DVertexCacher.cpp \
|
||||
ShellFolder2.cpp \
|
||||
ThemeReader.cpp \
|
||||
ComCtl32Util.cpp \
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
# Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -49,6 +49,9 @@ FILES_export = \
|
||||
sun/java2d/loops/TransformHelper.java \
|
||||
sun/java2d/loops/GraphicsPrimitiveMgr.java \
|
||||
sun/java2d/loops/GraphicsPrimitive.java \
|
||||
sun/java2d/pipe/hw/AccelSurface.java \
|
||||
sun/java2d/pipe/hw/AccelDeviceEventNotifier.java \
|
||||
sun/java2d/pipe/hw/ContextCapabilities.java \
|
||||
sun/awt/image/ImagingLib.java \
|
||||
sun/java2d/SurfaceData.java \
|
||||
sun/java2d/SunGraphics2D.java \
|
||||
@ -107,6 +110,7 @@ FILES_export = \
|
||||
sun/java2d/pipe/BufferedContext.java \
|
||||
sun/java2d/pipe/BufferedMaskBlit.java \
|
||||
sun/java2d/pipe/BufferedOpCodes.java \
|
||||
sun/java2d/pipe/BufferedMaskBlit.java \
|
||||
sun/java2d/pipe/BufferedPaints.java \
|
||||
sun/java2d/pipe/BufferedRenderPipe.java \
|
||||
sun/java2d/pipe/BufferedTextPipe.java \
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
# Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -125,14 +125,9 @@ FILES_export2 = \
|
||||
sun/awt/image/BufImgSurfaceData.java \
|
||||
sun/awt/image/DataBufferNative.java \
|
||||
sun/awt/shell/Win32ShellFolder2.java \
|
||||
sun/java2d/windows/DDBlitLoops.java \
|
||||
sun/java2d/windows/DDRenderer.java \
|
||||
sun/java2d/windows/DDScaleLoops.java \
|
||||
sun/java2d/windows/GDIBlitLoops.java \
|
||||
sun/java2d/windows/GDIRenderer.java \
|
||||
sun/java2d/windows/Win32OffScreenSurfaceData.java \
|
||||
sun/java2d/windows/Win32SurfaceData.java \
|
||||
sun/java2d/windows/WinBackBufferSurfaceData.java \
|
||||
sun/java2d/windows/GDIWindowSurfaceData.java \
|
||||
sun/java2d/windows/WindowsFlags.java \
|
||||
sun/java2d/loops/Blit.java \
|
||||
sun/java2d/loops/BlitBg.java \
|
||||
@ -219,6 +214,9 @@ FILES_export3 = \
|
||||
sun/awt/windows/WBufferStrategy.java \
|
||||
sun/awt/windows/WTrayIconPeer.java \
|
||||
sun/awt/image/ImagingLib.java \
|
||||
sun/java2d/pipe/hw/AccelSurface.java \
|
||||
sun/java2d/pipe/hw/AccelDeviceEventNotifier.java \
|
||||
sun/java2d/pipe/hw/ContextCapabilities.java \
|
||||
sun/java2d/pipe/BufferedContext.java \
|
||||
sun/java2d/pipe/BufferedMaskBlit.java \
|
||||
sun/java2d/pipe/BufferedOpCodes.java \
|
||||
@ -229,13 +227,6 @@ FILES_export3 = \
|
||||
sun/java2d/pipe/ShapeSpanIterator.java \
|
||||
sun/java2d/pipe/SpanClipRenderer.java \
|
||||
sun/java2d/pipe/RegionIterator.java \
|
||||
sun/java2d/d3d/D3DBlitLoops.java \
|
||||
sun/java2d/d3d/D3DMaskFill.java \
|
||||
sun/java2d/d3d/D3DRenderer.java \
|
||||
sun/java2d/d3d/D3DContext.java \
|
||||
sun/java2d/d3d/D3DSurfaceData.java \
|
||||
sun/java2d/d3d/D3DBackBufferSurfaceData.java \
|
||||
sun/java2d/d3d/D3DTextRenderer.java \
|
||||
sun/java2d/opengl/OGLBlitLoops.java \
|
||||
sun/java2d/opengl/OGLContext.java \
|
||||
sun/java2d/opengl/OGLMaskFill.java \
|
||||
@ -245,4 +236,13 @@ FILES_export3 = \
|
||||
sun/java2d/opengl/OGLSurfaceData.java \
|
||||
sun/java2d/opengl/OGLTextRenderer.java \
|
||||
sun/java2d/opengl/WGLGraphicsConfig.java \
|
||||
sun/java2d/opengl/WGLSurfaceData.java
|
||||
sun/java2d/opengl/WGLSurfaceData.java \
|
||||
sun/java2d/d3d/D3DBlitLoops.java \
|
||||
sun/java2d/d3d/D3DGraphicsDevice.java \
|
||||
sun/java2d/d3d/D3DSurfaceData.java \
|
||||
sun/java2d/d3d/D3DMaskFill.java \
|
||||
sun/java2d/d3d/D3DPaints.java \
|
||||
sun/java2d/d3d/D3DRenderQueue.java \
|
||||
sun/java2d/d3d/D3DRenderer.java \
|
||||
sun/java2d/d3d/D3DTextRenderer.java \
|
||||
sun/java2d/d3d/D3DContext.java
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
# Copyright 1995-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -69,7 +69,6 @@ include FILES_export_windows.gmk
|
||||
#
|
||||
AUTO_JAVA_PRUNE += RemoteOffScreenImage.java
|
||||
|
||||
OTHER_CXXFLAGS += -DD3D_OVERLOADS
|
||||
OTHER_CFLAGS += $(GX_OPTION) -DMLIB_NO_LIBSUNMATH -DUNICODE -D_UNICODE
|
||||
OTHER_CXXFLAGS += $(GX_OPTION) -DUNICODE -D_UNICODE
|
||||
|
||||
@ -448,7 +447,7 @@ OTHER_INCLUDES += -I$(CLASSHDRDIR)/../../java/jvm \
|
||||
-I$(SHARE_SRC)/native/sun/dc/path \
|
||||
-I$(SHARE_SRC)/native/sun/dc/doe \
|
||||
-I$(SHARE_SRC)/native/sun/awt/debug \
|
||||
-I$(PLATFORM_SRC)/native/sun/awt \
|
||||
-I$(PLATFORM_SRC)/native/sun/awt
|
||||
# -I$(WINAWT_COMMON_native)
|
||||
|
||||
# this is only required for compiling )/native/sun/awt/medialib/*.c files
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
# Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -417,12 +417,14 @@ SUNWprivate_1.1 {
|
||||
Java_sun_java2d_x11_X11SurfaceData_XSetForeground;
|
||||
Java_sun_java2d_x11_X11SurfaceData_XSetGraphicsExposures;
|
||||
|
||||
Java_sun_java2d_opengl_OGLContext_getOGLIdString;
|
||||
Java_sun_java2d_opengl_OGLMaskFill_maskFill;
|
||||
Java_sun_java2d_opengl_OGLRenderer_drawPoly;
|
||||
Java_sun_java2d_opengl_OGLRenderQueue_flushBuffer;
|
||||
Java_sun_java2d_opengl_OGLSurfaceData_initTexture;
|
||||
Java_sun_java2d_opengl_OGLSurfaceData_initFBObject;
|
||||
Java_sun_java2d_opengl_OGLSurfaceData_initFlipBackbuffer;
|
||||
Java_sun_java2d_opengl_OGLSurfaceData_getTextureID;
|
||||
Java_sun_java2d_opengl_OGLSurfaceData_getTextureTarget;
|
||||
Java_sun_java2d_opengl_OGLTextRenderer_drawGlyphList;
|
||||
Java_sun_java2d_opengl_GLXGraphicsConfig_getGLXConfigInfo;
|
||||
@ -511,6 +513,7 @@ SUNWprivate_1.1 {
|
||||
AWTCharAscent;
|
||||
AWTCharDescent;
|
||||
AWTDrawGlyphList;
|
||||
AccelGlyphCache_RemoveAllCellInfos;
|
||||
|
||||
local:
|
||||
*;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
# Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -137,7 +137,6 @@ SUNWprivate_1.1 {
|
||||
RegionToYXBandedRectangles;
|
||||
GrPrim_CompGetXorInfo;
|
||||
GrPrim_CompGetAlphaInfo;
|
||||
GrPrim_ColorGetRGB;
|
||||
J2dTraceImpl;
|
||||
J2dTraceInit;
|
||||
img_makePalette;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
# Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -568,6 +568,7 @@ SUNWprivate_1.1 {
|
||||
AWTCharAscent;
|
||||
AWTCharDescent;
|
||||
AWTDrawGlyphList;
|
||||
AccelGlyphCache_RemoveAllCellInfos;
|
||||
|
||||
local:
|
||||
*;
|
||||
|
@ -116,7 +116,7 @@ ifeq ($(PLATFORM),windows)
|
||||
FILES_c_platform = fontpath.c \
|
||||
lcdglyph.c
|
||||
|
||||
FILES_cpp_platform = D3DTextRenderer.cpp
|
||||
FILES_cpp_platform =
|
||||
else
|
||||
FILES_c_platform = X11FontScaler.c \
|
||||
X11TextRenderer.c
|
||||
|
@ -85,8 +85,6 @@ ifeq ($(PLATFORM), windows)
|
||||
OTHER_CFLAGS += -DCC_NOEX
|
||||
OTHER_CXXFLAGS += -DCC_NOEX
|
||||
|
||||
FILES_export += sun/java2d/d3d/D3DTextRenderer.java
|
||||
|
||||
else # PLATFORM unix
|
||||
|
||||
FILES_export += \
|
||||
@ -171,7 +169,6 @@ endif
|
||||
|
||||
ifeq ($(PLATFORM), windows)
|
||||
vpath %.cpp $(PLATFORM_SRC)/native/sun/windows
|
||||
vpath %.cpp $(PLATFORM_SRC)/native/sun/java2d/d3d
|
||||
else # PLATFORM
|
||||
|
||||
#
|
||||
@ -206,7 +203,6 @@ CPPFLAGS += -I$(SHARE_SRC)/native/$(PKGDIR) \
|
||||
-I$(TEMPDIR)/../../sun.awt/awt/CClassHeaders
|
||||
|
||||
ifeq ($(PLATFORM), windows)
|
||||
CPPFLAGS += -I$(PLATFORM_SRC)/native/sun/windows \
|
||||
-I$(PLATFORM_SRC)/native/sun/java2d/d3d
|
||||
CPPFLAGS += -I$(PLATFORM_SRC)/native/sun/windows
|
||||
endif
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 2001-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
# Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -60,6 +60,7 @@ SUNWprivate_1.1 {
|
||||
X11SurfaceData_GetOps;
|
||||
Java_java_awt_Font_initIDs;
|
||||
Java_sun_font_FontManager_getFontConfig;
|
||||
Java_sun_font_FontManager_getFontConfigVersion;
|
||||
Java_sun_font_FontManager_getFontConfigAASettings;
|
||||
Java_sun_font_FontManager_getFontPath;
|
||||
Java_sun_font_FontManager_setNativeFontPath;
|
||||
@ -98,6 +99,7 @@ SUNWprivate_1.1 {
|
||||
AWTCharAscent;
|
||||
AWTCharDescent;
|
||||
AWTDrawGlyphList;
|
||||
AccelGlyphCache_RemoveAllCellInfos;
|
||||
|
||||
|
||||
local:
|
||||
|
@ -1 +1 @@
|
||||
$(OBJDIR)/jawt.obj:: $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_AlphaComposite.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_AWTEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Component.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Dimension.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_FocusEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Event.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_KeyEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_MouseEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_WindowEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Font.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_FontDescriptor.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_PlatformFont.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WComponentPeer.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WFontMetrics.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WObjectPeer.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WToolkit.h ../../../src/share/javavm/export/jawt.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/awt/image/cvutils/img_globals.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jawt_md.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/sun/java2d/j2d_md.h ../../../src/windows/native/sun/java2d/windows/ddrawObject.h ../../../src/windows/native/sun/java2d/windows/dxCapabilities.h ../../../src/windows/native/sun/java2d/windows/RegistryKey.h ../../../src/windows/native/sun/java2d/windows/Win32SurfaceData.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt_Brush.h ../../../src/windows/native/sun/windows/awt_Component.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/awt_DrawingSurface.h ../../../src/windows/native/sun/windows/awt_Font.h ../../../src/windows/native/sun/windows/awt_GDIObject.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awt_MMStub.h ../../../src/windows/native/sun/windows/awtmsg.h ../../../src/windows/native/sun/windows/awt_Multimon.h ../../../src/windows/native/sun/windows/awt_Object.h ../../../src/windows/native/sun/windows/awt_Palette.h ../../../src/windows/native/sun/windows/awt_Pen.h ../../../src/windows/native/sun/windows/awt_Toolkit.h ../../../src/windows/native/sun/windows/awt_Unicode.h ../../../src/windows/native/sun/windows/awt_Win32GraphicsDevice.h ../../../src/windows/native/sun/windows/colordata.h ../../../src/windows/native/sun/windows/Devices.h ../../../src/windows/native/sun/windows/GDIHashtable.h ../../../src/windows/native/sun/windows/Hashtable.h ../../../src/windows/native/sun/windows/ObjectList.h ../../../src/windows/native/sun/windows/stdhdrs.h ../../../src/windows/native/sun/windows/UnicowsLoader.h
|
||||
$(OBJDIR)/jawt.obj:: $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_AWTEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Component.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Dimension.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Event.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Font.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_FocusEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_KeyEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_MouseEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_WindowEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_FontDescriptor.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_PlatformFont.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WComponentPeer.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WFontMetrics.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WObjectPeer.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WToolkit.h ../../../src/share/javavm/export/jawt.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/awt/image/cvutils/img_globals.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jawt_md.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h ../../../src/windows/native/sun/windows/Devices.h ../../../src/windows/native/sun/windows/GDIHashtable.h ../../../src/windows/native/sun/windows/Hashtable.h ../../../src/windows/native/sun/windows/ObjectList.h ../../../src/windows/native/sun/windows/UnicowsLoader.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awt_Brush.h ../../../src/windows/native/sun/windows/awt_Component.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/awt_DrawingSurface.h ../../../src/windows/native/sun/windows/awt_Font.h ../../../src/windows/native/sun/windows/awt_GDIObject.h ../../../src/windows/native/sun/windows/awt_MMStub.h ../../../src/windows/native/sun/windows/awt_Multimon.h ../../../src/windows/native/sun/windows/awt_Object.h ../../../src/windows/native/sun/windows/awt_Palette.h ../../../src/windows/native/sun/windows/awt_Pen.h ../../../src/windows/native/sun/windows/awt_Toolkit.h ../../../src/windows/native/sun/windows/awt_Unicode.h ../../../src/windows/native/sun/windows/awt_Win32GraphicsDevice.h ../../../src/windows/native/sun/windows/awtmsg.h ../../../src/windows/native/sun/windows/colordata.h ../../../src/windows/native/sun/windows/stdhdrs.h
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
# Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -177,6 +177,7 @@ SUNWprivate_1.1 {
|
||||
Java_java_awt_TextField_initIDs;
|
||||
Java_java_awt_TrayIcon_initIDs;
|
||||
Java_sun_font_FontManager_getFontConfig;
|
||||
Java_sun_font_FontManager_getFontConfigVersion;
|
||||
Java_sun_font_FontManager_getFontConfigAASettings;
|
||||
Java_sun_font_FontManager_getFontPath;
|
||||
Java_sun_font_FontManager_setNativeFontPath;
|
||||
@ -241,6 +242,7 @@ SUNWprivate_1.1 {
|
||||
AWTCharAscent;
|
||||
AWTCharDescent;
|
||||
AWTDrawGlyphList;
|
||||
AccelGlyphCache_RemoveAllCellInfos;
|
||||
|
||||
Java_sun_awt_X11_XToolkit_waitForEvents;
|
||||
Java_java_awt_Event_initIDs;
|
||||
|
@ -74,7 +74,11 @@ import sun.awt.dnd.SunDropTargetEvent;
|
||||
import sun.awt.im.CompositionArea;
|
||||
import sun.java2d.SunGraphics2D;
|
||||
import sun.java2d.pipe.Region;
|
||||
import sun.awt.image.VSyncedBSManager;
|
||||
import sun.java2d.pipe.hw.ExtendedBufferCapabilities;
|
||||
import static sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.*;
|
||||
import sun.awt.RequestFocusController;
|
||||
import sun.java2d.SunGraphicsEnvironment;
|
||||
|
||||
/**
|
||||
* A <em>component</em> is an object having a graphical representation
|
||||
@ -3522,6 +3526,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
if (numBuffers == 1) {
|
||||
bufferStrategy = new SingleBufferStrategy(caps);
|
||||
} else {
|
||||
SunGraphicsEnvironment sge = (SunGraphicsEnvironment)
|
||||
GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
if (!caps.isPageFlipping() && sge.isFlipStrategyPreferred(peer)) {
|
||||
caps = new ProxyCapabilities(caps);
|
||||
}
|
||||
// assert numBuffers > 1;
|
||||
if (caps.isPageFlipping()) {
|
||||
bufferStrategy = new FlipSubRegionBufferStrategy(numBuffers, caps);
|
||||
@ -3531,6 +3540,25 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a proxy capabilities class used when a FlipBufferStrategy
|
||||
* is created instead of the requested Blit strategy.
|
||||
*
|
||||
* @see sun.awt.SunGraphicsEnvironment#isFlipStrategyPreferred(ComponentPeer)
|
||||
*/
|
||||
private class ProxyCapabilities extends ExtendedBufferCapabilities {
|
||||
private BufferCapabilities orig;
|
||||
private ProxyCapabilities(BufferCapabilities orig) {
|
||||
super(orig.getFrontBufferCapabilities(),
|
||||
orig.getBackBufferCapabilities(),
|
||||
orig.getFlipContents() ==
|
||||
BufferCapabilities.FlipContents.BACKGROUND ?
|
||||
BufferCapabilities.FlipContents.BACKGROUND :
|
||||
BufferCapabilities.FlipContents.COPIED);
|
||||
this.orig = orig;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the buffer strategy used by this component
|
||||
* @see Window#createBufferStrategy
|
||||
@ -3660,16 +3688,30 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
width = getWidth();
|
||||
height = getHeight();
|
||||
|
||||
if (drawBuffer == null) {
|
||||
peer.createBuffers(numBuffers, caps);
|
||||
} else {
|
||||
if (drawBuffer != null) {
|
||||
// dispose the existing backbuffers
|
||||
drawBuffer = null;
|
||||
drawVBuffer = null;
|
||||
destroyBuffers();
|
||||
// ... then recreate the backbuffers
|
||||
peer.createBuffers(numBuffers, caps);
|
||||
}
|
||||
|
||||
if (caps instanceof ExtendedBufferCapabilities) {
|
||||
ExtendedBufferCapabilities ebc =
|
||||
(ExtendedBufferCapabilities)caps;
|
||||
if (ebc.getVSync() == VSYNC_ON) {
|
||||
// if this buffer strategy is not allowed to be v-synced,
|
||||
// change the caps that we pass to the peer but keep on
|
||||
// trying to create v-synced buffers;
|
||||
// do not throw IAE here in case it is disallowed, see
|
||||
// ExtendedBufferCapabilities for more info
|
||||
if (!VSyncedBSManager.vsyncAllowed(this)) {
|
||||
caps = ebc.derive(VSYNC_DEFAULT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
peer.createBuffers(numBuffers, caps);
|
||||
updateInternalBuffers();
|
||||
}
|
||||
|
||||
@ -3714,7 +3756,23 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
*/
|
||||
protected void flip(BufferCapabilities.FlipContents flipAction) {
|
||||
if (peer != null) {
|
||||
peer.flip(flipAction);
|
||||
Image backBuffer = getBackBuffer();
|
||||
if (backBuffer != null) {
|
||||
peer.flip(0, 0,
|
||||
backBuffer.getWidth(null),
|
||||
backBuffer.getHeight(null), flipAction);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException(
|
||||
"Component must have a valid peer");
|
||||
}
|
||||
}
|
||||
|
||||
void flipSubRegion(int x1, int y1, int x2, int y2,
|
||||
BufferCapabilities.FlipContents flipAction)
|
||||
{
|
||||
if (peer != null) {
|
||||
peer.flip(x1, y1, x2, y2, flipAction);
|
||||
} else {
|
||||
throw new IllegalStateException(
|
||||
"Component must have a valid peer");
|
||||
@ -3725,6 +3783,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
* Destroys the buffers created through this object
|
||||
*/
|
||||
protected void destroyBuffers() {
|
||||
VSyncedBSManager.releaseVsync(this);
|
||||
if (peer != null) {
|
||||
peer.destroyBuffers();
|
||||
} else {
|
||||
@ -3737,7 +3796,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
* @return the buffering capabilities of this strategy
|
||||
*/
|
||||
public BufferCapabilities getCapabilities() {
|
||||
return caps;
|
||||
if (caps instanceof ProxyCapabilities) {
|
||||
return ((ProxyCapabilities)caps).orig;
|
||||
} else {
|
||||
return caps;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3824,6 +3887,14 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
flip(caps.getFlipContents());
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes specified region of the the next available buffer visible
|
||||
* by either blitting or flipping.
|
||||
*/
|
||||
void showSubRegion(int x1, int y1, int x2, int y2) {
|
||||
flipSubRegion(x1, y1, x2, y2, caps.getFlipContents());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 1.6
|
||||
@ -4094,8 +4165,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
|
||||
/**
|
||||
* Private class to perform sub-region flipping.
|
||||
* REMIND: this subclass currently punts on subregions and
|
||||
* flips the entire buffer.
|
||||
*/
|
||||
private class FlipSubRegionBufferStrategy extends FlipBufferStrategy
|
||||
implements SubRegionShowable
|
||||
@ -4109,14 +4178,13 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
}
|
||||
|
||||
public void show(int x1, int y1, int x2, int y2) {
|
||||
show();
|
||||
showSubRegion(x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
// This is invoked by Swing on the toolkit thread.
|
||||
public boolean validateAndShow(int x1, int y1, int x2, int y2) {
|
||||
revalidate(false);
|
||||
if (!contentsRestored() && !contentsLost()) {
|
||||
show();
|
||||
public boolean showIfNotLost(int x1, int y1, int x2, int y2) {
|
||||
if (!contentsLost()) {
|
||||
showSubRegion(x1, y1, x2, y2);
|
||||
return !contentsLost();
|
||||
}
|
||||
return false;
|
||||
@ -4144,9 +4212,8 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
}
|
||||
|
||||
// This method is called by Swing on the toolkit thread.
|
||||
public boolean validateAndShow(int x1, int y1, int x2, int y2) {
|
||||
revalidate(false);
|
||||
if (!contentsRestored() && !contentsLost()) {
|
||||
public boolean showIfNotLost(int x1, int y1, int x2, int y2) {
|
||||
if (!contentsLost()) {
|
||||
showSubRegion(x1, y1, x2, y2);
|
||||
return !contentsLost();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -236,6 +236,10 @@ public abstract class GraphicsDevice {
|
||||
*/
|
||||
public void setFullScreenWindow(Window w) {
|
||||
if (fullScreenWindow != null && windowedModeBounds != null) {
|
||||
// if the window went into fs mode before it was realized it may
|
||||
// have (0,0) dimensions
|
||||
if (windowedModeBounds.width == 0) windowedModeBounds.width = 1;
|
||||
if (windowedModeBounds.height == 0) windowedModeBounds.height = 1;
|
||||
fullScreenWindow.setBounds(windowedModeBounds);
|
||||
}
|
||||
// Set the full screen window
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,12 +25,18 @@
|
||||
|
||||
package java.awt;
|
||||
|
||||
import java.awt.peer.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.awt.image.DirectColorModel;
|
||||
import java.awt.image.Raster;
|
||||
import java.awt.image.WritableRaster;
|
||||
import java.awt.peer.RobotPeer;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import sun.awt.ComponentFactory;
|
||||
import sun.awt.SunToolkit;
|
||||
import sun.awt.image.SunWritableRaster;
|
||||
import sun.security.util.SecurityConstants;
|
||||
|
||||
/**
|
||||
@ -335,6 +341,10 @@ public class Robot {
|
||||
/* blue mask */ 0x000000FF);
|
||||
}
|
||||
|
||||
// need to sync the toolkit prior to grabbing the pixels since in some
|
||||
// cases rendering to the screen may be delayed
|
||||
Toolkit.getDefaultToolkit().sync();
|
||||
|
||||
int pixels[];
|
||||
int[] bandmasks = new int[3];
|
||||
|
||||
@ -346,6 +356,7 @@ public class Robot {
|
||||
bandmasks[2] = screenCapCM.getBlueMask();
|
||||
|
||||
raster = Raster.createPackedRaster(buffer, translatedRect.width, translatedRect.height, translatedRect.width, bandmasks, null);
|
||||
SunWritableRaster.makeTrackable(buffer);
|
||||
|
||||
image = new BufferedImage(screenCapCM, raster, false, null);
|
||||
|
||||
|
@ -530,6 +530,12 @@ public abstract class DataBuffer {
|
||||
public StateTrackableDelegate getTrackable(DataBuffer db) {
|
||||
return db.theTrackable;
|
||||
}
|
||||
|
||||
public void setTrackable(DataBuffer db,
|
||||
StateTrackableDelegate trackable)
|
||||
{
|
||||
db.theTrackable = trackable;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1995-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -88,7 +88,7 @@ public interface ComponentPeer {
|
||||
boolean handlesWheelScrolling();
|
||||
void createBuffers(int numBuffers, BufferCapabilities caps) throws AWTException;
|
||||
Image getBackBuffer();
|
||||
void flip(BufferCapabilities.FlipContents flipAction);
|
||||
void flip(int x1, int y1, int x2, int y2, BufferCapabilities.FlipContents flipAction);
|
||||
void destroyBuffers();
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -263,7 +263,7 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager {
|
||||
(SubRegionShowable)bufferStrategy;
|
||||
boolean paintAllOnExpose = info.getPaintAllOnExpose();
|
||||
info.setPaintAllOnExpose(false);
|
||||
if (bsSubRegion.validateAndShow(x, y, (x + w), (y + h))) {
|
||||
if (bsSubRegion.showIfNotLost(x, y, (x + w), (y + h))) {
|
||||
return !paintAllOnExpose;
|
||||
}
|
||||
// Mark the buffer as needing to be repainted. We don't
|
||||
|
@ -72,6 +72,11 @@ public abstract class FontConfiguration {
|
||||
protected boolean preferLocaleFonts;
|
||||
protected boolean preferPropFonts;
|
||||
|
||||
private File fontConfigFile;
|
||||
private boolean foundOsSpecificFile;
|
||||
private boolean inited;
|
||||
private String javaLib;
|
||||
|
||||
/* A default FontConfiguration must be created before an alternate
|
||||
* one to ensure proper static initialisation takes place.
|
||||
*/
|
||||
@ -80,14 +85,25 @@ public abstract class FontConfiguration {
|
||||
logger = Logger.getLogger("sun.awt.FontConfiguration");
|
||||
}
|
||||
this.environment = environment;
|
||||
this.preferLocaleFonts = false;
|
||||
this.preferPropFonts = false;
|
||||
setOsNameAndVersion(); /* static initialization */
|
||||
setEncoding(); /* static initialization */
|
||||
fontConfig = this; /* static initialization */
|
||||
/* Separating out the file location from the rest of the
|
||||
* initialisation, so the caller has the option of doing
|
||||
* something else if a suitable file isn't found.
|
||||
*/
|
||||
findFontConfigFile();
|
||||
}
|
||||
|
||||
readFontConfigFile();
|
||||
initFontConfig();
|
||||
public synchronized boolean init() {
|
||||
if (!inited) {
|
||||
this.preferLocaleFonts = false;
|
||||
this.preferPropFonts = false;
|
||||
fontConfig = this; /* static initialization */
|
||||
readFontConfigFile(fontConfigFile);
|
||||
initFontConfig();
|
||||
inited = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public FontConfiguration(SunGraphicsEnvironment environment,
|
||||
@ -121,21 +137,51 @@ public abstract class FontConfiguration {
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// methods for loading the FontConfig file //
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
private void readFontConfigFile() {
|
||||
// Find fontconfig file
|
||||
File f = null;
|
||||
|
||||
public boolean foundOsSpecificFile() {
|
||||
return foundOsSpecificFile;
|
||||
}
|
||||
|
||||
/* Smoke test to see if we can trust this configuration by testing if
|
||||
* the first slot of a composite font maps to an installed file.
|
||||
*/
|
||||
public boolean fontFilesArePresent() {
|
||||
init();
|
||||
short fontNameID = compFontNameIDs[0][0][0];
|
||||
short fileNameID = getComponentFileID(fontNameID);
|
||||
final String fileName = mapFileName(getComponentFileName(fileNameID));
|
||||
Boolean exists = (Boolean)java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction() {
|
||||
public Object run() {
|
||||
try {
|
||||
File f = new File(fileName);
|
||||
return Boolean.valueOf(f.exists());
|
||||
}
|
||||
catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
return exists.booleanValue();
|
||||
}
|
||||
|
||||
private void findFontConfigFile() {
|
||||
|
||||
foundOsSpecificFile = true; // default assumption.
|
||||
String javaHome = System.getProperty("java.home");
|
||||
if (javaHome == null) {
|
||||
throw new Error("java.home property not set");
|
||||
}
|
||||
String javaLib = javaHome + File.separator + "lib";
|
||||
javaLib = javaHome + File.separator + "lib";
|
||||
String userConfigFile = System.getProperty("sun.awt.fontconfig");
|
||||
if (userConfigFile != null) {
|
||||
f = new File(userConfigFile);
|
||||
fontConfigFile = new File(userConfigFile);
|
||||
} else {
|
||||
f = findFontConfigFile(javaLib);
|
||||
fontConfigFile = findFontConfigFile(javaLib);
|
||||
}
|
||||
}
|
||||
|
||||
private void readFontConfigFile(File f) {
|
||||
/* This is invoked here as readFontConfigFile is only invoked
|
||||
* once per VM, and always in a privileged context, thus the
|
||||
* directory containing installed fall back fonts is accessed
|
||||
@ -167,7 +213,7 @@ public abstract class FontConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
private void getInstalledFallbackFonts(String javaLib) {
|
||||
protected void getInstalledFallbackFonts(String javaLib) {
|
||||
String fallbackDirName = javaLib + File.separator +
|
||||
"fonts" + File.separator + "fallback";
|
||||
|
||||
@ -229,6 +275,8 @@ public abstract class FontConfiguration {
|
||||
return configFile;
|
||||
}
|
||||
}
|
||||
foundOsSpecificFile = false;
|
||||
|
||||
configFile = findImpl(baseName);
|
||||
if (configFile != null) {
|
||||
return configFile;
|
||||
@ -506,12 +554,12 @@ public abstract class FontConfiguration {
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
protected static final int NUM_FONTS = 5;
|
||||
protected static final int NUM_STYLES = 4;
|
||||
private static final String[] fontNames
|
||||
protected static final String[] fontNames
|
||||
= {"serif", "sansserif", "monospaced", "dialog", "dialoginput"};
|
||||
private static final String[] publicFontNames
|
||||
protected static final String[] publicFontNames
|
||||
= {Font.SERIF, Font.SANS_SERIF, Font.MONOSPACED, Font.DIALOG,
|
||||
Font.DIALOG_INPUT};
|
||||
private static final String[] styleNames
|
||||
protected static final String[] styleNames
|
||||
= {"plain", "bold", "italic", "bolditalic"};
|
||||
|
||||
/**
|
||||
@ -656,7 +704,7 @@ public abstract class FontConfiguration {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String[] installedFallbackFontFiles = null;
|
||||
protected static String[] installedFallbackFontFiles = null;
|
||||
|
||||
/**
|
||||
* Maps a file name given in the font configuration file
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -255,7 +255,9 @@ public class NullComponentPeer implements LightweightPeer,
|
||||
throw new IllegalStateException(
|
||||
"Page-flipping is not allowed on a lightweight component");
|
||||
}
|
||||
public void flip(BufferCapabilities.FlipContents flipAction) {
|
||||
public void flip(int x1, int y1, int x2, int y2,
|
||||
BufferCapabilities.FlipContents flipAction)
|
||||
{
|
||||
throw new IllegalStateException(
|
||||
"Page-flipping is not allowed on a lightweight component");
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -39,10 +39,11 @@ public interface SubRegionShowable {
|
||||
public void show(int x1, int y1, int x2, int y2);
|
||||
|
||||
/**
|
||||
* Validates the buffer and if successful shows the specified region.
|
||||
* Shows the specified region if the buffer is not lost and the dimensions
|
||||
* of the back-buffer match those of the component.
|
||||
*
|
||||
* @return true if successful
|
||||
*/
|
||||
// NOTE: this is invoked by swing on the toolkit thread!
|
||||
public boolean validateAndShow(int x1, int y1, int x2, int y2);
|
||||
public boolean showIfNotLost(int x1, int y1, int x2, int y2);
|
||||
}
|
||||
|
@ -29,19 +29,18 @@ import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.ImageCapabilities;
|
||||
import java.awt.Transparency;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.awt.image.VolatileImage;
|
||||
import java.awt.image.WritableRaster;
|
||||
import sun.java2d.SunGraphics2D;
|
||||
import sun.java2d.SurfaceData;
|
||||
import sun.java2d.SurfaceManagerFactory;
|
||||
import sun.java2d.DestSurfaceProvider;
|
||||
import sun.java2d.Surface;
|
||||
import static sun.java2d.pipe.hw.AccelSurface.*;
|
||||
|
||||
/**
|
||||
* This class is the base implementation of the VolatileImage
|
||||
@ -52,23 +51,28 @@ import sun.java2d.SurfaceManagerFactory;
|
||||
* appropriate VolatileSurfaceManager for the GraphicsConfiguration
|
||||
* under which this SunVolatileImage was created.
|
||||
*/
|
||||
public class SunVolatileImage extends VolatileImage {
|
||||
public class SunVolatileImage extends VolatileImage
|
||||
implements DestSurfaceProvider
|
||||
{
|
||||
|
||||
protected VolatileSurfaceManager volSurfaceManager;
|
||||
protected Component comp;
|
||||
private GraphicsConfiguration graphicsConfig;
|
||||
private Font defaultFont;
|
||||
private int width, height;
|
||||
private int forcedAccelSurfaceType;
|
||||
|
||||
private SunVolatileImage(Component comp,
|
||||
GraphicsConfiguration graphicsConfig,
|
||||
int width, int height, Object context,
|
||||
int transparency, ImageCapabilities caps)
|
||||
protected SunVolatileImage(Component comp,
|
||||
GraphicsConfiguration graphicsConfig,
|
||||
int width, int height, Object context,
|
||||
int transparency, ImageCapabilities caps,
|
||||
int accType)
|
||||
{
|
||||
this.comp = comp;
|
||||
this.graphicsConfig = graphicsConfig;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.forcedAccelSurfaceType = accType;
|
||||
if (!(transparency == Transparency.OPAQUE ||
|
||||
transparency == Transparency.BITMASK ||
|
||||
transparency == Transparency.TRANSLUCENT))
|
||||
@ -92,7 +96,7 @@ public class SunVolatileImage extends VolatileImage {
|
||||
ImageCapabilities caps)
|
||||
{
|
||||
this(comp, graphicsConfig,
|
||||
width, height, context, Transparency.OPAQUE, caps);
|
||||
width, height, context, Transparency.OPAQUE, caps, UNDEFINED);
|
||||
}
|
||||
|
||||
public SunVolatileImage(Component comp, int width, int height) {
|
||||
@ -110,7 +114,8 @@ public class SunVolatileImage extends VolatileImage {
|
||||
int width, int height, int transparency,
|
||||
ImageCapabilities caps)
|
||||
{
|
||||
this(null, graphicsConfig, width, height, null, transparency, caps);
|
||||
this(null, graphicsConfig, width, height, null, transparency,
|
||||
caps, UNDEFINED);
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
@ -144,6 +149,10 @@ public class SunVolatileImage extends VolatileImage {
|
||||
return comp;
|
||||
}
|
||||
|
||||
public int getForcedAccelSurfaceType() {
|
||||
return forcedAccelSurfaceType;
|
||||
}
|
||||
|
||||
protected VolatileSurfaceManager createSurfaceManager(Object context,
|
||||
ImageCapabilities caps)
|
||||
{
|
||||
@ -248,4 +257,14 @@ public class SunVolatileImage extends VolatileImage {
|
||||
public ImageCapabilities getCapabilities() {
|
||||
return volSurfaceManager.getCapabilities(graphicsConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @see sun.java2d.DestSurfaceProvider#getDestSurface
|
||||
*/
|
||||
@Override
|
||||
public Surface getDestSurface() {
|
||||
return volSurfaceManager.getPrimarySurfaceData();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -35,6 +35,7 @@ import java.awt.image.DataBufferInt;
|
||||
import java.awt.image.SampleModel;
|
||||
import java.awt.image.WritableRaster;
|
||||
|
||||
import sun.java2d.StateTrackable.State;
|
||||
import sun.java2d.SurfaceData;
|
||||
import sun.java2d.StateTrackableDelegate;
|
||||
|
||||
@ -54,6 +55,7 @@ public class SunWritableRaster extends WritableRaster {
|
||||
public short[] getData(DataBufferUShort dbus, int bank);
|
||||
public int[] getData(DataBufferInt dbi, int bank);
|
||||
public StateTrackableDelegate getTrackable(DataBuffer db);
|
||||
public void setTrackable(DataBuffer db, StateTrackableDelegate trackable);
|
||||
}
|
||||
|
||||
public static void setDataStealer(DataStealer ds) {
|
||||
@ -79,6 +81,14 @@ public class SunWritableRaster extends WritableRaster {
|
||||
return stealer.getTrackable(db);
|
||||
}
|
||||
|
||||
public static void setTrackable(DataBuffer db, StateTrackableDelegate trackable) {
|
||||
stealer.setTrackable(db, trackable);
|
||||
}
|
||||
|
||||
public static void makeTrackable(DataBuffer db) {
|
||||
stealer.setTrackable(db, StateTrackableDelegate.createInstance(State.STABLE));
|
||||
}
|
||||
|
||||
public static void markDirty(DataBuffer db) {
|
||||
stealer.getTrackable(db).markDirty();
|
||||
}
|
||||
|
121
jdk/src/share/classes/sun/awt/image/VSyncedBSManager.java
Normal file
121
jdk/src/share/classes/sun/awt/image/VSyncedBSManager.java
Normal file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package sun.awt.image;
|
||||
|
||||
import java.awt.image.BufferStrategy;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
/**
|
||||
* Manages v-synced buffer strategies.
|
||||
*/
|
||||
public abstract class VSyncedBSManager {
|
||||
|
||||
private static VSyncedBSManager theInstance;
|
||||
|
||||
private static final boolean vSyncLimit =
|
||||
Boolean.valueOf((String)java.security.AccessController.doPrivileged(
|
||||
new sun.security.action.GetPropertyAction(
|
||||
"sun.java2d.vsynclimit", "true")));
|
||||
|
||||
private static VSyncedBSManager getInstance(boolean create) {
|
||||
if (theInstance == null && create) {
|
||||
theInstance =
|
||||
vSyncLimit ? new SingleVSyncedBSMgr() : new NoLimitVSyncBSMgr();
|
||||
}
|
||||
return theInstance;
|
||||
}
|
||||
|
||||
abstract boolean checkAllowed(BufferStrategy bs);
|
||||
abstract void relinquishVsync(BufferStrategy bs);
|
||||
|
||||
/**
|
||||
* Returns true if the buffer strategy is allowed to be created
|
||||
* v-synced.
|
||||
*
|
||||
* @return true if the bs is allowed to be v-synced, false otherwise
|
||||
*/
|
||||
public static boolean vsyncAllowed(BufferStrategy bs) {
|
||||
VSyncedBSManager bsm = getInstance(true);
|
||||
return bsm.checkAllowed(bs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets the manager know that this buffer strategy is no longer interested
|
||||
* in being v-synced.
|
||||
*/
|
||||
public static synchronized void releaseVsync(BufferStrategy bs) {
|
||||
VSyncedBSManager bsm = getInstance(false);
|
||||
if (bsm != null) {
|
||||
bsm.relinquishVsync(bs);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An instance of the manager which allows any buffer strategy to be
|
||||
* v-synced.
|
||||
*/
|
||||
private static final class NoLimitVSyncBSMgr extends VSyncedBSManager {
|
||||
@Override
|
||||
boolean checkAllowed(BufferStrategy bs) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
void relinquishVsync(BufferStrategy bs) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An instance of the manager which allows only one buffer strategy to
|
||||
* be v-synced at any give moment in the vm.
|
||||
*/
|
||||
private static final class SingleVSyncedBSMgr extends VSyncedBSManager {
|
||||
private WeakReference<BufferStrategy> strategy;
|
||||
|
||||
@Override
|
||||
public synchronized boolean checkAllowed(BufferStrategy bs) {
|
||||
if (strategy != null) {
|
||||
BufferStrategy current = strategy.get();
|
||||
if (current != null) {
|
||||
return (current == bs);
|
||||
}
|
||||
}
|
||||
strategy = new WeakReference<BufferStrategy>(bs);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void relinquishVsync(BufferStrategy bs) {
|
||||
if (strategy != null) {
|
||||
BufferStrategy b = strategy.get();
|
||||
if (b == bs) {
|
||||
strategy.clear();
|
||||
strategy = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -37,6 +37,7 @@ import sun.awt.image.SunVolatileImage;
|
||||
import sun.java2d.SunGraphicsEnvironment;
|
||||
import sun.java2d.SurfaceData;
|
||||
import sun.java2d.loops.CompositeType;
|
||||
import static sun.java2d.pipe.hw.AccelSurface.*;
|
||||
|
||||
/**
|
||||
* This SurfaceManager variant manages an accelerated volatile surface, if it
|
||||
@ -117,7 +118,11 @@ public abstract class VolatileSurfaceManager
|
||||
sdCurrent = sdAccel;
|
||||
}
|
||||
}
|
||||
if (sdCurrent == null) {
|
||||
// only initialize the backup surface for images with unforced
|
||||
// acceleration type
|
||||
if (sdCurrent == null &&
|
||||
vImg.getForcedAccelSurfaceType() == UNDEFINED)
|
||||
{
|
||||
sdCurrent = getBackupSurface();
|
||||
}
|
||||
}
|
||||
@ -270,9 +275,13 @@ public abstract class VolatileSurfaceManager
|
||||
* the background).
|
||||
*/
|
||||
public void initContents() {
|
||||
Graphics g = vImg.createGraphics();
|
||||
g.clearRect(0, 0, vImg.getWidth(), vImg.getHeight());
|
||||
g.dispose();
|
||||
// images with forced acceleration type may have a null sdCurrent
|
||||
// because we do not create a backup surface for them
|
||||
if (sdCurrent != null) {
|
||||
Graphics g = vImg.createGraphics();
|
||||
g.clearRect(0, 0, vImg.getWidth(), vImg.getHeight());
|
||||
g.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -148,6 +148,7 @@ public final class FontManager {
|
||||
static HashSet<String> jreLucidaFontFiles;
|
||||
static String[] jreOtherFontFiles;
|
||||
static boolean noOtherJREFontFiles = false; // initial assumption.
|
||||
static boolean fontConfigFailed = false;
|
||||
|
||||
/* Used to indicate required return type from toArray(..); */
|
||||
private static String[] STR_ARRAY = new String[0];
|
||||
@ -3100,19 +3101,30 @@ public final class FontManager {
|
||||
"monospace:bold:italic",
|
||||
};
|
||||
|
||||
/* This class is just a data structure.
|
||||
/* These next three classes are just data structures.
|
||||
*/
|
||||
private static class FontConfigInfo {
|
||||
static class FontConfigFont {
|
||||
String familyName; // eg Bitstream Vera Sans
|
||||
String styleStr; // eg Bold
|
||||
String fullName; // eg Bitstream Vera Sans Bold
|
||||
String fontFile; // eg /usr/X11/lib/fonts/foo.ttf
|
||||
}
|
||||
|
||||
static class FcCompFont {
|
||||
String fcName; // eg sans
|
||||
String fcFamily; // eg sans
|
||||
String jdkName; // eg sansserif
|
||||
int style; // eg 0=PLAIN
|
||||
String familyName; // eg Bitstream Vera Sans
|
||||
String fontFile; // eg /usr/X11/lib/fonts/foo.ttf
|
||||
FontConfigFont firstFont;
|
||||
FontConfigFont[] allFonts;
|
||||
//boolean preferBitmaps; // if embedded bitmaps preferred over AA
|
||||
CompositeFont compFont; // null if not yet created/known.
|
||||
}
|
||||
|
||||
static class FontConfigInfo {
|
||||
int fcVersion;
|
||||
String[] cacheDirs = new String[4];
|
||||
}
|
||||
|
||||
private static String getFCLocaleStr() {
|
||||
Locale l = SunToolkit.getStartupLocale();
|
||||
@ -3124,6 +3136,12 @@ public final class FontManager {
|
||||
return localeStr;
|
||||
}
|
||||
|
||||
/* This does cause the native libfontconfig to be loaded and unloaded,
|
||||
* but it does not incur the overhead of initialisation of its
|
||||
* data structures, so shouldn't have a measurable impact.
|
||||
*/
|
||||
public static native int getFontConfigVersion();
|
||||
|
||||
private static native int
|
||||
getFontConfigAASettings(String locale, String fcFamily);
|
||||
|
||||
@ -3157,17 +3175,35 @@ public final class FontManager {
|
||||
return getFontConfigAAHint("sans");
|
||||
}
|
||||
|
||||
/* This is populated by native */
|
||||
private static final FontConfigInfo fcInfo = new FontConfigInfo();
|
||||
|
||||
/* This array has the array elements created in Java code and is
|
||||
* passed down to native to be filled in.
|
||||
*/
|
||||
private static FontConfigInfo[] fontConfigFonts;
|
||||
private static FcCompFont[] fontConfigFonts;
|
||||
|
||||
/* Return an array of FontConfigInfo structs describing the primary
|
||||
/* Return an array of FcCompFont structs describing the primary
|
||||
* font located for each of fontconfig/GTK/Pango's logical font names.
|
||||
*/
|
||||
private static native void getFontConfig(String locale,
|
||||
FontConfigInfo[] fonts);
|
||||
FontConfigInfo fcInfo,
|
||||
FcCompFont[] fonts,
|
||||
boolean includeFallbacks);
|
||||
|
||||
static void populateFontConfig(FcCompFont[] fcInfo) {
|
||||
fontConfigFonts = fcInfo;
|
||||
}
|
||||
|
||||
static FcCompFont[] loadFontConfig() {
|
||||
initFontConfigFonts(true);
|
||||
return fontConfigFonts;
|
||||
}
|
||||
|
||||
static FontConfigInfo getFontConfigInfo() {
|
||||
initFontConfigFonts(true);
|
||||
return fcInfo;
|
||||
}
|
||||
|
||||
/* This can be made public if it's needed to force a re-read
|
||||
* rather than using the cached values. The re-read would be needed
|
||||
@ -3175,54 +3211,80 @@ public final class FontManager {
|
||||
* In that event this method would need to return directly the array
|
||||
* to be used by the caller in case it subsequently changed.
|
||||
*/
|
||||
private static void initFontConfigFonts() {
|
||||
private static synchronized void
|
||||
initFontConfigFonts(boolean includeFallbacks) {
|
||||
|
||||
if (fontConfigFonts != null) {
|
||||
return;
|
||||
if (!includeFallbacks || (fontConfigFonts[0].allFonts != null)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (isWindows) {
|
||||
if (isWindows || fontConfigFailed) {
|
||||
return;
|
||||
}
|
||||
|
||||
long t0 = 0;
|
||||
if (logging) {
|
||||
t0 = System.currentTimeMillis();
|
||||
t0 = System.nanoTime();
|
||||
}
|
||||
|
||||
FontConfigInfo[] fontArr = new FontConfigInfo[fontConfigNames.length];
|
||||
FcCompFont[] fontArr = new FcCompFont[fontConfigNames.length];
|
||||
for (int i = 0; i< fontArr.length; i++) {
|
||||
fontArr[i] = new FontConfigInfo();
|
||||
fontArr[i] = new FcCompFont();
|
||||
fontArr[i].fcName = fontConfigNames[i];
|
||||
int colonPos = fontArr[i].fcName.indexOf(':');
|
||||
fontArr[i].fcFamily = fontArr[i].fcName.substring(0, colonPos);
|
||||
fontArr[i].jdkName = mapFcName(fontArr[i].fcFamily);
|
||||
fontArr[i].style = i % 4; // depends on array order.
|
||||
}
|
||||
getFontConfig(getFCLocaleStr(), fontArr);
|
||||
getFontConfig(getFCLocaleStr(), fcInfo, fontArr, includeFallbacks);
|
||||
/* If don't find anything (eg no libfontconfig), then just return */
|
||||
for (int i = 0; i< fontArr.length; i++) {
|
||||
FcCompFont fci = fontArr[i];
|
||||
if (fci.firstFont == null) {
|
||||
if (logging) {
|
||||
logger.info("Fontconfig returned no fonts.");
|
||||
}
|
||||
fontConfigFailed = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
fontConfigFonts = fontArr;
|
||||
|
||||
if (logging) {
|
||||
long t1 = System.currentTimeMillis();
|
||||
logger.info("Time spent accessing fontconfig="+(t1-t0)+"ms.");
|
||||
long t1 = System.nanoTime();
|
||||
logger.info("Time spent accessing fontconfig="+
|
||||
(t1-t0)/1000000+"ms.");
|
||||
|
||||
for (int i = 0; i< fontConfigFonts.length; i++) {
|
||||
FontConfigInfo fci = fontConfigFonts[i];
|
||||
FcCompFont fci = fontConfigFonts[i];
|
||||
logger.info("FC font " + fci.fcName+" maps to family " +
|
||||
fci.familyName + " in file " + fci.fontFile);
|
||||
fci.firstFont.familyName +
|
||||
" in file " + fci.firstFont.fontFile);
|
||||
if (fci.allFonts != null) {
|
||||
for (int f=0;f<fci.allFonts.length;f++) {
|
||||
FontConfigFont fcf = fci.allFonts[f];
|
||||
logger.info("Family=" + fcf.familyName +
|
||||
" Style="+ fcf.styleStr +
|
||||
" Fullname="+fcf.fullName +
|
||||
" File="+fcf.fontFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static PhysicalFont registerFromFcInfo(FontConfigInfo fcInfo) {
|
||||
private static PhysicalFont registerFromFcInfo(FcCompFont fcInfo) {
|
||||
|
||||
/* If it's a TTC file we need to know that as we will need to
|
||||
* make sure we return the right font */
|
||||
int offset = fcInfo.fontFile.length()-4;
|
||||
String fontFile = fcInfo.firstFont.fontFile;
|
||||
int offset = fontFile.length()-4;
|
||||
if (offset <= 0) {
|
||||
return null;
|
||||
}
|
||||
String ext = fcInfo.fontFile.substring(offset).toLowerCase();
|
||||
String ext = fontFile.substring(offset).toLowerCase();
|
||||
boolean isTTC = ext.equals(".ttc");
|
||||
|
||||
/* If this file is already registered, can just return its font.
|
||||
@ -3230,10 +3292,10 @@ public final class FontManager {
|
||||
* a specific font, so rather than directly returning it, let
|
||||
* findFont2D resolve that.
|
||||
*/
|
||||
PhysicalFont physFont = registeredFontFiles.get(fcInfo.fontFile);
|
||||
PhysicalFont physFont = registeredFontFiles.get(fontFile);
|
||||
if (physFont != null) {
|
||||
if (isTTC) {
|
||||
Font2D f2d = findFont2D(fcInfo.familyName,
|
||||
Font2D f2d = findFont2D(fcInfo.firstFont.familyName,
|
||||
fcInfo.style, NO_FALLBACK);
|
||||
if (f2d instanceof PhysicalFont) { /* paranoia */
|
||||
return (PhysicalFont)f2d;
|
||||
@ -3249,18 +3311,20 @@ public final class FontManager {
|
||||
* Lucida Sans), we want to use the JRE version, so make it
|
||||
* point to the JRE font.
|
||||
*/
|
||||
physFont = findJREDeferredFont(fcInfo.familyName, fcInfo.style);
|
||||
physFont = findJREDeferredFont(fcInfo.firstFont.familyName,
|
||||
fcInfo.style);
|
||||
|
||||
/* It is also possible the font file is on the "deferred" list,
|
||||
* in which case we can just initialise it now.
|
||||
*/
|
||||
if (physFont == null &&
|
||||
deferredFontFiles.get(fcInfo.fontFile) != null) {
|
||||
physFont = initialiseDeferredFont(fcInfo.fontFile);
|
||||
deferredFontFiles.get(fontFile) != null)
|
||||
{
|
||||
physFont = initialiseDeferredFont(fcInfo.firstFont.fontFile);
|
||||
/* use findFont2D to get the right font from TTC's */
|
||||
if (physFont != null) {
|
||||
if (isTTC) {
|
||||
Font2D f2d = findFont2D(fcInfo.familyName,
|
||||
Font2D f2d = findFont2D(fcInfo.firstFont.familyName,
|
||||
fcInfo.style, NO_FALLBACK);
|
||||
if (f2d instanceof PhysicalFont) { /* paranoia */
|
||||
return (PhysicalFont)f2d;
|
||||
@ -3287,7 +3351,7 @@ public final class FontManager {
|
||||
fontFormat = FONTFORMAT_TYPE1;
|
||||
fontRank = Font2D.TYPE1_RANK;
|
||||
}
|
||||
physFont = registerFontFile(fcInfo.fontFile, null,
|
||||
physFont = registerFontFile(fcInfo.firstFont.fontFile, null,
|
||||
fontFormat, true, fontRank);
|
||||
}
|
||||
return physFont;
|
||||
@ -3345,12 +3409,12 @@ public final class FontManager {
|
||||
}
|
||||
info[1] = info[1] + File.separator + "arial.ttf";
|
||||
} else {
|
||||
initFontConfigFonts();
|
||||
initFontConfigFonts(false);
|
||||
for (int i=0; i<fontConfigFonts.length; i++) {
|
||||
if ("sans".equals(fontConfigFonts[i].fcFamily) &&
|
||||
0 == fontConfigFonts[i].style) {
|
||||
info[0] = fontConfigFonts[i].familyName;
|
||||
info[1] = fontConfigFonts[i].fontFile;
|
||||
info[0] = fontConfigFonts[i].firstFont.familyName;
|
||||
info[1] = fontConfigFonts[i].firstFont.fontFile;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -3360,9 +3424,9 @@ public final class FontManager {
|
||||
*/
|
||||
if (info[0] == null) {
|
||||
if (fontConfigFonts.length > 0 &&
|
||||
fontConfigFonts[0].fontFile != null) {
|
||||
info[0] = fontConfigFonts[0].familyName;
|
||||
info[1] = fontConfigFonts[0].fontFile;
|
||||
fontConfigFonts[0].firstFont.fontFile != null) {
|
||||
info[0] = fontConfigFonts[0].firstFont.familyName;
|
||||
info[1] = fontConfigFonts[0].firstFont.fontFile;
|
||||
} else {
|
||||
info[0] = "Dialog";
|
||||
info[1] = "/dialog.ttf";
|
||||
@ -3373,8 +3437,8 @@ public final class FontManager {
|
||||
return defaultPlatformFont;
|
||||
}
|
||||
|
||||
private FontConfigInfo getFontConfigInfo() {
|
||||
initFontConfigFonts();
|
||||
private FcCompFont getFcCompFont() {
|
||||
initFontConfigFonts(false);
|
||||
for (int i=0; i<fontConfigFonts.length; i++) {
|
||||
if ("sans".equals(fontConfigFonts[i].fcFamily) &&
|
||||
0 == fontConfigFonts[i].style) {
|
||||
@ -3391,9 +3455,9 @@ public final class FontManager {
|
||||
|
||||
name = name.toLowerCase();
|
||||
|
||||
initFontConfigFonts();
|
||||
initFontConfigFonts(false);
|
||||
|
||||
FontConfigInfo fcInfo = null;
|
||||
FcCompFont fcInfo = null;
|
||||
for (int i=0; i<fontConfigFonts.length; i++) {
|
||||
if (name.equals(fontConfigFonts[i].fcFamily) &&
|
||||
style == fontConfigFonts[i].style) {
|
||||
@ -3407,7 +3471,8 @@ public final class FontManager {
|
||||
|
||||
if (logging) {
|
||||
logger.info("FC name=" + name + " style=" + style + " uses " +
|
||||
fcInfo.familyName + " in file: " + fcInfo.fontFile);
|
||||
fcInfo.firstFont.familyName +
|
||||
" in file: " + fcInfo.firstFont.fontFile);
|
||||
}
|
||||
|
||||
if (fcInfo.compFont != null) {
|
||||
@ -3420,7 +3485,8 @@ public final class FontManager {
|
||||
CompositeFont jdkFont = (CompositeFont)
|
||||
findFont2D(fcInfo.jdkName, style, LOGICAL_FALLBACK);
|
||||
|
||||
if (fcInfo.familyName == null || fcInfo.fontFile == null) {
|
||||
if (fcInfo.firstFont.familyName == null ||
|
||||
fcInfo.firstFont.fontFile == null) {
|
||||
return (fcInfo.compFont = jdkFont);
|
||||
}
|
||||
|
||||
@ -3432,7 +3498,7 @@ public final class FontManager {
|
||||
* will fall through this code, but the regisration code will
|
||||
* find that file already registered and return its font.
|
||||
*/
|
||||
FontFamily family = FontFamily.getFamily(fcInfo.familyName);
|
||||
FontFamily family = FontFamily.getFamily(fcInfo.firstFont.familyName);
|
||||
PhysicalFont physFont = null;
|
||||
if (family != null) {
|
||||
Font2D f2D = family.getFontWithExactStyleMatch(fcInfo.style);
|
||||
@ -3441,7 +3507,8 @@ public final class FontManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (physFont == null || !fcInfo.fontFile.equals(physFont.platName)) {
|
||||
if (physFont == null ||
|
||||
!fcInfo.firstFont.fontFile.equals(physFont.platName)) {
|
||||
physFont = registerFromFcInfo(fcInfo);
|
||||
if (physFont == null) {
|
||||
return (fcInfo.compFont = jdkFont);
|
||||
@ -3459,10 +3526,10 @@ public final class FontManager {
|
||||
* together to prevent synthetic styling.
|
||||
*/
|
||||
for (int i=0; i<fontConfigFonts.length; i++) {
|
||||
FontConfigInfo fc = fontConfigFonts[i];
|
||||
FcCompFont fc = fontConfigFonts[i];
|
||||
if (fc != fcInfo &&
|
||||
physFont.getFamilyName(null).equals(fc.familyName) &&
|
||||
!fc.fontFile.equals(physFont.platName) &&
|
||||
physFont.getFamilyName(null).equals(fc.firstFont.familyName) &&
|
||||
!fc.firstFont.fontFile.equals(physFont.platName) &&
|
||||
family.getFontWithExactStyleMatch(fc.style) == null) {
|
||||
|
||||
registerFromFcInfo(fontConfigFonts[i]);
|
||||
|
@ -76,7 +76,7 @@ class NullFontScaler extends FontScaler {
|
||||
}
|
||||
|
||||
int getNumGlyphs() throws FontScalerException {
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int getMissingGlyphCode() throws FontScalerException {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,16 +25,17 @@
|
||||
|
||||
package sun.font;
|
||||
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontFormatException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import sun.java2d.Disposer;
|
||||
import sun.java2d.pipe.BufferedContext;
|
||||
import sun.java2d.pipe.RenderQueue;
|
||||
import sun.java2d.pipe.hw.AccelGraphicsConfig;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
/**
|
||||
@ -192,13 +193,13 @@ public final class StrikeCache {
|
||||
recentStrikeIndex = index;
|
||||
}
|
||||
|
||||
static void disposeStrike(FontStrikeDisposer disposer) {
|
||||
private static final void doDispose(FontStrikeDisposer disposer) {
|
||||
if (disposer.intGlyphImages != null) {
|
||||
freeIntMemory(disposer.intGlyphImages,
|
||||
disposer.pScalerContext);
|
||||
disposer.pScalerContext);
|
||||
} else if (disposer.longGlyphImages != null) {
|
||||
freeLongMemory(disposer.longGlyphImages,
|
||||
disposer.pScalerContext);
|
||||
disposer.pScalerContext);
|
||||
} else if (disposer.segIntGlyphImages != null) {
|
||||
/* NB Now making multiple JNI calls in this case.
|
||||
* But assuming that there's a reasonable amount of locality
|
||||
@ -207,7 +208,7 @@ public final class StrikeCache {
|
||||
for (int i=0; i<disposer.segIntGlyphImages.length; i++) {
|
||||
if (disposer.segIntGlyphImages[i] != null) {
|
||||
freeIntMemory(disposer.segIntGlyphImages[i],
|
||||
disposer.pScalerContext);
|
||||
disposer.pScalerContext);
|
||||
/* native will only free the scaler context once */
|
||||
disposer.pScalerContext = 0L;
|
||||
disposer.segIntGlyphImages[i] = null;
|
||||
@ -223,7 +224,7 @@ public final class StrikeCache {
|
||||
for (int i=0; i<disposer.segLongGlyphImages.length; i++) {
|
||||
if (disposer.segLongGlyphImages[i] != null) {
|
||||
freeLongMemory(disposer.segLongGlyphImages[i],
|
||||
disposer.pScalerContext);
|
||||
disposer.pScalerContext);
|
||||
disposer.pScalerContext = 0L;
|
||||
disposer.segLongGlyphImages[i] = null;
|
||||
}
|
||||
@ -234,6 +235,44 @@ public final class StrikeCache {
|
||||
}
|
||||
}
|
||||
|
||||
static void disposeStrike(final FontStrikeDisposer disposer) {
|
||||
// we need to execute the strike disposal on the rendering thread
|
||||
// because they may be accessed on that thread at the time of the
|
||||
// disposal (for example, when the accel. cache is invalidated)
|
||||
|
||||
// REMIND: this look a bit heavyweight, but should be ok
|
||||
// because strike disposal is a relatively infrequent operation,
|
||||
// more worrisome is the necessity of getting a GC here.
|
||||
RenderQueue rq = null;
|
||||
GraphicsEnvironment ge =
|
||||
GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
if (!ge.isHeadless()) {
|
||||
GraphicsConfiguration gc =
|
||||
ge.getDefaultScreenDevice().getDefaultConfiguration();
|
||||
if (gc instanceof AccelGraphicsConfig) {
|
||||
AccelGraphicsConfig agc = (AccelGraphicsConfig)gc;
|
||||
BufferedContext bc = agc.getContext();
|
||||
if (bc != null) {
|
||||
rq = bc.getRenderQueue();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rq != null) {
|
||||
rq.lock();
|
||||
try {
|
||||
rq.flushAndInvokeNow(new Runnable() {
|
||||
public void run() {
|
||||
doDispose(disposer);
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
rq.unlock();
|
||||
}
|
||||
} else {
|
||||
doDispose(disposer);
|
||||
}
|
||||
}
|
||||
|
||||
static native void freeIntPointer(int ptr);
|
||||
static native void freeLongPointer(long ptr);
|
||||
private static native void freeIntMemory(int[] glyphPtrs, long pContext);
|
||||
|
41
jdk/src/share/classes/sun/java2d/DestSurfaceProvider.java
Normal file
41
jdk/src/share/classes/sun/java2d/DestSurfaceProvider.java
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package sun.java2d;
|
||||
|
||||
import sun.java2d.pipe.hw.*;
|
||||
|
||||
/**
|
||||
* Classes implementing this interface provide access to their
|
||||
* destination surfaces.
|
||||
*/
|
||||
public interface DestSurfaceProvider {
|
||||
/**
|
||||
* Returns a surface currently used as a destination surface for rendering.
|
||||
*
|
||||
* @return destination surface
|
||||
*/
|
||||
public Surface getDestSurface();
|
||||
}
|
@ -41,24 +41,17 @@ import java.awt.image.renderable.RenderableImage;
|
||||
import java.awt.image.renderable.RenderContext;
|
||||
import java.awt.image.AffineTransformOp;
|
||||
import java.awt.image.Raster;
|
||||
import java.awt.image.SampleModel;
|
||||
import java.awt.image.VolatileImage;
|
||||
import java.awt.image.WritableRaster;
|
||||
import java.awt.Image;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Color;
|
||||
import java.awt.color.ColorSpace;
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.IndexColorModel;
|
||||
import java.awt.image.DirectColorModel;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.Paint;
|
||||
import java.awt.GradientPaint;
|
||||
import java.awt.LinearGradientPaint;
|
||||
import java.awt.RadialGradientPaint;
|
||||
import java.awt.TexturePaint;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.geom.PathIterator;
|
||||
import java.awt.geom.GeneralPath;
|
||||
@ -69,19 +62,16 @@ import java.awt.Rectangle;
|
||||
import java.text.AttributedCharacterIterator;
|
||||
import java.awt.Font;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.awt.image.ColorConvertOp;
|
||||
import java.awt.Transparency;
|
||||
import java.awt.font.GlyphVector;
|
||||
import java.awt.font.TextLayout;
|
||||
import sun.font.FontDesignMetrics;
|
||||
import sun.font.StandardGlyphVector;
|
||||
import sun.java2d.pipe.PixelDrawPipe;
|
||||
import sun.java2d.pipe.PixelFillPipe;
|
||||
import sun.java2d.pipe.ShapeDrawPipe;
|
||||
import sun.java2d.pipe.ValidatePipe;
|
||||
import sun.java2d.pipe.ShapeSpanIterator;
|
||||
import sun.java2d.pipe.Region;
|
||||
import sun.java2d.pipe.RegionIterator;
|
||||
import sun.java2d.pipe.TextPipe;
|
||||
import sun.java2d.pipe.DrawImagePipe;
|
||||
import sun.java2d.pipe.LoopPipe;
|
||||
@ -90,7 +80,6 @@ import sun.java2d.loops.RenderLoops;
|
||||
import sun.java2d.loops.CompositeType;
|
||||
import sun.java2d.loops.SurfaceType;
|
||||
import sun.java2d.loops.Blit;
|
||||
import sun.java2d.loops.BlitBg;
|
||||
import sun.java2d.loops.MaskFill;
|
||||
import sun.font.FontManager;
|
||||
import java.awt.font.FontRenderContext;
|
||||
@ -99,7 +88,7 @@ import sun.awt.ConstrainableGraphics;
|
||||
import sun.awt.SunHints;
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
import sun.awt.image.OffScreenImage;
|
||||
import sun.java2d.DestSurfaceProvider;
|
||||
import sun.misc.PerformanceLogger;
|
||||
|
||||
/**
|
||||
@ -113,7 +102,7 @@ import sun.misc.PerformanceLogger;
|
||||
*/
|
||||
public final class SunGraphics2D
|
||||
extends Graphics2D
|
||||
implements ConstrainableGraphics, Cloneable
|
||||
implements ConstrainableGraphics, Cloneable, DestSurfaceProvider
|
||||
{
|
||||
/*
|
||||
* Attribute States
|
||||
@ -3306,4 +3295,14 @@ public final class SunGraphics2D
|
||||
public Object getDestination() {
|
||||
return surfaceData.getDestination();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @see sun.java2d.DestSurfaceProvider#getDestSurface
|
||||
*/
|
||||
@Override
|
||||
public Surface getDestSurface() {
|
||||
return surfaceData;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -36,6 +36,7 @@ import java.awt.Rectangle;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.font.TextAttribute;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.peer.ComponentPeer;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -78,6 +79,7 @@ public abstract class SunGraphicsEnvironment extends GraphicsEnvironment
|
||||
|
||||
public static boolean isLinux;
|
||||
public static boolean isSolaris;
|
||||
public static boolean isOpenSolaris;
|
||||
public static boolean isWindows;
|
||||
public static boolean noType1Font;
|
||||
private static Font defaultFont;
|
||||
@ -167,6 +169,23 @@ public abstract class SunGraphicsEnvironment extends GraphicsEnvironment
|
||||
isLinux = true;
|
||||
} else if ("SunOS".equals(osName)) {
|
||||
isSolaris = true;
|
||||
String version = System.getProperty("os.version", "0.0");
|
||||
try {
|
||||
float ver = Float.parseFloat(version);
|
||||
if (ver > 5.10f) {
|
||||
File f = new File("/etc/release");
|
||||
FileInputStream fis = new FileInputStream(f);
|
||||
InputStreamReader isr
|
||||
= new InputStreamReader(fis, "ISO-8859-1");
|
||||
BufferedReader br = new BufferedReader(isr);
|
||||
String line = br.readLine();
|
||||
if (line.indexOf("OpenSolaris") >= 0) {
|
||||
isOpenSolaris = true;
|
||||
}
|
||||
fis.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
} else if ("Windows".equals(osName)) {
|
||||
isWindows = true;
|
||||
}
|
||||
@ -174,11 +193,7 @@ public abstract class SunGraphicsEnvironment extends GraphicsEnvironment
|
||||
noType1Font = "true".
|
||||
equals(System.getProperty("sun.java2d.noType1Font"));
|
||||
|
||||
if (isOpenJDK()) {
|
||||
String[] fontInfo = FontManager.getDefaultPlatformFont();
|
||||
defaultFontName = fontInfo[0];
|
||||
defaultFontFileName = fontInfo[1];
|
||||
} else {
|
||||
if (!isOpenJDK()) {
|
||||
defaultFontName = lucidaFontName;
|
||||
if (useAbsoluteFontFileNames()) {
|
||||
defaultFontFileName =
|
||||
@ -244,6 +259,11 @@ public abstract class SunGraphicsEnvironment extends GraphicsEnvironment
|
||||
* that might be specified.
|
||||
*/
|
||||
fontConfig = createFontConfiguration();
|
||||
if (isOpenJDK()) {
|
||||
String[] fontInfo = FontManager.getDefaultPlatformFont();
|
||||
defaultFontName = fontInfo[0];
|
||||
defaultFontFileName = fontInfo[1];
|
||||
}
|
||||
getPlatformFontPathFromFontConfig();
|
||||
|
||||
String extraFontPath = fontConfig.getExtraFontPath();
|
||||
@ -1069,7 +1089,7 @@ public abstract class SunGraphicsEnvironment extends GraphicsEnvironment
|
||||
String fontFileName =
|
||||
getFileNameFromPlatformName(platformFontName);
|
||||
String[] nativeNames = null;
|
||||
if (fontFileName == null) {
|
||||
if (fontFileName == null || fontFileName.equals(platformFontName)){
|
||||
/* No file located, so register using the platform name,
|
||||
* i.e. as a native font.
|
||||
*/
|
||||
@ -1294,4 +1314,18 @@ public abstract class SunGraphicsEnvironment extends GraphicsEnvironment
|
||||
/*
|
||||
* ----END DISPLAY CHANGE SUPPORT----
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns true if FlipBufferStrategy with COPIED buffer contents
|
||||
* is preferred for this peer's GraphicsConfiguration over
|
||||
* BlitBufferStrategy, false otherwise.
|
||||
*
|
||||
* The reason FlipBS could be preferred is that in some configurations
|
||||
* an accelerated copy to the screen is supported (like Direct3D 9)
|
||||
*
|
||||
* @return true if flip strategy should be used, false otherwise
|
||||
*/
|
||||
public boolean isFlipStrategyPreferred(ComponentPeer peer) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
34
jdk/src/share/classes/sun/java2d/Surface.java
Normal file
34
jdk/src/share/classes/sun/java2d/Surface.java
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package sun.java2d;
|
||||
|
||||
/**
|
||||
* This is a tag interface for a surface.
|
||||
* @see sun.java2d.SurfaceData
|
||||
* @see sun.java2d.pipe.hw.AccelSurface
|
||||
*/
|
||||
public interface Surface {
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -93,7 +93,7 @@ import sun.awt.image.SurfaceManager;
|
||||
* retrieved the tracker.
|
||||
*/
|
||||
public abstract class SurfaceData
|
||||
implements Transparency, DisposerTarget, StateTrackable
|
||||
implements Transparency, DisposerTarget, StateTrackable, Surface
|
||||
{
|
||||
private long pData;
|
||||
private boolean valid;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -521,7 +521,7 @@ public abstract class SurfaceDataProxy
|
||||
CompositeType.SrcNoEa,
|
||||
dstType);
|
||||
blitbg.BlitBg(srcData, dstData,
|
||||
AlphaComposite.Src, null, bgColor,
|
||||
AlphaComposite.Src, null, bgColor.getRGB(),
|
||||
0, 0, 0, 0, w, h);
|
||||
dstData.markDirty();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1999-2004 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -109,7 +109,7 @@ public class BlitBg extends GraphicsPrimitive
|
||||
*/
|
||||
public native void BlitBg(SurfaceData src, SurfaceData dst,
|
||||
Composite comp, Region clip,
|
||||
Color bgColor,
|
||||
int bgColor,
|
||||
int srcx, int srcy,
|
||||
int dstx, int dsty,
|
||||
int width, int height);
|
||||
@ -142,19 +142,19 @@ public class BlitBg extends GraphicsPrimitive
|
||||
compositeType = comptype;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void BlitBg(SurfaceData srcData,
|
||||
SurfaceData dstData,
|
||||
Composite comp,
|
||||
Region clip,
|
||||
Color bgColor,
|
||||
int bgArgb,
|
||||
int srcx, int srcy,
|
||||
int dstx, int dsty,
|
||||
int width, int height)
|
||||
{
|
||||
ColorModel dstModel = dstData.getColorModel();
|
||||
if (!dstModel.hasAlpha() &&
|
||||
bgColor.getTransparency() != Transparency.OPAQUE)
|
||||
{
|
||||
boolean bgHasAlpha = (bgArgb >>> 24) != 0xff;
|
||||
if (!dstModel.hasAlpha() && bgHasAlpha) {
|
||||
dstModel = ColorModel.getRGBdefault();
|
||||
}
|
||||
WritableRaster wr =
|
||||
@ -163,6 +163,7 @@ public class BlitBg extends GraphicsPrimitive
|
||||
BufferedImage bimg =
|
||||
new BufferedImage(dstModel, wr, isPremult, null);
|
||||
SurfaceData tmpData = BufImgSurfaceData.createData(bimg);
|
||||
Color bgColor = new Color(bgArgb, bgHasAlpha);
|
||||
SunGraphics2D sg2d = new SunGraphics2D(tmpData, bgColor, bgColor,
|
||||
defaultFont);
|
||||
FillRect fillop = FillRect.locate(SurfaceType.AnyColor,
|
||||
@ -201,9 +202,10 @@ public class BlitBg extends GraphicsPrimitive
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void BlitBg(SurfaceData src, SurfaceData dst,
|
||||
Composite comp, Region clip,
|
||||
Color bgColor,
|
||||
int bgColor,
|
||||
int srcx, int srcy, int dstx, int dsty,
|
||||
int width, int height)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -159,6 +159,10 @@ public final class GeneralRenderer {
|
||||
{
|
||||
int mx, my, x1, y1;
|
||||
int[] tmp = null;
|
||||
|
||||
if (nPoints <= 0) {
|
||||
return;
|
||||
}
|
||||
mx = x1 = xPoints[off] + transx;
|
||||
my = y1 = yPoints[off] + transy;
|
||||
while (--nPoints > 0) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -35,6 +35,7 @@ import sun.java2d.SunGraphics2D;
|
||||
import sun.java2d.SurfaceData;
|
||||
import sun.java2d.loops.CompositeType;
|
||||
import sun.java2d.pipe.BufferedBufImgOps;
|
||||
import static sun.java2d.opengl.OGLContext.OGLContextCaps.*;
|
||||
|
||||
class OGLBufImgOps extends BufferedBufImgOps {
|
||||
|
||||
@ -94,7 +95,7 @@ class OGLBufImgOps extends BufferedBufImgOps {
|
||||
OGLSurfaceData oglSrc = (OGLSurfaceData)srcData;
|
||||
OGLGraphicsConfig gc = oglSrc.getOGLGraphicsConfig();
|
||||
if (oglSrc.getType() != OGLSurfaceData.TEXTURE ||
|
||||
!gc.isCapPresent(OGLContext.CAPS_EXT_BIOP_SHADER))
|
||||
!gc.isCapPresent(CAPS_EXT_BIOP_SHADER))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2004-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,91 +25,24 @@
|
||||
|
||||
package sun.java2d.opengl;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Paint;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import sun.java2d.SunGraphics2D;
|
||||
import sun.java2d.pipe.BufferedContext;
|
||||
import sun.java2d.pipe.Region;
|
||||
import sun.java2d.pipe.RenderBuffer;
|
||||
import sun.java2d.pipe.RenderQueue;
|
||||
import sun.java2d.pipe.hw.ContextCapabilities;
|
||||
import static sun.java2d.pipe.BufferedOpCodes.*;
|
||||
import static sun.java2d.pipe.hw.ContextCapabilities.*;
|
||||
|
||||
/**
|
||||
* Note that the RenderQueue lock must be acquired before calling any of
|
||||
* the methods in this class.
|
||||
*/
|
||||
class OGLContext extends BufferedContext {
|
||||
public class OGLContext extends BufferedContext {
|
||||
|
||||
/** Indicates that the context has no capabilities. */
|
||||
static final int CAPS_EMPTY = (0 << 0);
|
||||
/** Indicates that the context is doublebuffered. */
|
||||
static final int CAPS_DOUBLEBUFFERED = (1 << 0);
|
||||
/** Indicates that the context supports a stored alpha channel. */
|
||||
static final int CAPS_STORED_ALPHA = (1 << 1);
|
||||
/** Indicates the presence of the GL_ARB_multitexture extension. */
|
||||
static final int CAPS_EXT_MULTITEXTURE = (1 << 2);
|
||||
/** Indicates the presence of the GL_ARB_texture_non_power_of_two ext. */
|
||||
static final int CAPS_EXT_TEXNONPOW2 = (1 << 3);
|
||||
/**
|
||||
* Indicates the presence of the GL_EXT_framebuffer_object extension.
|
||||
* This cap will only be set if the fbobject system property has been
|
||||
* enabled and we are able to create an FBO with depth buffer.
|
||||
*/
|
||||
static final int CAPS_EXT_FBOBJECT = (1 << 4);
|
||||
/**
|
||||
* Indicates the presence of the GL_ARB_fragment_shader extension.
|
||||
* This cap will only be set if the lcdshader system property has been
|
||||
* enabled and the hardware supports the minimum number of texture units.
|
||||
*/
|
||||
static final int CAPS_EXT_LCD_SHADER = (1 << 5);
|
||||
/** Indicates the presence of the GL_ARB_texture_rectangle extension. */
|
||||
static final int CAPS_EXT_TEXRECT = (1 << 6);
|
||||
/**
|
||||
* Indicates the presence of the GL_ARB_fragment_shader extension.
|
||||
* This cap will only be set if the biopshader system property has been
|
||||
* enabled and the hardware meets our minimum requirements.
|
||||
*/
|
||||
static final int CAPS_EXT_BIOP_SHADER = (1 << 7);
|
||||
/**
|
||||
* Indicates the presence of the GL_ARB_fragment_shader extension.
|
||||
* This cap will only be set if the gradshader system property has been
|
||||
* enabled and the hardware meets our minimum requirements.
|
||||
*/
|
||||
static final int CAPS_EXT_GRAD_SHADER = (1 << 8);
|
||||
private final OGLGraphicsConfig config;
|
||||
|
||||
OGLContext(RenderQueue rq) {
|
||||
OGLContext(RenderQueue rq, OGLGraphicsConfig config) {
|
||||
super(rq);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the OGLContext associated with the current GraphicsConfig
|
||||
* and validates the context using the given parameters. Most rendering
|
||||
* operations will call this method first in order to set the necessary
|
||||
* state before issuing rendering commands.
|
||||
*/
|
||||
static void validateContext(OGLSurfaceData srcData,
|
||||
OGLSurfaceData dstData,
|
||||
Region clip, Composite comp,
|
||||
AffineTransform xform,
|
||||
Paint paint, SunGraphics2D sg2d,
|
||||
int flags)
|
||||
{
|
||||
// assert rq.lock.isHeldByCurrentThread();
|
||||
OGLContext oglc = dstData.getContext();
|
||||
oglc.validate(srcData, dstData,
|
||||
clip, comp, xform, paint, sg2d, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Simplified version of validateContext() that disables all context
|
||||
* state settings.
|
||||
*/
|
||||
static void validateContext(OGLSurfaceData dstData) {
|
||||
// assert rq.lock.isHeldByCurrentThread();
|
||||
validateContext(dstData, dstData,
|
||||
null, null, null, null, null, NO_CONTEXT_FLAGS);
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -160,19 +93,128 @@ class OGLContext extends BufferedContext {
|
||||
static void invalidateCurrentContext() {
|
||||
// assert OGLRenderQueue.getInstance().lock.isHeldByCurrentThread();
|
||||
|
||||
// first invalidate the context reference at the native level, and
|
||||
// invalidate the current Java-level context so that we
|
||||
// revalidate everything the next time around
|
||||
if (currentContext != null) {
|
||||
currentContext.invalidateContext();
|
||||
currentContext = null;
|
||||
}
|
||||
|
||||
// invalidate the context reference at the native level, and
|
||||
// then flush the queue so that we have no pending operations
|
||||
// dependent on the current context
|
||||
OGLRenderQueue rq = OGLRenderQueue.getInstance();
|
||||
rq.ensureCapacity(4);
|
||||
rq.getBuffer().putInt(INVALIDATE_CONTEXT);
|
||||
rq.flushNow();
|
||||
}
|
||||
|
||||
// then invalidate the current Java-level context so that we
|
||||
// revalidate everything the next time around
|
||||
if (currentContext != null) {
|
||||
currentContext.invalidateSurfaces();
|
||||
currentContext = null;
|
||||
public RenderQueue getRenderQueue() {
|
||||
return OGLRenderQueue.getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representing adapter id (vendor, renderer, version).
|
||||
* Must be called on the rendering thread.
|
||||
*
|
||||
* @return an id string for the adapter
|
||||
*/
|
||||
static final native String getOGLIdString();
|
||||
|
||||
@Override
|
||||
public void saveState() {
|
||||
// assert rq.lock.isHeldByCurrentThread();
|
||||
|
||||
// reset all attributes of this and current contexts
|
||||
invalidateContext();
|
||||
invalidateCurrentContext();
|
||||
|
||||
setScratchSurface(config);
|
||||
|
||||
// save the state on the native level
|
||||
rq.ensureCapacity(4);
|
||||
buf.putInt(SAVE_STATE);
|
||||
rq.flushNow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreState() {
|
||||
// assert rq.lock.isHeldByCurrentThread();
|
||||
|
||||
// reset all attributes of this and current contexts
|
||||
invalidateContext();
|
||||
invalidateCurrentContext();
|
||||
|
||||
setScratchSurface(config);
|
||||
|
||||
// restore the state on the native level
|
||||
rq.ensureCapacity(4);
|
||||
buf.putInt(RESTORE_STATE);
|
||||
rq.flushNow();
|
||||
}
|
||||
|
||||
static class OGLContextCaps extends ContextCapabilities {
|
||||
/**
|
||||
* Indicates the presence of the GL_EXT_framebuffer_object extension.
|
||||
* This cap will only be set if the fbobject system property has been
|
||||
* enabled and we are able to create an FBO with depth buffer.
|
||||
*/
|
||||
static final int CAPS_EXT_FBOBJECT =
|
||||
(CAPS_RT_TEXTURE_ALPHA | CAPS_RT_TEXTURE_OPAQUE);
|
||||
/** Indicates that the context supports a stored alpha channel. */
|
||||
static final int CAPS_STORED_ALPHA = CAPS_RT_PLAIN_ALPHA;
|
||||
/** Indicates that the context is doublebuffered. */
|
||||
static final int CAPS_DOUBLEBUFFERED = (FIRST_PRIVATE_CAP << 0);
|
||||
/**
|
||||
* Indicates the presence of the GL_ARB_fragment_shader extension.
|
||||
* This cap will only be set if the lcdshader system property has been
|
||||
* enabled and the hardware supports the minimum number of texture units
|
||||
*/
|
||||
static final int CAPS_EXT_LCD_SHADER = (FIRST_PRIVATE_CAP << 1);
|
||||
/**
|
||||
* Indicates the presence of the GL_ARB_fragment_shader extension.
|
||||
* This cap will only be set if the biopshader system property has been
|
||||
* enabled and the hardware meets our minimum requirements.
|
||||
*/
|
||||
static final int CAPS_EXT_BIOP_SHADER = (FIRST_PRIVATE_CAP << 2);
|
||||
/**
|
||||
* Indicates the presence of the GL_ARB_fragment_shader extension.
|
||||
* This cap will only be set if the gradshader system property has been
|
||||
* enabled and the hardware meets our minimum requirements.
|
||||
*/
|
||||
static final int CAPS_EXT_GRAD_SHADER = (FIRST_PRIVATE_CAP << 3);
|
||||
/** Indicates the presence of the GL_ARB_texture_rectangle extension. */
|
||||
static final int CAPS_EXT_TEXRECT = (FIRST_PRIVATE_CAP << 4);
|
||||
|
||||
OGLContextCaps(int caps, String adapterId) {
|
||||
super(caps, adapterId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer(super.toString());
|
||||
if ((caps & CAPS_EXT_FBOBJECT) != 0) {
|
||||
buf.append("CAPS_EXT_FBOBJECT|");
|
||||
}
|
||||
if ((caps & CAPS_STORED_ALPHA) != 0) {
|
||||
buf.append("CAPS_STORED_ALPHA|");
|
||||
}
|
||||
if ((caps & CAPS_DOUBLEBUFFERED) != 0) {
|
||||
buf.append("CAPS_DOUBLEBUFFERED|");
|
||||
}
|
||||
if ((caps & CAPS_EXT_LCD_SHADER) != 0) {
|
||||
buf.append("CAPS_EXT_LCD_SHADER|");
|
||||
}
|
||||
if ((caps & CAPS_EXT_BIOP_SHADER) != 0) {
|
||||
buf.append("CAPS_BIOP_SHADER|");
|
||||
}
|
||||
if ((caps & CAPS_EXT_GRAD_SHADER) != 0) {
|
||||
buf.append("CAPS_EXT_GRAD_SHADER|");
|
||||
}
|
||||
if ((caps & CAPS_EXT_TEXRECT) != 0) {
|
||||
buf.append("CAPS_EXT_TEXRECT|");
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,13 +27,16 @@ package sun.java2d.opengl;
|
||||
|
||||
import sun.java2d.SurfaceData;
|
||||
import sun.awt.image.SurfaceManager;
|
||||
import sun.java2d.pipe.hw.AccelGraphicsConfig;
|
||||
|
||||
/**
|
||||
* This interface collects the methods that are provided by both
|
||||
* GLXGraphicsConfig and WGLGraphicsConfig, making it easier to invoke these
|
||||
* methods directly from OGLSurfaceData.
|
||||
*/
|
||||
interface OGLGraphicsConfig extends SurfaceManager.ProxiedGraphicsConfig {
|
||||
interface OGLGraphicsConfig extends
|
||||
AccelGraphicsConfig, SurfaceManager.ProxiedGraphicsConfig
|
||||
{
|
||||
OGLContext getContext();
|
||||
long getNativeConfigInfo();
|
||||
boolean isCapPresent(int cap);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -39,6 +39,7 @@ import sun.java2d.SunGraphics2D;
|
||||
import sun.java2d.SurfaceData;
|
||||
import sun.java2d.loops.CompositeType;
|
||||
import static sun.java2d.pipe.BufferedPaints.*;
|
||||
import static sun.java2d.opengl.OGLContext.OGLContextCaps.*;
|
||||
|
||||
abstract class OGLPaints {
|
||||
|
||||
@ -170,7 +171,7 @@ abstract class OGLPaints {
|
||||
|
||||
OGLSurfaceData dstData = (OGLSurfaceData)sg2d.surfaceData;
|
||||
OGLGraphicsConfig gc = dstData.getOGLGraphicsConfig();
|
||||
if (!gc.isCapPresent(OGLContext.CAPS_EXT_GRAD_SHADER)) {
|
||||
if (!gc.isCapPresent(CAPS_EXT_GRAD_SHADER)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -30,6 +30,7 @@ import java.awt.geom.Path2D;
|
||||
import sun.java2d.SunGraphics2D;
|
||||
import sun.java2d.loops.GraphicsPrimitive;
|
||||
import sun.java2d.pipe.BufferedRenderPipe;
|
||||
import sun.java2d.pipe.ParallelogramPipe;
|
||||
import sun.java2d.pipe.RenderQueue;
|
||||
import sun.java2d.pipe.SpanIterator;
|
||||
import static sun.java2d.pipe.BufferedOpCodes.*;
|
||||
@ -51,6 +52,15 @@ class OGLRenderer extends BufferedRenderPipe {
|
||||
null, sg2d.paint, sg2d, ctxflags);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateContextAA(SunGraphics2D sg2d) {
|
||||
int ctxflags = OGLContext.NO_CONTEXT_FLAGS;
|
||||
OGLSurfaceData dstData = (OGLSurfaceData)sg2d.surfaceData;
|
||||
OGLContext.validateContext(dstData, dstData,
|
||||
sg2d.getCompClip(), sg2d.composite,
|
||||
null, sg2d.paint, sg2d, ctxflags);
|
||||
}
|
||||
|
||||
void copyArea(SunGraphics2D sg2d,
|
||||
int x, int y, int w, int h, int dx, int dy)
|
||||
{
|
||||
@ -88,6 +98,31 @@ class OGLRenderer extends BufferedRenderPipe {
|
||||
super(oglr.rq);
|
||||
this.oglr = oglr;
|
||||
}
|
||||
public ParallelogramPipe getAAParallelogramPipe() {
|
||||
final ParallelogramPipe realpipe = oglr.getAAParallelogramPipe();
|
||||
return new ParallelogramPipe() {
|
||||
public void fillParallelogram(SunGraphics2D sg2d,
|
||||
double x, double y,
|
||||
double dx1, double dy1,
|
||||
double dx2, double dy2)
|
||||
{
|
||||
GraphicsPrimitive.tracePrimitive("OGLFillAAParallelogram");
|
||||
realpipe.fillParallelogram(sg2d,
|
||||
x, y, dx1, dy1, dx2, dy2);
|
||||
}
|
||||
public void drawParallelogram(SunGraphics2D sg2d,
|
||||
double x, double y,
|
||||
double dx1, double dy1,
|
||||
double dx2, double dy2,
|
||||
double lw1, double lw2)
|
||||
{
|
||||
GraphicsPrimitive.tracePrimitive("OGLDrawAAParallelogram");
|
||||
realpipe.drawParallelogram(sg2d,
|
||||
x, y, dx1, dy1, dx2, dy2,
|
||||
lw1, lw2);
|
||||
}
|
||||
};
|
||||
}
|
||||
protected void validateContext(SunGraphics2D sg2d) {
|
||||
oglr.validateContext(sg2d);
|
||||
}
|
||||
@ -130,6 +165,23 @@ class OGLRenderer extends BufferedRenderPipe {
|
||||
GraphicsPrimitive.tracePrimitive("OGLFillSpans");
|
||||
oglr.fillSpans(sg2d, si, transx, transy);
|
||||
}
|
||||
public void fillParallelogram(SunGraphics2D sg2d,
|
||||
double x, double y,
|
||||
double dx1, double dy1,
|
||||
double dx2, double dy2)
|
||||
{
|
||||
GraphicsPrimitive.tracePrimitive("OGLFillParallelogram");
|
||||
oglr.fillParallelogram(sg2d, x, y, dx1, dy1, dx2, dy2);
|
||||
}
|
||||
public void drawParallelogram(SunGraphics2D sg2d,
|
||||
double x, double y,
|
||||
double dx1, double dy1,
|
||||
double dx2, double dy2,
|
||||
double lw1, double lw2)
|
||||
{
|
||||
GraphicsPrimitive.tracePrimitive("OGLDrawParallelogram");
|
||||
oglr.drawParallelogram(sg2d, x, y, dx1, dy1, dx2, dy2, lw1, lw2);
|
||||
}
|
||||
public void copyArea(SunGraphics2D sg2d,
|
||||
int x, int y, int w, int h, int dx, int dy)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,23 +27,26 @@ package sun.java2d.opengl;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Transparency;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.Raster;
|
||||
import sun.awt.SunHints;
|
||||
import sun.awt.image.PixelConverter;
|
||||
import sun.java2d.pipe.hw.AccelSurface;
|
||||
import sun.java2d.SunGraphics2D;
|
||||
import sun.java2d.SurfaceData;
|
||||
import sun.java2d.SurfaceDataProxy;
|
||||
import sun.java2d.loops.CompositeType;
|
||||
import sun.java2d.loops.GraphicsPrimitive;
|
||||
import sun.java2d.loops.MaskFill;
|
||||
import sun.java2d.loops.SurfaceType;
|
||||
import sun.java2d.pipe.PixelToShapeConverter;
|
||||
import sun.java2d.pipe.ParallelogramPipe;
|
||||
import sun.java2d.pipe.PixelToParallelogramConverter;
|
||||
import sun.java2d.pipe.RenderBuffer;
|
||||
import sun.java2d.pipe.RenderQueue;
|
||||
import sun.java2d.pipe.TextPipe;
|
||||
import static sun.java2d.pipe.BufferedOpCodes.*;
|
||||
import static sun.java2d.opengl.OGLContext.*;
|
||||
import static sun.java2d.opengl.OGLContext.OGLContextCaps.*;
|
||||
|
||||
/**
|
||||
* This class describes an OpenGL "surface", that is, a region of pixels
|
||||
@ -92,17 +95,16 @@ import static sun.java2d.opengl.OGLContext.*;
|
||||
* FLIP_BACKBUFFER OpenGLSurface
|
||||
* FBOBJECT OpenGLSurfaceRTT
|
||||
*/
|
||||
public abstract class OGLSurfaceData extends SurfaceData {
|
||||
public abstract class OGLSurfaceData extends SurfaceData
|
||||
implements AccelSurface {
|
||||
|
||||
/**
|
||||
* OGL-specific surface types
|
||||
*
|
||||
* @see sun.java2d.pipe.hw.AccelSurface
|
||||
*/
|
||||
public static final int UNDEFINED = 0;
|
||||
public static final int WINDOW = 1;
|
||||
public static final int PBUFFER = 2;
|
||||
public static final int TEXTURE = 3;
|
||||
public static final int FLIP_BACKBUFFER = 4;
|
||||
public static final int FBOBJECT = 5;
|
||||
public static final int PBUFFER = RT_PLAIN;
|
||||
public static final int FBOBJECT = RT_TEXTURE;
|
||||
|
||||
/**
|
||||
* Pixel formats
|
||||
@ -148,11 +150,14 @@ public abstract class OGLSurfaceData extends SurfaceData {
|
||||
private static boolean isGradShaderEnabled;
|
||||
|
||||
private OGLGraphicsConfig graphicsConfig;
|
||||
private int textureTarget;
|
||||
protected int type;
|
||||
// these fields are set from the native code when the surface is
|
||||
// initialized
|
||||
private int nativeWidth, nativeHeight;
|
||||
|
||||
protected static OGLRenderer oglRenderPipe;
|
||||
protected static PixelToShapeConverter oglTxRenderPipe;
|
||||
protected static PixelToParallelogramConverter oglTxRenderPipe;
|
||||
protected static ParallelogramPipe oglAAPgramPipe;
|
||||
protected static OGLTextRenderer oglTextPipe;
|
||||
protected static OGLDrawImage oglImagePipe;
|
||||
|
||||
@ -170,6 +175,7 @@ public abstract class OGLSurfaceData extends SurfaceData {
|
||||
int width, int height);
|
||||
|
||||
private native int getTextureTarget(long pData);
|
||||
private native int getTextureID(long pData);
|
||||
|
||||
static {
|
||||
if (!GraphicsEnvironment.isHeadless()) {
|
||||
@ -203,9 +209,14 @@ public abstract class OGLSurfaceData extends SurfaceData {
|
||||
oglRenderPipe = new OGLRenderer(rq);
|
||||
if (GraphicsPrimitive.tracingEnabled()) {
|
||||
oglTextPipe = oglTextPipe.traceWrap();
|
||||
oglRenderPipe = oglRenderPipe.traceWrap();
|
||||
//The wrapped oglRenderPipe will wrap the AA pipe as well...
|
||||
//oglAAPgramPipe = oglRenderPipe.traceWrap();
|
||||
}
|
||||
oglTxRenderPipe = new PixelToShapeConverter(oglRenderPipe);
|
||||
oglAAPgramPipe = oglRenderPipe.getAAParallelogramPipe();
|
||||
oglTxRenderPipe =
|
||||
new PixelToParallelogramConverter(oglRenderPipe,
|
||||
oglRenderPipe,
|
||||
1.0, 0.25, true);
|
||||
|
||||
OGLBlitLoops.register();
|
||||
OGLMaskFill.register();
|
||||
@ -282,9 +293,7 @@ public abstract class OGLSurfaceData extends SurfaceData {
|
||||
break;
|
||||
}
|
||||
|
||||
if (success) {
|
||||
textureTarget = getTextureTarget(getNativeOps());
|
||||
} else {
|
||||
if (!success) {
|
||||
throw new OutOfMemoryError("can't create offscreen surface");
|
||||
}
|
||||
}
|
||||
@ -323,7 +332,7 @@ public abstract class OGLSurfaceData extends SurfaceData {
|
||||
* Returns the OGLContext for the GraphicsConfig associated with this
|
||||
* surface.
|
||||
*/
|
||||
final OGLContext getContext() {
|
||||
public final OGLContext getContext() {
|
||||
return graphicsConfig.getContext();
|
||||
}
|
||||
|
||||
@ -337,7 +346,7 @@ public abstract class OGLSurfaceData extends SurfaceData {
|
||||
/**
|
||||
* Returns one of the surface type constants defined above.
|
||||
*/
|
||||
final int getType() {
|
||||
public final int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@ -346,8 +355,41 @@ public abstract class OGLSurfaceData extends SurfaceData {
|
||||
* for that texture (either GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE_ARB).
|
||||
* Otherwise, this method will return zero.
|
||||
*/
|
||||
final int getTextureTarget() {
|
||||
return textureTarget;
|
||||
public final int getTextureTarget() {
|
||||
return getTextureTarget(getNativeOps());
|
||||
}
|
||||
|
||||
/**
|
||||
* If this surface is backed by a texture object, returns the texture ID
|
||||
* for that texture.
|
||||
* Otherwise, this method will return zero.
|
||||
*/
|
||||
public final int getTextureID() {
|
||||
return getTextureID(getNativeOps());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns native resource of specified {@code resType} associated with
|
||||
* this surface.
|
||||
*
|
||||
* Specifically, for {@code OGLSurfaceData} this method returns the
|
||||
* the following:
|
||||
* <pre>
|
||||
* TEXTURE - texture id
|
||||
* </pre>
|
||||
*
|
||||
* Note: the resource returned by this method is only valid on the rendering
|
||||
* thread.
|
||||
*
|
||||
* @return native resource of specified type or 0L if
|
||||
* such resource doesn't exist or can not be retrieved.
|
||||
* @see sun.java2d.pipe.hw.AccelSurface#getNativeResource
|
||||
*/
|
||||
public long getNativeResource(int resType) {
|
||||
if (resType == TEXTURE) {
|
||||
return getTextureID();
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
public Raster getRaster(int x, int y, int w, int h) {
|
||||
@ -366,7 +408,7 @@ public abstract class OGLSurfaceData extends SurfaceData {
|
||||
*/
|
||||
public boolean canRenderLCDText(SunGraphics2D sg2d) {
|
||||
return
|
||||
graphicsConfig.isCapPresent(OGLContext.CAPS_EXT_LCD_SHADER) &&
|
||||
graphicsConfig.isCapPresent(CAPS_EXT_LCD_SHADER) &&
|
||||
sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY &&
|
||||
sg2d.paintState <= SunGraphics2D.PAINT_OPAQUECOLOR;
|
||||
}
|
||||
@ -405,7 +447,7 @@ public abstract class OGLSurfaceData extends SurfaceData {
|
||||
validated = true;
|
||||
}
|
||||
|
||||
PixelToShapeConverter txPipe = null;
|
||||
PixelToParallelogramConverter txPipe = null;
|
||||
OGLRenderer nonTxPipe = null;
|
||||
|
||||
if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON) {
|
||||
@ -422,12 +464,28 @@ public abstract class OGLSurfaceData extends SurfaceData {
|
||||
// custom paints handled by super.validatePipe() below
|
||||
}
|
||||
} else {
|
||||
if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR &&
|
||||
sg2d.compositeState == sg2d.COMP_XOR)
|
||||
{
|
||||
// install the solid pipes when AA and XOR are both enabled
|
||||
txPipe = oglTxRenderPipe;
|
||||
nonTxPipe = oglRenderPipe;
|
||||
if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR) {
|
||||
if (graphicsConfig.isCapPresent(CAPS_PS30) &&
|
||||
(sg2d.imageComp == CompositeType.SrcOverNoEa ||
|
||||
sg2d.imageComp == CompositeType.SrcOver))
|
||||
{
|
||||
if (!validated) {
|
||||
super.validatePipe(sg2d);
|
||||
validated = true;
|
||||
}
|
||||
PixelToParallelogramConverter aaConverter =
|
||||
new PixelToParallelogramConverter(sg2d.shapepipe,
|
||||
oglAAPgramPipe,
|
||||
1.0/8.0, 0.499,
|
||||
false);
|
||||
sg2d.drawpipe = aaConverter;
|
||||
sg2d.fillpipe = aaConverter;
|
||||
sg2d.shapepipe = aaConverter;
|
||||
} else if (sg2d.compositeState == sg2d.COMP_XOR) {
|
||||
// install the solid pipes when AA and XOR are both enabled
|
||||
txPipe = oglTxRenderPipe;
|
||||
nonTxPipe = oglRenderPipe;
|
||||
}
|
||||
}
|
||||
// other cases handled by super.validatePipe() below
|
||||
}
|
||||
@ -443,7 +501,11 @@ public abstract class OGLSurfaceData extends SurfaceData {
|
||||
sg2d.drawpipe = nonTxPipe;
|
||||
sg2d.fillpipe = nonTxPipe;
|
||||
}
|
||||
sg2d.shapepipe = nonTxPipe;
|
||||
// Note that we use the transforming pipe here because it
|
||||
// will examine the shape and possibly perform an optimized
|
||||
// operation if it can be simplified. The simplifications
|
||||
// will be valid for all STROKE and TRANSFORM types.
|
||||
sg2d.shapepipe = txPipe;
|
||||
} else {
|
||||
if (!validated) {
|
||||
super.validatePipe(sg2d);
|
||||
@ -472,7 +534,7 @@ public abstract class OGLSurfaceData extends SurfaceData {
|
||||
* validation code will choose a more general software-based loop.
|
||||
*/
|
||||
if (!OGLPaints.isValid(sg2d) ||
|
||||
!graphicsConfig.isCapPresent(CAPS_EXT_MULTITEXTURE))
|
||||
!graphicsConfig.isCapPresent(CAPS_MULTITEXTURE))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@ -564,7 +626,7 @@ public abstract class OGLSurfaceData extends SurfaceData {
|
||||
* when using the basic GL_TEXTURE_2D target.
|
||||
*/
|
||||
boolean isTexNonPow2Available() {
|
||||
return graphicsConfig.isCapPresent(OGLContext.CAPS_EXT_TEXNONPOW2);
|
||||
return graphicsConfig.isCapPresent(CAPS_TEXNONPOW2);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -573,6 +635,16 @@ public abstract class OGLSurfaceData extends SurfaceData {
|
||||
* GL_ARB_texture_rectangle extension is present).
|
||||
*/
|
||||
boolean isTexRectAvailable() {
|
||||
return graphicsConfig.isCapPresent(OGLContext.CAPS_EXT_TEXRECT);
|
||||
return graphicsConfig.isCapPresent(CAPS_EXT_TEXRECT);
|
||||
}
|
||||
|
||||
public Rectangle getNativeBounds() {
|
||||
OGLRenderQueue rq = OGLRenderQueue.getInstance();
|
||||
rq.lock();
|
||||
try {
|
||||
return new Rectangle(nativeWidth, nativeHeight);
|
||||
} finally {
|
||||
rq.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,12 +26,13 @@
|
||||
package sun.java2d.pipe;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Paint;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import sun.java2d.pipe.hw.AccelSurface;
|
||||
import sun.java2d.InvalidPipeException;
|
||||
import sun.java2d.SunGraphics2D;
|
||||
import sun.java2d.SurfaceData;
|
||||
import sun.java2d.loops.XORComposite;
|
||||
import static sun.java2d.pipe.BufferedOpCodes.*;
|
||||
import static sun.java2d.pipe.BufferedRenderPipe.BYTES_PER_SPAN;
|
||||
@ -43,8 +44,10 @@ import static sun.java2d.pipe.BufferedRenderPipe.BYTES_PER_SPAN;
|
||||
* single thread. Note that the RenderQueue lock must be acquired before
|
||||
* calling the validate() method (or any other method in this class). See
|
||||
* the RenderQueue class comments for a sample usage scenario.
|
||||
*
|
||||
* @see RenderQueue
|
||||
*/
|
||||
public class BufferedContext {
|
||||
public abstract class BufferedContext {
|
||||
|
||||
/*
|
||||
* The following flags help the internals of validate() determine
|
||||
@ -82,19 +85,66 @@ public class BufferedContext {
|
||||
*/
|
||||
protected static BufferedContext currentContext;
|
||||
|
||||
private SurfaceData validatedSrcData;
|
||||
private SurfaceData validatedDstData;
|
||||
private AccelSurface validatedSrcData;
|
||||
private AccelSurface validatedDstData;
|
||||
private Region validatedClip;
|
||||
private Composite validatedComp;
|
||||
private Paint validatedPaint;
|
||||
private boolean isValidatedPaintAColor;
|
||||
private int validatedRGB;
|
||||
private int validatedFlags;
|
||||
private boolean xformInUse;
|
||||
private int transX;
|
||||
private int transY;
|
||||
|
||||
protected BufferedContext(RenderQueue rq) {
|
||||
this.rq = rq;
|
||||
this.buf = rq.getBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the BufferedContextContext associated with the dst. surface
|
||||
* and validates the context using the given parameters. Most rendering
|
||||
* operations will call this method first in order to set the necessary
|
||||
* state before issuing rendering commands.
|
||||
*
|
||||
* Note: must be called while the RenderQueue lock is held.
|
||||
*
|
||||
* @throws InvalidPipeException if either src or dest surface is not valid
|
||||
* or lost
|
||||
* @see RenderQueue#lock
|
||||
* @see RenderQueue#unlock
|
||||
*/
|
||||
public static void validateContext(AccelSurface srcData,
|
||||
AccelSurface dstData,
|
||||
Region clip, Composite comp,
|
||||
AffineTransform xform,
|
||||
Paint paint, SunGraphics2D sg2d,
|
||||
int flags)
|
||||
{
|
||||
// assert rq.lock.isHeldByCurrentThread();
|
||||
BufferedContext d3dc = dstData.getContext();
|
||||
d3dc.validate(srcData, dstData,
|
||||
clip, comp, xform, paint, sg2d, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the BufferedContextassociated with the surface
|
||||
* and disables all context state settings.
|
||||
*
|
||||
* Note: must be called while the RenderQueue lock is held.
|
||||
*
|
||||
* @throws InvalidPipeException if the surface is not valid
|
||||
* or lost
|
||||
* @see RenderQueue#lock
|
||||
* @see RenderQueue#unlock
|
||||
*/
|
||||
public static void validateContext(AccelSurface surface) {
|
||||
// assert rt.lock.isHeldByCurrentThread();
|
||||
validateContext(surface, surface,
|
||||
null, null, null, null, null, NO_CONTEXT_FLAGS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the given parameters against the current state for this
|
||||
* context. If this context is not current, it will be made current
|
||||
@ -106,19 +156,47 @@ public class BufferedContext {
|
||||
* Note that the SunGraphics2D parameter is only used for the purposes
|
||||
* of validating a (non-null) Paint parameter. In all other cases it
|
||||
* is safe to pass a null SunGraphics2D and it will be ignored.
|
||||
*
|
||||
* Note: must be called while the RenderQueue lock is held.
|
||||
*
|
||||
* @throws InvalidPipeException if either src or dest surface is not valid
|
||||
* or lost
|
||||
*/
|
||||
public void validate(SurfaceData srcData, SurfaceData dstData,
|
||||
public void validate(AccelSurface srcData, AccelSurface dstData,
|
||||
Region clip, Composite comp,
|
||||
AffineTransform xform,
|
||||
Paint paint, SunGraphics2D sg2d, int flags)
|
||||
{
|
||||
// assert rq.lock.isHeldByCurrentThread();
|
||||
|
||||
boolean updateClip = (clip != validatedClip);
|
||||
boolean updatePaint = (paint != validatedPaint);
|
||||
boolean updateClip = false;
|
||||
boolean updatePaint = false;
|
||||
|
||||
if (!dstData.isValid()) {
|
||||
throw new InvalidPipeException("bounds changed");
|
||||
if (!dstData.isValid() ||
|
||||
dstData.isSurfaceLost() || srcData.isSurfaceLost())
|
||||
{
|
||||
invalidateContext();
|
||||
throw new InvalidPipeException("bounds changed or surface lost");
|
||||
}
|
||||
|
||||
if (paint instanceof Color) {
|
||||
// REMIND: not 30-bit friendly
|
||||
int newRGB = ((Color)paint).getRGB();
|
||||
if (isValidatedPaintAColor) {
|
||||
if (newRGB != validatedRGB) {
|
||||
validatedRGB = newRGB;
|
||||
updatePaint = true;
|
||||
}
|
||||
} else {
|
||||
validatedRGB = newRGB;
|
||||
updatePaint = true;
|
||||
isValidatedPaintAColor = true;
|
||||
}
|
||||
} else if (validatedPaint != paint) {
|
||||
updatePaint = true;
|
||||
// this should be set when we are switching from paint to color
|
||||
// in which case this condition will be true
|
||||
isValidatedPaintAColor = false;
|
||||
}
|
||||
|
||||
if ((currentContext != this) ||
|
||||
@ -147,9 +225,18 @@ public class BufferedContext {
|
||||
}
|
||||
|
||||
// validate clip
|
||||
if (updateClip) {
|
||||
if ((clip != validatedClip) || updateClip) {
|
||||
if (clip != null) {
|
||||
setClip(clip);
|
||||
if (updateClip ||
|
||||
validatedClip == null ||
|
||||
!(validatedClip.isRectangular() && clip.isRectangular()) ||
|
||||
((clip.getLoX() != validatedClip.getLoX() ||
|
||||
clip.getLoY() != validatedClip.getLoY() ||
|
||||
clip.getHiX() != validatedClip.getHiX() ||
|
||||
clip.getHiY() != validatedClip.getHiY())))
|
||||
{
|
||||
setClip(clip);
|
||||
}
|
||||
} else {
|
||||
resetClip();
|
||||
}
|
||||
@ -173,14 +260,29 @@ public class BufferedContext {
|
||||
}
|
||||
|
||||
// validate transform
|
||||
boolean txChanged = false;
|
||||
if (xform == null) {
|
||||
if (xformInUse) {
|
||||
resetTransform();
|
||||
xformInUse = false;
|
||||
txChanged = true;
|
||||
} else if (sg2d != null) {
|
||||
if (transX != sg2d.transX || transY != sg2d.transY) {
|
||||
txChanged = true;
|
||||
}
|
||||
}
|
||||
if (sg2d != null) {
|
||||
transX = sg2d.transX;
|
||||
transY = sg2d.transY;
|
||||
}
|
||||
} else {
|
||||
setTransform(xform);
|
||||
xformInUse = true;
|
||||
txChanged = true;
|
||||
}
|
||||
// non-Color paints may require paint revalidation
|
||||
if (!isValidatedPaintAColor && txChanged) {
|
||||
updatePaint = true;
|
||||
}
|
||||
|
||||
// validate paint
|
||||
@ -194,6 +296,7 @@ public class BufferedContext {
|
||||
}
|
||||
|
||||
// mark dstData dirty
|
||||
// REMIND: is this really needed now? we do it in SunGraphics2D..
|
||||
dstData.markDirty();
|
||||
}
|
||||
|
||||
@ -201,13 +304,20 @@ public class BufferedContext {
|
||||
* Invalidates the surfaces associated with this context. This is
|
||||
* useful when the context is no longer needed, and we want to break
|
||||
* the chain caused by these surface references.
|
||||
*
|
||||
* Note: must be called while the RenderQueue lock is held.
|
||||
*
|
||||
* @see RenderQueue#lock
|
||||
* @see RenderQueue#unlock
|
||||
*/
|
||||
public void invalidateSurfaces() {
|
||||
validatedSrcData = null;
|
||||
validatedDstData = null;
|
||||
}
|
||||
|
||||
private void setSurfaces(SurfaceData srcData, SurfaceData dstData) {
|
||||
private void setSurfaces(AccelSurface srcData,
|
||||
AccelSurface dstData)
|
||||
{
|
||||
// assert rq.lock.isHeldByCurrentThread();
|
||||
rq.ensureCapacityAndAlignment(20, 4);
|
||||
buf.putInt(SET_SURFACES);
|
||||
@ -304,4 +414,54 @@ public class BufferedContext {
|
||||
buf.putDouble(xform.getTranslateX());
|
||||
buf.putDouble(xform.getTranslateY());
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets this context's surfaces and all attributes.
|
||||
*
|
||||
* Note: must be called while the RenderQueue lock is held.
|
||||
*
|
||||
* @see RenderQueue#lock
|
||||
* @see RenderQueue#unlock
|
||||
*/
|
||||
public void invalidateContext() {
|
||||
resetTransform();
|
||||
resetComposite();
|
||||
resetClip();
|
||||
invalidateSurfaces();
|
||||
validatedComp = null;
|
||||
validatedClip = null;
|
||||
validatedPaint = null;
|
||||
xformInUse = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a singleton {@code RenderQueue} object used by the rendering
|
||||
* pipeline.
|
||||
*
|
||||
* @return a render queue
|
||||
* @see RenderQueue
|
||||
*/
|
||||
public abstract RenderQueue getRenderQueue();
|
||||
|
||||
/**
|
||||
* Saves the the state of this context.
|
||||
* It may reset the current context.
|
||||
*
|
||||
* Note: must be called while the RenderQueue lock is held.
|
||||
*
|
||||
* @see RenderQueue#lock
|
||||
* @see RenderQueue#unlock
|
||||
*/
|
||||
public abstract void saveState();
|
||||
|
||||
/**
|
||||
* Restores the native state of this context.
|
||||
* It may reset the current context.
|
||||
*
|
||||
* Note: must be called while the RenderQueue lock is held.
|
||||
*
|
||||
* @see RenderQueue#lock
|
||||
* @see RenderQueue#unlock
|
||||
*/
|
||||
public abstract void restoreState();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -32,10 +32,14 @@ public class BufferedOpCodes {
|
||||
public static final int DRAW_POLY = 12;
|
||||
public static final int DRAW_PIXEL = 13;
|
||||
public static final int DRAW_SCANLINES = 14;
|
||||
public static final int DRAW_PARALLELOGRAM = 15;
|
||||
public static final int DRAW_AAPARALLELOGRAM = 16;
|
||||
|
||||
// fill ops
|
||||
public static final int FILL_RECT = 20;
|
||||
public static final int FILL_SPANS = 21;
|
||||
public static final int FILL_PARALLELOGRAM = 22;
|
||||
public static final int FILL_AAPARALLELOGRAM = 23;
|
||||
|
||||
// copy-related ops
|
||||
public static final int COPY_AREA = 30;
|
||||
@ -67,6 +71,9 @@ public class BufferedOpCodes {
|
||||
public static final int DISPOSE_CONFIG = 74;
|
||||
public static final int INVALIDATE_CONTEXT = 75;
|
||||
public static final int SYNC = 76;
|
||||
public static final int RESTORE_DEVICES = 77;
|
||||
public static final int SAVE_STATE = 78;
|
||||
public static final int RESTORE_STATE = 79;
|
||||
|
||||
// multibuffering ops
|
||||
public static final int SWAP_BUFFERS = 80;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,7 @@
|
||||
|
||||
package sun.java2d.pipe;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Polygon;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.AffineTransform;
|
||||
@ -33,6 +34,7 @@ import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.Path2D;
|
||||
import java.awt.geom.IllegalPathStateException;
|
||||
import java.awt.geom.PathIterator;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
import sun.java2d.SunGraphics2D;
|
||||
import sun.java2d.loops.ProcessPath;
|
||||
@ -51,8 +53,10 @@ import static sun.java2d.pipe.BufferedOpCodes.*;
|
||||
* simply delegate to draw(Shape) and fill(Shape), respectively.
|
||||
*/
|
||||
public abstract class BufferedRenderPipe
|
||||
implements PixelDrawPipe, PixelFillPipe, ShapeDrawPipe
|
||||
implements PixelDrawPipe, PixelFillPipe, ShapeDrawPipe, ParallelogramPipe
|
||||
{
|
||||
ParallelogramPipe aapgrampipe = new AAParallelogramPipe();
|
||||
|
||||
static final int BYTES_PER_POLY_POINT = 8;
|
||||
static final int BYTES_PER_SCANLINE = 12;
|
||||
static final int BYTES_PER_SPAN = 16;
|
||||
@ -67,12 +71,17 @@ public abstract class BufferedRenderPipe
|
||||
this.drawHandler = new BufferedDrawHandler();
|
||||
}
|
||||
|
||||
public ParallelogramPipe getAAParallelogramPipe() {
|
||||
return aapgrampipe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the state in the provided SunGraphics2D object and sets up
|
||||
* any special resources for this operation (e.g. enabling gradient
|
||||
* shading).
|
||||
*/
|
||||
protected abstract void validateContext(SunGraphics2D sg2d);
|
||||
protected abstract void validateContextAA(SunGraphics2D sg2d);
|
||||
|
||||
public void drawLine(SunGraphics2D sg2d,
|
||||
int x1, int y1, int x2, int y2)
|
||||
@ -398,6 +407,98 @@ public abstract class BufferedRenderPipe
|
||||
}
|
||||
}
|
||||
|
||||
public void fillParallelogram(SunGraphics2D sg2d,
|
||||
double x, double y,
|
||||
double dx1, double dy1,
|
||||
double dx2, double dy2)
|
||||
{
|
||||
rq.lock();
|
||||
try {
|
||||
validateContext(sg2d);
|
||||
rq.ensureCapacity(28);
|
||||
buf.putInt(FILL_PARALLELOGRAM);
|
||||
buf.putFloat((float) x);
|
||||
buf.putFloat((float) y);
|
||||
buf.putFloat((float) dx1);
|
||||
buf.putFloat((float) dy1);
|
||||
buf.putFloat((float) dx2);
|
||||
buf.putFloat((float) dy2);
|
||||
} finally {
|
||||
rq.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void drawParallelogram(SunGraphics2D sg2d,
|
||||
double x, double y,
|
||||
double dx1, double dy1,
|
||||
double dx2, double dy2,
|
||||
double lw1, double lw2)
|
||||
{
|
||||
rq.lock();
|
||||
try {
|
||||
validateContext(sg2d);
|
||||
rq.ensureCapacity(36);
|
||||
buf.putInt(DRAW_PARALLELOGRAM);
|
||||
buf.putFloat((float) x);
|
||||
buf.putFloat((float) y);
|
||||
buf.putFloat((float) dx1);
|
||||
buf.putFloat((float) dy1);
|
||||
buf.putFloat((float) dx2);
|
||||
buf.putFloat((float) dy2);
|
||||
buf.putFloat((float) lw1);
|
||||
buf.putFloat((float) lw2);
|
||||
} finally {
|
||||
rq.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private class AAParallelogramPipe implements ParallelogramPipe {
|
||||
public void fillParallelogram(SunGraphics2D sg2d,
|
||||
double x, double y,
|
||||
double dx1, double dy1,
|
||||
double dx2, double dy2)
|
||||
{
|
||||
rq.lock();
|
||||
try {
|
||||
validateContextAA(sg2d);
|
||||
rq.ensureCapacity(28);
|
||||
buf.putInt(FILL_AAPARALLELOGRAM);
|
||||
buf.putFloat((float) x);
|
||||
buf.putFloat((float) y);
|
||||
buf.putFloat((float) dx1);
|
||||
buf.putFloat((float) dy1);
|
||||
buf.putFloat((float) dx2);
|
||||
buf.putFloat((float) dy2);
|
||||
} finally {
|
||||
rq.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void drawParallelogram(SunGraphics2D sg2d,
|
||||
double x, double y,
|
||||
double dx1, double dy1,
|
||||
double dx2, double dy2,
|
||||
double lw1, double lw2)
|
||||
{
|
||||
rq.lock();
|
||||
try {
|
||||
validateContextAA(sg2d);
|
||||
rq.ensureCapacity(36);
|
||||
buf.putInt(DRAW_AAPARALLELOGRAM);
|
||||
buf.putFloat((float) x);
|
||||
buf.putFloat((float) y);
|
||||
buf.putFloat((float) dx1);
|
||||
buf.putFloat((float) dy1);
|
||||
buf.putFloat((float) dx2);
|
||||
buf.putFloat((float) dy2);
|
||||
buf.putFloat((float) lw1);
|
||||
buf.putFloat((float) lw2);
|
||||
} finally {
|
||||
rq.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void draw(SunGraphics2D sg2d, Shape s) {
|
||||
if (sg2d.strokeState == sg2d.STROKE_THIN) {
|
||||
if (s instanceof Polygon) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -955,7 +955,7 @@ public class DrawImage implements DrawImagePipe
|
||||
} else {
|
||||
BlitBg blit = BlitBg.getFromCache(srcType, comp, dstType);
|
||||
blit.BlitBg(srcData, dstData, sg.composite, clipRegion,
|
||||
bgColor, sx, sy, dx, dy, w, h);
|
||||
bgColor.getRGB(), sx, sy, dx, dy, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
|
66
jdk/src/share/classes/sun/java2d/pipe/ParallelogramPipe.java
Normal file
66
jdk/src/share/classes/sun/java2d/pipe/ParallelogramPipe.java
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package sun.java2d.pipe;
|
||||
|
||||
import sun.java2d.SunGraphics2D;
|
||||
|
||||
/**
|
||||
* This interface defines the set of calls that pipeline objects
|
||||
* can use to pass on responsibility for drawing arbitrary
|
||||
* parallelogram shapes.
|
||||
* Six floating point numbers are provided and the parallelogram
|
||||
* is defined as the quadrilateral with the following vertices:
|
||||
* <pre>
|
||||
* origin: (x, y)
|
||||
* => (x+dx1, y+dy1)
|
||||
* => (x+dx1+dx2, y+dy1+dy2)
|
||||
* => (x+dx2, y+dy2)
|
||||
* => origin
|
||||
* </pre>
|
||||
*/
|
||||
public interface ParallelogramPipe {
|
||||
public void fillParallelogram(SunGraphics2D sg,
|
||||
double x, double y,
|
||||
double dx1, double dy1,
|
||||
double dx2, double dy2);
|
||||
|
||||
/**
|
||||
* Draw a Parallelogram with the indicated line widths
|
||||
* assuming a standard BasicStroke with MITER joins.
|
||||
* lw1 specifies the width of the stroke along the dx1,dy1
|
||||
* vector and lw2 specifies the width of the stroke along
|
||||
* the dx2,dy2 vector.
|
||||
* This is equivalent to outsetting the indicated
|
||||
* parallelogram by lw/2 pixels, then insetting the
|
||||
* same parallelogram by lw/2 pixels and filling the
|
||||
* difference between the outer and inner parallelograms.
|
||||
*/
|
||||
public void drawParallelogram(SunGraphics2D sg,
|
||||
double x, double y,
|
||||
double dx1, double dy1,
|
||||
double dx2, double dy2,
|
||||
double lw1, double lw2);
|
||||
}
|
@ -0,0 +1,417 @@
|
||||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package sun.java2d.pipe;
|
||||
|
||||
import java.awt.Shape;
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.geom.Line2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import sun.java2d.SunGraphics2D;
|
||||
import sun.awt.SunHints;
|
||||
|
||||
/**
|
||||
* This class converts calls to the basic pixel rendering methods
|
||||
* into calls to the methods on a ParallelogramPipe.
|
||||
* Most calls are transformed into calls to the fill(Shape) method
|
||||
* by the parent PixelToShapeConverter class, but some calls are
|
||||
* transformed into calls to fill/drawParallelogram().
|
||||
*/
|
||||
public class PixelToParallelogramConverter extends PixelToShapeConverter
|
||||
implements ShapeDrawPipe
|
||||
{
|
||||
ParallelogramPipe outrenderer;
|
||||
double minPenSize;
|
||||
double normPosition;
|
||||
double normRoundingBias;
|
||||
boolean adjustfill;
|
||||
|
||||
/**
|
||||
* @param shapepipe pipeline to forward shape calls to
|
||||
* @param pgrampipe pipeline to forward parallelogram calls to
|
||||
* (and drawLine calls if possible)
|
||||
* @param minPenSize minimum pen size for dropout control
|
||||
* @param normPosition sub-pixel location to normalize endpoints
|
||||
* for STROKE_NORMALIZE cases
|
||||
* @param adjustFill boolean to control whethere normalization
|
||||
* constants are also applied to fill operations
|
||||
* (normally true for non-AA, false for AA)
|
||||
*/
|
||||
public PixelToParallelogramConverter(ShapeDrawPipe shapepipe,
|
||||
ParallelogramPipe pgrampipe,
|
||||
double minPenSize,
|
||||
double normPosition,
|
||||
boolean adjustfill)
|
||||
{
|
||||
super(shapepipe);
|
||||
outrenderer = pgrampipe;
|
||||
this.minPenSize = minPenSize;
|
||||
this.normPosition = normPosition;
|
||||
this.normRoundingBias = 0.5 - normPosition;
|
||||
this.adjustfill = adjustfill;
|
||||
}
|
||||
|
||||
public void drawLine(SunGraphics2D sg2d,
|
||||
int x1, int y1, int x2, int y2)
|
||||
{
|
||||
if (!drawGeneralLine(sg2d, x1, y1, x2, y2)) {
|
||||
super.drawLine(sg2d, x1, y1, x2, y2);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawRect(SunGraphics2D sg2d,
|
||||
int x, int y, int w, int h)
|
||||
{
|
||||
if (w >= 0 && h >= 0) {
|
||||
if (sg2d.strokeState < SunGraphics2D.STROKE_CUSTOM) {
|
||||
BasicStroke bs = ((BasicStroke) sg2d.stroke);
|
||||
if (w > 0 && h > 0) {
|
||||
if (bs.getLineJoin() == BasicStroke.JOIN_MITER &&
|
||||
bs.getDashArray() == null)
|
||||
{
|
||||
double lw = bs.getLineWidth();
|
||||
drawRectangle(sg2d, x, y, w, h, lw);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Note: This calls the integer version which
|
||||
// will verify that the local drawLine optimizations
|
||||
// work and call super.drawLine(), if not.
|
||||
drawLine(sg2d, x, y, x+w, y+h);
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.drawRect(sg2d, x, y, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
public void fillRect(SunGraphics2D sg2d,
|
||||
int x, int y, int w, int h)
|
||||
{
|
||||
if (w > 0 && h > 0) {
|
||||
fillRectangle(sg2d, x, y, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
public void draw(SunGraphics2D sg2d, Shape s) {
|
||||
if (sg2d.strokeState < SunGraphics2D.STROKE_CUSTOM) {
|
||||
BasicStroke bs = ((BasicStroke) sg2d.stroke);
|
||||
if (s instanceof Rectangle2D) {
|
||||
if (bs.getLineJoin() == BasicStroke.JOIN_MITER &&
|
||||
bs.getDashArray() == null)
|
||||
{
|
||||
Rectangle2D r2d = (Rectangle2D) s;
|
||||
double w = r2d.getWidth();
|
||||
double h = r2d.getHeight();
|
||||
double x = r2d.getX();
|
||||
double y = r2d.getY();
|
||||
if (w >= 0 && h >= 0) {
|
||||
double lw = bs.getLineWidth();
|
||||
drawRectangle(sg2d, x, y, w, h, lw);
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else if (s instanceof Line2D) {
|
||||
Line2D l2d = (Line2D) s;
|
||||
if (drawGeneralLine(sg2d,
|
||||
l2d.getX1(), l2d.getY1(),
|
||||
l2d.getX2(), l2d.getY2()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
outpipe.draw(sg2d, s);
|
||||
}
|
||||
|
||||
public void fill(SunGraphics2D sg2d, Shape s) {
|
||||
if (s instanceof Rectangle2D) {
|
||||
Rectangle2D r2d = (Rectangle2D) s;
|
||||
double w = r2d.getWidth();
|
||||
double h = r2d.getHeight();
|
||||
if (w > 0 && h > 0) {
|
||||
double x = r2d.getX();
|
||||
double y = r2d.getY();
|
||||
fillRectangle(sg2d, x, y, w, h);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
outpipe.fill(sg2d, s);
|
||||
}
|
||||
|
||||
static double len(double x, double y) {
|
||||
return ((x == 0) ? Math.abs(y)
|
||||
: ((y == 0) ? Math.abs(x)
|
||||
: Math.sqrt(x * x + y * y)));
|
||||
}
|
||||
|
||||
double normalize(double v) {
|
||||
return Math.floor(v + normRoundingBias) + normPosition;
|
||||
}
|
||||
|
||||
public boolean drawGeneralLine(SunGraphics2D sg2d,
|
||||
double x1, double y1,
|
||||
double x2, double y2)
|
||||
{
|
||||
if (sg2d.strokeState == SunGraphics2D.STROKE_CUSTOM ||
|
||||
sg2d.strokeState == SunGraphics2D.STROKE_THINDASHED)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
BasicStroke bs = (BasicStroke) sg2d.stroke;
|
||||
int cap = bs.getEndCap();
|
||||
if (cap == BasicStroke.CAP_ROUND || bs.getDashArray() != null) {
|
||||
// TODO: we could construct the GeneralPath directly
|
||||
// for CAP_ROUND and save a lot of processing in that case...
|
||||
// And again, we would need to deal with dropout control...
|
||||
return false;
|
||||
}
|
||||
double lw = bs.getLineWidth();
|
||||
// Save the original dx, dy in case we need it to transform
|
||||
// the linewidth as a perpendicular vector below
|
||||
double dx = x2 - x1;
|
||||
double dy = y2 - y1;
|
||||
switch (sg2d.transformState) {
|
||||
case SunGraphics2D.TRANSFORM_GENERIC:
|
||||
case SunGraphics2D.TRANSFORM_TRANSLATESCALE:
|
||||
{
|
||||
double coords[] = {x1, y1, x2, y2};
|
||||
sg2d.transform.transform(coords, 0, coords, 0, 2);
|
||||
x1 = coords[0];
|
||||
y1 = coords[1];
|
||||
x2 = coords[2];
|
||||
y2 = coords[3];
|
||||
}
|
||||
break;
|
||||
case SunGraphics2D.TRANSFORM_ANY_TRANSLATE:
|
||||
case SunGraphics2D.TRANSFORM_INT_TRANSLATE:
|
||||
{
|
||||
double tx = sg2d.transform.getTranslateX();
|
||||
double ty = sg2d.transform.getTranslateY();
|
||||
x1 += tx;
|
||||
y1 += ty;
|
||||
x2 += tx;
|
||||
y2 += ty;
|
||||
}
|
||||
break;
|
||||
case SunGraphics2D.TRANSFORM_ISIDENT:
|
||||
break;
|
||||
default:
|
||||
throw new InternalError("unknown TRANSFORM state...");
|
||||
}
|
||||
if (sg2d.strokeHint != SunHints.INTVAL_STROKE_PURE) {
|
||||
if (sg2d.strokeState == SunGraphics2D.STROKE_THIN &&
|
||||
outrenderer instanceof PixelDrawPipe)
|
||||
{
|
||||
// PixelDrawPipes will add sg2d.transXY so we need to factor
|
||||
// that out...
|
||||
int ix1 = (int) Math.floor(x1 - sg2d.transX);
|
||||
int iy1 = (int) Math.floor(y1 - sg2d.transY);
|
||||
int ix2 = (int) Math.floor(x2 - sg2d.transX);
|
||||
int iy2 = (int) Math.floor(y2 - sg2d.transY);
|
||||
((PixelDrawPipe)outrenderer).drawLine(sg2d, ix1, iy1, ix2, iy2);
|
||||
return true;
|
||||
}
|
||||
x1 = normalize(x1);
|
||||
y1 = normalize(y1);
|
||||
x2 = normalize(x2);
|
||||
y2 = normalize(y2);
|
||||
}
|
||||
if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
|
||||
// Transform the linewidth...
|
||||
// calculate the scaling factor for a unit vector
|
||||
// perpendicular to the original user space line.
|
||||
double len = len(dx, dy);
|
||||
if (len == 0) {
|
||||
dx = len = 1;
|
||||
// dy = 0; already
|
||||
}
|
||||
// delta transform the transposed (90 degree rotated) unit vector
|
||||
double unitvector[] = {dy/len, -dx/len};
|
||||
sg2d.transform.deltaTransform(unitvector, 0, unitvector, 0, 1);
|
||||
lw *= len(unitvector[0], unitvector[1]);
|
||||
}
|
||||
lw = Math.max(lw, minPenSize);
|
||||
dx = x2 - x1;
|
||||
dy = y2 - y1;
|
||||
double len = len(dx, dy);
|
||||
double udx, udy;
|
||||
if (len == 0) {
|
||||
if (cap == BasicStroke.CAP_BUTT) {
|
||||
return true;
|
||||
}
|
||||
udx = lw;
|
||||
udy = 0;
|
||||
} else {
|
||||
udx = lw * dx / len;
|
||||
udy = lw * dy / len;
|
||||
}
|
||||
double px = x1 + udy / 2.0;
|
||||
double py = y1 - udx / 2.0;
|
||||
if (cap == BasicStroke.CAP_SQUARE) {
|
||||
px -= udx / 2.0;
|
||||
py -= udy / 2.0;
|
||||
dx += udx;
|
||||
dy += udy;
|
||||
}
|
||||
outrenderer.fillParallelogram(sg2d, px, py, -udy, udx, dx, dy);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void fillRectangle(SunGraphics2D sg2d,
|
||||
double rx, double ry,
|
||||
double rw, double rh)
|
||||
{
|
||||
double px, py;
|
||||
double dx1, dy1, dx2, dy2;
|
||||
AffineTransform txform = sg2d.transform;
|
||||
dx1 = txform.getScaleX();
|
||||
dy1 = txform.getShearY();
|
||||
dx2 = txform.getShearX();
|
||||
dy2 = txform.getScaleY();
|
||||
px = rx * dx1 + ry * dx2 + txform.getTranslateX();
|
||||
py = rx * dy1 + ry * dy2 + txform.getTranslateY();
|
||||
dx1 *= rw;
|
||||
dy1 *= rw;
|
||||
dx2 *= rh;
|
||||
dy2 *= rh;
|
||||
if (adjustfill &&
|
||||
sg2d.strokeState < SunGraphics2D.STROKE_CUSTOM &&
|
||||
sg2d.strokeHint != SunHints.INTVAL_STROKE_PURE)
|
||||
{
|
||||
double newx = normalize(px);
|
||||
double newy = normalize(py);
|
||||
dx1 = normalize(px + dx1) - newx;
|
||||
dy1 = normalize(py + dy1) - newy;
|
||||
dx2 = normalize(px + dx2) - newx;
|
||||
dy2 = normalize(py + dy2) - newy;
|
||||
px = newx;
|
||||
py = newy;
|
||||
}
|
||||
outrenderer.fillParallelogram(sg2d, px, py, dx1, dy1, dx2, dy2);
|
||||
}
|
||||
|
||||
public void drawRectangle(SunGraphics2D sg2d,
|
||||
double rx, double ry,
|
||||
double rw, double rh,
|
||||
double lw)
|
||||
{
|
||||
double px, py;
|
||||
double dx1, dy1, dx2, dy2;
|
||||
double lw1, lw2;
|
||||
AffineTransform txform = sg2d.transform;
|
||||
dx1 = txform.getScaleX();
|
||||
dy1 = txform.getShearY();
|
||||
dx2 = txform.getShearX();
|
||||
dy2 = txform.getScaleY();
|
||||
px = rx * dx1 + ry * dx2 + txform.getTranslateX();
|
||||
py = rx * dy1 + ry * dy2 + txform.getTranslateY();
|
||||
// lw along dx1,dy1 scale by transformed length of dx2,dy2 vectors
|
||||
// and vice versa
|
||||
lw1 = len(dx1, dy1) * lw;
|
||||
lw2 = len(dx2, dy2) * lw;
|
||||
dx1 *= rw;
|
||||
dy1 *= rw;
|
||||
dx2 *= rh;
|
||||
dy2 *= rh;
|
||||
if (sg2d.strokeState < SunGraphics2D.STROKE_CUSTOM &&
|
||||
sg2d.strokeHint != SunHints.INTVAL_STROKE_PURE)
|
||||
{
|
||||
double newx = normalize(px);
|
||||
double newy = normalize(py);
|
||||
dx1 = normalize(px + dx1) - newx;
|
||||
dy1 = normalize(py + dy1) - newy;
|
||||
dx2 = normalize(px + dx2) - newx;
|
||||
dy2 = normalize(py + dy2) - newy;
|
||||
px = newx;
|
||||
py = newy;
|
||||
}
|
||||
lw1 = Math.max(lw1, minPenSize);
|
||||
lw2 = Math.max(lw2, minPenSize);
|
||||
double len1 = len(dx1, dy1);
|
||||
double len2 = len(dx2, dy2);
|
||||
if (lw1 >= len1 || lw2 >= len2) {
|
||||
// The line widths are large enough to consume the
|
||||
// entire hole in the middle of the parallelogram
|
||||
// so we can just fill the outer parallelogram.
|
||||
fillOuterParallelogram(sg2d,
|
||||
px, py, dx1, dy1, dx2, dy2,
|
||||
len1, len2, lw1, lw2);
|
||||
} else {
|
||||
outrenderer.drawParallelogram(sg2d,
|
||||
px, py, dx1, dy1, dx2, dy2,
|
||||
lw1 / len1, lw2 / len2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This utility function handles the case where a drawRectangle
|
||||
* operation discovered that the interior hole in the rectangle
|
||||
* or parallelogram has been completely filled in by the stroke
|
||||
* width. It calculates the outer parallelogram of the stroke
|
||||
* and issues a single fillParallelogram request to fill it.
|
||||
*/
|
||||
public void fillOuterParallelogram(SunGraphics2D sg2d,
|
||||
double px, double py,
|
||||
double dx1, double dy1,
|
||||
double dx2, double dy2,
|
||||
double len1, double len2,
|
||||
double lw1, double lw2)
|
||||
{
|
||||
double udx1 = dx1 / len1;
|
||||
double udy1 = dy1 / len1;
|
||||
double udx2 = dx2 / len2;
|
||||
double udy2 = dy2 / len2;
|
||||
if (len1 == 0) {
|
||||
// len1 is 0, replace udxy1 with perpendicular of udxy2
|
||||
if (len2 == 0) {
|
||||
// both are 0, use a unit Y vector for udxy2
|
||||
udx2 = 0;
|
||||
udy2 = 1;
|
||||
}
|
||||
udx1 = udy2;
|
||||
udy1 = -udx2;
|
||||
} else if (len2 == 0) {
|
||||
// len2 is 0, replace udxy2 with perpendicular of udxy1
|
||||
udx2 = udy1;
|
||||
udy2 = -udx1;
|
||||
}
|
||||
udx1 *= lw1;
|
||||
udy1 *= lw1;
|
||||
udx2 *= lw2;
|
||||
udy2 *= lw2;
|
||||
px -= (udx1 + udx2) / 2;
|
||||
py -= (udy1 + udy2) / 2;
|
||||
dx1 += udx1;
|
||||
dy1 += udy1;
|
||||
dx2 += udx2;
|
||||
dy2 += udy2;
|
||||
|
||||
outrenderer.fillParallelogram(sg2d, px, py, dx1, dy1, dx2, dy2);
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package sun.java2d.pipe.hw;
|
||||
|
||||
/**
|
||||
* An interface for receiving notifications about imminent accelerated device's
|
||||
* events. Upon receiving such event appropriate actions can be taken (for
|
||||
* example, resources associated with the device can be freed).
|
||||
*/
|
||||
public interface AccelDeviceEventListener {
|
||||
/**
|
||||
* Called when the device is about to be reset.
|
||||
*
|
||||
* One must release all native resources associated with the device which
|
||||
* prevent the device from being reset (such as Default Pool resources for
|
||||
* the D3D pipeline).
|
||||
*
|
||||
* It is safe to remove the listener while in the call back.
|
||||
*
|
||||
* Note: this method is called on the rendering thread,
|
||||
* do not call into user code, do not take RQ lock!
|
||||
*/
|
||||
public void onDeviceReset();
|
||||
|
||||
/**
|
||||
* Called when the device is about to be disposed of.
|
||||
*
|
||||
* One must release all native resources associated with the device.
|
||||
*
|
||||
* It is safe to remove the listener while in the call back.
|
||||
*
|
||||
* Note: this method is called on the rendering thread,
|
||||
* do not call into user code, do not take RQ lock!
|
||||
*/
|
||||
public void onDeviceDispose();
|
||||
}
|
@ -0,0 +1,167 @@
|
||||
/*
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package sun.java2d.pipe.hw;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* This class is used to notify listeners about accelerated device's
|
||||
* events such as device reset or dispose that are about to occur.
|
||||
*/
|
||||
public class AccelDeviceEventNotifier {
|
||||
|
||||
private static AccelDeviceEventNotifier theInstance;
|
||||
|
||||
/**
|
||||
* A device is about to be reset. The listeners have to release all
|
||||
* resources associated with the device which are required for the device
|
||||
* to be reset.
|
||||
*/
|
||||
public static final int DEVICE_RESET = 0;
|
||||
|
||||
/**
|
||||
* A device is about to be disposed. The listeners have to release all
|
||||
* resources associated with the device.
|
||||
*/
|
||||
public static final int DEVICE_DISPOSED = 1;
|
||||
|
||||
private final Map<AccelDeviceEventListener, Integer> listeners;
|
||||
|
||||
private AccelDeviceEventNotifier() {
|
||||
listeners = Collections.synchronizedMap(
|
||||
new HashMap<AccelDeviceEventListener, Integer>(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a singleton of AccelDeviceEventNotifier if it exists. If the
|
||||
* passed boolean is false and singleton doesn't exist yet, null is
|
||||
* returned. If the passed boolean is {@code true} and singleton doesn't
|
||||
* exist it will be created and returned.
|
||||
*
|
||||
* @param create whether to create a singleton instance if doesn't yet
|
||||
* exist
|
||||
* @return a singleton instance or null
|
||||
*/
|
||||
private static synchronized
|
||||
AccelDeviceEventNotifier getInstance(boolean create)
|
||||
{
|
||||
if (theInstance == null && create) {
|
||||
theInstance = new AccelDeviceEventNotifier();
|
||||
}
|
||||
return theInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to indicate that a device event had occured.
|
||||
* If a singleton exists, the listeners (those associated with
|
||||
* the device) will be notified.
|
||||
*
|
||||
* @param screen a screen number of the device which is a source of
|
||||
* the event
|
||||
* @param eventType a type of the event
|
||||
* @see #DEVICE_DISPOSED
|
||||
* @see #DEVICE_RESET
|
||||
*/
|
||||
public static final void eventOccured(int screen, int eventType) {
|
||||
AccelDeviceEventNotifier notifier = getInstance(false);
|
||||
if (notifier != null) {
|
||||
notifier.notifyListeners(eventType, screen);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the listener associated with a device on particular screen.
|
||||
*
|
||||
* Note: the listener must be removed as otherwise it will forever
|
||||
* be referenced by the notifier.
|
||||
*
|
||||
* @param l the listener
|
||||
* @param screen the screen number indicating which device the listener is
|
||||
* interested in.
|
||||
*/
|
||||
public static final void addListener(AccelDeviceEventListener l,int screen){
|
||||
getInstance(true).add(l, screen);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the listener.
|
||||
*
|
||||
* @param l the listener
|
||||
*/
|
||||
public static final void removeListener(AccelDeviceEventListener l) {
|
||||
getInstance(true).remove(l);
|
||||
}
|
||||
|
||||
private final void add(AccelDeviceEventListener theListener, int screen) {
|
||||
listeners.put(theListener, screen);
|
||||
}
|
||||
private final void remove(AccelDeviceEventListener theListener) {
|
||||
listeners.remove(theListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies the listeners associated with the screen's device about the
|
||||
* event.
|
||||
*
|
||||
* Implementation note: the current list of listeners is first duplicated
|
||||
* which allows the listeners to remove themselves during the iteration.
|
||||
*
|
||||
* @param screen a screen number with which the device which is a source of
|
||||
* the event is associated with
|
||||
* @param eventType a type of the event
|
||||
* @see #DEVICE_DISPOSED
|
||||
* @see #DEVICE_RESET
|
||||
*/
|
||||
private final void notifyListeners(int deviceEventType, int screen) {
|
||||
HashMap<AccelDeviceEventListener, Integer> listClone;
|
||||
Set<AccelDeviceEventListener> cloneSet;
|
||||
|
||||
synchronized(listeners) {
|
||||
listClone =
|
||||
new HashMap<AccelDeviceEventListener, Integer>(listeners);
|
||||
}
|
||||
|
||||
cloneSet = listClone.keySet();
|
||||
Iterator<AccelDeviceEventListener> itr = cloneSet.iterator();
|
||||
while (itr.hasNext()) {
|
||||
AccelDeviceEventListener current = itr.next();
|
||||
Integer i = listClone.get(current);
|
||||
// only notify listeners which are interested in this device
|
||||
if (i != null && i.intValue() != screen) {
|
||||
continue;
|
||||
}
|
||||
if (deviceEventType == DEVICE_RESET) {
|
||||
current.onDeviceReset();
|
||||
} else if (deviceEventType == DEVICE_DISPOSED) {
|
||||
current.onDeviceDispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package sun.java2d.pipe.hw;
|
||||
|
||||
import java.awt.image.VolatileImage;
|
||||
|
||||
/**
|
||||
* Implementors of this interface provida a way to create a
|
||||
* {@code VolatileImage} whose destination surface is an
|
||||
* {@link AccelSurface} of specified type.
|
||||
*
|
||||
* @see AccelSurface
|
||||
*/
|
||||
public interface AccelGraphicsConfig extends BufferedContextProvider {
|
||||
/**
|
||||
* Returns a VolatileImage with specified width, height, transparency
|
||||
* and guaranteed accelerated surface type. If such image can not be created
|
||||
* (out of vram error, specific surface type is not supported) null
|
||||
* is returned.
|
||||
*
|
||||
* Note: if {@link AccelSurface#TEXTURE} type is requested, rendering
|
||||
* to the image will be denied by throwing
|
||||
* {@code UnsupportedOperationException }
|
||||
* from {@link java.awt.image.VolatileImage#getGraphics} and
|
||||
* {@link java.awt.image.VolatileImage#createGraphics}
|
||||
*
|
||||
* @param width the width of the returned {@code VolatileImage}
|
||||
* @param height the height of the returned {@code VolatileImage}
|
||||
* @param transparency the specified transparency mode
|
||||
* @param type requested accelerated surface type as specified by constants
|
||||
* in AccelSurface interface
|
||||
* @return a {@code VolatileImage} backed up by requested accelerated
|
||||
* surface type or null
|
||||
* @throws IllegalArgumentException if the transparency is not a valid value
|
||||
* @see AccelSurface#TEXTURE
|
||||
* @see AccelSurface#RT_PLAIN
|
||||
* @see AccelSurface#RT_TEXTURE
|
||||
*/
|
||||
public VolatileImage createCompatibleVolatileImage(int width, int height,
|
||||
int transparency,
|
||||
int type);
|
||||
/**
|
||||
* Returns object representing capabilities of the context associated
|
||||
* with this {@code AccelGraphicsConfig}.
|
||||
*
|
||||
* @return ContextCapabilities object representing caps
|
||||
* @see ContextCapabilities
|
||||
*/
|
||||
public ContextCapabilities getContextCapabilities();
|
||||
|
||||
/**
|
||||
* Adds an {@code AccelDeviceEventListener} to listen to accelerated
|
||||
* device's (which is associated with this {@code AccelGraphicsConfig})
|
||||
* events.
|
||||
*
|
||||
* Note: a hard link to the listener may be kept so it must be explicitly
|
||||
* removed via {@link #removeDeviceEventListener()}.
|
||||
*
|
||||
* @param l the listener
|
||||
* @see AccelDeviceEventListener
|
||||
*/
|
||||
public void addDeviceEventListener(AccelDeviceEventListener l);
|
||||
|
||||
/**
|
||||
* Removes an {@code AccelDeviceEventListener} from the list of listeners
|
||||
* for this device's events.
|
||||
*
|
||||
* @param l the listener
|
||||
* @see AccelDeviceEventListener
|
||||
*/
|
||||
public void removeDeviceEventListener(AccelDeviceEventListener l);
|
||||
}
|
136
jdk/src/share/classes/sun/java2d/pipe/hw/AccelSurface.java
Normal file
136
jdk/src/share/classes/sun/java2d/pipe/hw/AccelSurface.java
Normal file
@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package sun.java2d.pipe.hw;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import sun.java2d.Surface;
|
||||
|
||||
/**
|
||||
* Abstraction for a hardware accelerated surface.
|
||||
*/
|
||||
public interface AccelSurface extends BufferedContextProvider, Surface {
|
||||
/**
|
||||
* Undefined
|
||||
*/
|
||||
public static final int UNDEFINED = 0;
|
||||
/**
|
||||
* Window (or window substitute) surface
|
||||
*/
|
||||
public static final int WINDOW = 1;
|
||||
/**
|
||||
* Render-To Plain surface (pbuffer for OpenGL, Render Target surface
|
||||
* for Direct3D)
|
||||
*/
|
||||
public static final int RT_PLAIN = 2;
|
||||
/**
|
||||
* Texture surface
|
||||
*/
|
||||
public static final int TEXTURE = 3;
|
||||
/**
|
||||
* A back-buffer surface (SwapChain surface for Direct3D, backbuffer for
|
||||
* OpenGL)
|
||||
*/
|
||||
public static final int FLIP_BACKBUFFER = 4;
|
||||
/**
|
||||
* Render-To Texture surface (fbobject for OpenGL, texture with render-to
|
||||
* attribute for Direct3D)
|
||||
*/
|
||||
public static final int RT_TEXTURE = 5;
|
||||
|
||||
/**
|
||||
* Returns {@code int} representing surface's type as defined by constants
|
||||
* in this interface.
|
||||
*
|
||||
* @return an integer representing this surface's type
|
||||
* @see AccelSurface#UNDEFINED
|
||||
* @see AccelSurface#WINDOW
|
||||
* @see AccelSurface#RT_PLAIN
|
||||
* @see AccelSurface#TEXTURE
|
||||
* @see AccelSurface#FLIP_BACKBUFFER
|
||||
* @see AccelSurface#RT_TEXTURE
|
||||
*/
|
||||
public int getType();
|
||||
|
||||
/**
|
||||
* Returns a pointer to the native surface data associated with this
|
||||
* surface.
|
||||
* Note: this pointer is only valid on the rendering thread.
|
||||
*
|
||||
* @return pointer to the native surface's data
|
||||
*/
|
||||
public long getNativeOps();
|
||||
|
||||
/**
|
||||
* Returns a pointer to the real native resource
|
||||
* of the specified type associated with this AccelSurface.
|
||||
* Note: this pointer is only valid on the rendering thread.
|
||||
*
|
||||
* @param resType the type of the requested resource
|
||||
* @return a long containing a pointer to the native resource of the
|
||||
* specified type or 0L if such resource doesn't exist for this surface
|
||||
*/
|
||||
public long getNativeResource(int resType);
|
||||
|
||||
/**
|
||||
* Marks this surface dirty.
|
||||
*/
|
||||
public void markDirty();
|
||||
|
||||
/**
|
||||
* Returns whether the pipeline considers this surface valid. A surface
|
||||
* may become invalid if it is disposed of, or resized.
|
||||
*
|
||||
* @return true if valid, false otherwise
|
||||
*/
|
||||
public boolean isValid();
|
||||
|
||||
/**
|
||||
* Returns whether this surface is lost. The return value is only valid
|
||||
* on the render thread, meaning that even if this method returns
|
||||
* {@code true} it could be lost in the next moment unless it is called
|
||||
* on the rendering thread.
|
||||
*
|
||||
* @return true if the surface is known to be lost, false otherwise
|
||||
*/
|
||||
public boolean isSurfaceLost();
|
||||
|
||||
/**
|
||||
* Returns the requested bounds of the destination surface. The real bounds
|
||||
* of the native accelerated surface may differ. Use
|
||||
* {@link #getNativeBounds} to get the bounds of the native surface.
|
||||
*
|
||||
* @return Rectangle representing java surface's bounds
|
||||
*/
|
||||
public Rectangle getBounds();
|
||||
|
||||
/**
|
||||
* Returns real bounds of the native surface, which may differ from those
|
||||
* returned by {@link #getBounds}.
|
||||
*
|
||||
* @return Rectangle representing native surface's bounds
|
||||
*/
|
||||
public Rectangle getNativeBounds();
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package sun.java2d.pipe.hw;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import sun.awt.image.SunVolatileImage;
|
||||
import static sun.java2d.pipe.hw.AccelSurface.*;
|
||||
|
||||
/**
|
||||
* This is an image with forced type of the accelerated surface.
|
||||
*/
|
||||
public class AccelTypedVolatileImage extends SunVolatileImage {
|
||||
|
||||
/**
|
||||
* Creates a volatile image with specified type of accelerated surface.
|
||||
*
|
||||
* @param graphicsConfig a GraphicsConfiguration for which this image should
|
||||
* be created.
|
||||
* @param width width
|
||||
* @param height width
|
||||
* @param transparency type of {@link java.awt.Transparency transparency}
|
||||
* requested for the image
|
||||
* @param accType type of the desired accelerated surface as defined in
|
||||
* AccelSurface interface
|
||||
* @see sun.java2d.pipe.hw.AccelSurface
|
||||
*/
|
||||
public AccelTypedVolatileImage(GraphicsConfiguration graphicsConfig,
|
||||
int width, int height, int transparency,
|
||||
int accType)
|
||||
{
|
||||
super(null, graphicsConfig, width, height, null, transparency,
|
||||
null, accType);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* This method will throw {@code UnsupportedOperationException} if it this
|
||||
* image's destination surface can not be rendered to.
|
||||
*/
|
||||
@Override
|
||||
public Graphics2D createGraphics() {
|
||||
if (getForcedAccelSurfaceType() == TEXTURE) {
|
||||
throw new UnsupportedOperationException("Can't render " +
|
||||
"to a non-RT Texture");
|
||||
}
|
||||
return super.createGraphics();
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package sun.java2d.pipe.hw;
|
||||
|
||||
import sun.java2d.pipe.BufferedContext;
|
||||
|
||||
/**
|
||||
* Classes implementing this interface can provide the {@code BufferedContext}
|
||||
* associated with or used by them.
|
||||
*
|
||||
* @see sun.java2d.pipe.BufferedContext
|
||||
*/
|
||||
public interface BufferedContextProvider {
|
||||
/**
|
||||
* Retrieves a context associated with object implementing this
|
||||
* interface.
|
||||
*
|
||||
* @return associated context
|
||||
* @see sun.java2d.pipe.BufferedContext
|
||||
*/
|
||||
public BufferedContext getContext();
|
||||
}
|
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package sun.java2d.pipe.hw;
|
||||
|
||||
/**
|
||||
* Represents a set of capabilities of a BufferedContext and associated
|
||||
* AccelGraphicsConfig.
|
||||
*
|
||||
* @see AccelGraphicsConfig
|
||||
*/
|
||||
public class ContextCapabilities {
|
||||
/** Indicates that the context has no capabilities. */
|
||||
public static final int CAPS_EMPTY = (0 << 0);
|
||||
/** Indicates that the context supports RT surfaces with alpha channel. */
|
||||
public static final int CAPS_RT_PLAIN_ALPHA = (1 << 1);
|
||||
/** Indicates that the context supports RT textures with alpha channel. */
|
||||
public static final int CAPS_RT_TEXTURE_ALPHA = (1 << 2);
|
||||
/** Indicates that the context supports opaque RT textures. */
|
||||
public static final int CAPS_RT_TEXTURE_OPAQUE = (1 << 3);
|
||||
/** Indicates that the context supports multitexturing. */
|
||||
public static final int CAPS_MULTITEXTURE = (1 << 4);
|
||||
/** Indicates that the context supports non-pow2 texture dimensions. */
|
||||
public static final int CAPS_TEXNONPOW2 = (1 << 5);
|
||||
/** Indicates that the context supports non-square textures. */
|
||||
public static final int CAPS_TEXNONSQUARE = (1 << 6);
|
||||
/** Indicates that the context supports pixel shader 2.0 or better. */
|
||||
public static final int CAPS_PS20 = (1 << 7);
|
||||
/** Indicates that the context supports pixel shader 3.0 or better. */
|
||||
public static final int CAPS_PS30 = (1 << 8);
|
||||
/*
|
||||
* Pipeline contexts should use this for defining pipeline-specific
|
||||
* capabilities, for example:
|
||||
* int CAPS_D3D_1 = (FIRST_PRIVATE_CAP << 0);
|
||||
* int CAPS_D3D_2 = (FIRST_PRIVATE_CAP << 1);
|
||||
*/
|
||||
protected static final int FIRST_PRIVATE_CAP = (1 << 16);
|
||||
|
||||
protected final int caps;
|
||||
protected final String adapterId;
|
||||
|
||||
/**
|
||||
* Constructs a {@code ContextCapabilities} object.
|
||||
* @param caps an {@code int} representing the capabilities
|
||||
* @param a {@code String} representing the name of the adapter, or null,
|
||||
* in which case the adapterId will be set to "unknown adapter".
|
||||
*/
|
||||
protected ContextCapabilities(int caps, String adapterId) {
|
||||
this.caps = caps;
|
||||
this.adapterId = adapterId != null ? adapterId : "unknown adapter";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representing the name of the graphics adapter if such
|
||||
* could be determined. It is guaranteed to never return {@code null}.
|
||||
* @return string representing adapter id
|
||||
*/
|
||||
public String getAdapterId() {
|
||||
return adapterId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an {@code int} with capabilities (OR-ed constants defined in
|
||||
* this class and its pipeline-specific subclasses).
|
||||
* @return capabilities as {@code int}
|
||||
*/
|
||||
public int getCaps() {
|
||||
return caps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf =
|
||||
new StringBuffer("ContextCapabilities: adapter=" +
|
||||
adapterId+", caps=");
|
||||
if (caps == CAPS_EMPTY) {
|
||||
buf.append("CAPS_EMPTY");
|
||||
} else {
|
||||
if ((caps & CAPS_RT_PLAIN_ALPHA) != 0) {
|
||||
buf.append("CAPS_RT_PLAIN_ALPHA|");
|
||||
}
|
||||
if ((caps & CAPS_RT_TEXTURE_ALPHA) != 0) {
|
||||
buf.append("CAPS_RT_TEXTURE_ALPHA|");
|
||||
}
|
||||
if ((caps & CAPS_RT_TEXTURE_OPAQUE) != 0) {
|
||||
buf.append("CAPS_RT_TEXTURE_OPAQUE|");
|
||||
}
|
||||
if ((caps & CAPS_MULTITEXTURE) != 0) {
|
||||
buf.append("CAPS_MULTITEXTURE|");
|
||||
}
|
||||
if ((caps & CAPS_TEXNONPOW2) != 0) {
|
||||
buf.append("CAPS_TEXNONPOW2|");
|
||||
}
|
||||
if ((caps & CAPS_TEXNONSQUARE) != 0) {
|
||||
buf.append("CAPS_TEXNONSQUARE|");
|
||||
}
|
||||
if ((caps & CAPS_PS20) != 0) {
|
||||
buf.append("CAPS_PS20|");
|
||||
}
|
||||
if ((caps & CAPS_PS30) != 0) {
|
||||
buf.append("CAPS_PS30|");
|
||||
}
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package sun.java2d.pipe.hw;
|
||||
|
||||
import java.awt.BufferCapabilities;
|
||||
import java.awt.ImageCapabilities;
|
||||
|
||||
/**
|
||||
* Provides extended BufferStrategy capabilities, allowing to specify
|
||||
* the type of vertical refresh synchronization for a buffer strategy.
|
||||
*
|
||||
* This BS capability is always page flipping because v-sync is only relevant
|
||||
* to flipping buffer strategies.
|
||||
*
|
||||
* Note that asking for a v-synced BS doesn't necessarily guarantee that it will
|
||||
* be v-synced since the vsync capability may be disabled in the driver, or
|
||||
* there may be other restriction (like a number of v-synced buffer strategies
|
||||
* allowed per vm). Because of this {@code createBufferStrategy} doesn't
|
||||
* throw {@code AWTException} when a v-synced BS could not be created when
|
||||
* requested.
|
||||
*
|
||||
* @see java.awt.Canvas#createBufferStrategy(int, BufferCapabilities)
|
||||
* @see java.awt.Window#createBufferStrategy(int, BufferCapabilities)
|
||||
*/
|
||||
public class ExtendedBufferCapabilities extends BufferCapabilities {
|
||||
|
||||
/**
|
||||
* Type of synchronization on vertical retrace.
|
||||
*/
|
||||
public static enum VSyncType {
|
||||
/**
|
||||
* Use the default v-sync mode appropriate for given BufferStrategy
|
||||
* and situation.
|
||||
*/
|
||||
VSYNC_DEFAULT(0),
|
||||
|
||||
/**
|
||||
* Synchronize flip on vertical retrace.
|
||||
*/
|
||||
VSYNC_ON(1),
|
||||
|
||||
/**
|
||||
* Do not synchronize flip on vertical retrace.
|
||||
*/
|
||||
VSYNC_OFF(2);
|
||||
|
||||
/**
|
||||
* Used to identify the v-sync type (independent of the constants
|
||||
* order as opposed to {@code ordinal()}).
|
||||
*/
|
||||
public int id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
private VSyncType(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
private int id;
|
||||
}
|
||||
|
||||
private VSyncType vsync;
|
||||
|
||||
/**
|
||||
* Creates an ExtendedBufferCapabilities object with front/back/flip caps
|
||||
* from the passed cap, and VSYNC_DEFAULT v-sync mode.
|
||||
*/
|
||||
public ExtendedBufferCapabilities(BufferCapabilities caps) {
|
||||
super(caps.getFrontBufferCapabilities(),
|
||||
caps.getBackBufferCapabilities(),
|
||||
caps.getFlipContents());
|
||||
|
||||
this.vsync = VSyncType.VSYNC_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an ExtendedBufferCapabilities instance with front/back/flip caps
|
||||
* from the passed caps, and VSYNC_DEFAULT v-sync mode.
|
||||
*/
|
||||
public ExtendedBufferCapabilities(ImageCapabilities front,
|
||||
ImageCapabilities back, FlipContents flip)
|
||||
{
|
||||
super(front, back, flip);
|
||||
|
||||
this.vsync = VSyncType.VSYNC_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an ExtendedBufferCapabilities instance with front/back/flip caps
|
||||
* from the passed image/flip caps, and the v-sync type.
|
||||
*/
|
||||
public ExtendedBufferCapabilities(ImageCapabilities front,
|
||||
ImageCapabilities back, FlipContents flip,
|
||||
VSyncType t)
|
||||
{
|
||||
super(front, back, flip);
|
||||
|
||||
this.vsync = t;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an ExtendedBufferCapabilities instance with front/back/flip caps
|
||||
* from the passed cap, and the passed v-sync mode.
|
||||
*/
|
||||
public ExtendedBufferCapabilities(BufferCapabilities caps, VSyncType t) {
|
||||
super(caps.getFrontBufferCapabilities(),
|
||||
caps.getBackBufferCapabilities(),
|
||||
caps.getFlipContents());
|
||||
|
||||
this.vsync = t;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an ExtendedBufferCapabilities instance with front/back/flip caps
|
||||
* from the object, and passed v-sync mode.
|
||||
*/
|
||||
public ExtendedBufferCapabilities derive(VSyncType t) {
|
||||
return new ExtendedBufferCapabilities(this, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of v-sync requested by this capabilities instance.
|
||||
*/
|
||||
public VSyncType getVSync() {
|
||||
return vsync;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isPageFlipping() {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -45,6 +45,19 @@
|
||||
* list describing the cache as new glyphs are added. Platform specific
|
||||
* glyph caching code is responsible for actually creating the accelerated
|
||||
* memory surface that will contain the individual glyph images.
|
||||
*
|
||||
* Each glyph contains a reference to a list of cell infos - one per glyph
|
||||
* cache. There may be multiple glyph caches (for example, one per graphics
|
||||
* adapter), so if the glyph is cached on two devices its cell list will
|
||||
* consists of two elements corresponding to different glyph caches.
|
||||
*
|
||||
* The platform-specific glyph caching code is supposed to use
|
||||
* GetCellInfoForCache method for retrieving cache infos from the glyph's list.
|
||||
*
|
||||
* Note that if it is guaranteed that there will be only one global glyph
|
||||
* cache then it one does not have to use AccelGlyphCache_GetCellInfoForCache
|
||||
* for retrieving cell info for the glyph, but instead just use the struct's
|
||||
* field directly.
|
||||
*/
|
||||
GlyphCacheInfo *
|
||||
AccelGlyphCache_Init(jint width, jint height,
|
||||
@ -86,8 +99,11 @@ AccelGlyphCache_Init(jint width, jint height,
|
||||
* "virtual" glyph cache is available for the glyph image. Platform specific
|
||||
* glyph caching code is responsible for actually caching the glyph image
|
||||
* in the associated accelerated memory surface.
|
||||
*
|
||||
* Returns created cell info if it was successfully created and added to the
|
||||
* cache and glyph's cell lists, NULL otherwise.
|
||||
*/
|
||||
void
|
||||
CacheCellInfo *
|
||||
AccelGlyphCache_AddGlyph(GlyphCacheInfo *cache, GlyphInfo *glyph)
|
||||
{
|
||||
CacheCellInfo *cellinfo = NULL;
|
||||
@ -99,7 +115,7 @@ AccelGlyphCache_AddGlyph(GlyphCacheInfo *cache, GlyphInfo *glyph)
|
||||
if ((glyph->width > cache->cellWidth) ||
|
||||
(glyph->height > cache->cellHeight))
|
||||
{
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!cache->isFull) {
|
||||
@ -126,9 +142,8 @@ AccelGlyphCache_AddGlyph(GlyphCacheInfo *cache, GlyphInfo *glyph)
|
||||
// create new CacheCellInfo
|
||||
cellinfo = (CacheCellInfo *)malloc(sizeof(CacheCellInfo));
|
||||
if (cellinfo == NULL) {
|
||||
glyph->cellInfo = NULL;
|
||||
J2dTraceLn(J2D_TRACE_ERROR, "could not allocate CellInfo");
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cellinfo->cacheInfo = cache;
|
||||
@ -136,6 +151,8 @@ AccelGlyphCache_AddGlyph(GlyphCacheInfo *cache, GlyphInfo *glyph)
|
||||
cellinfo->timesRendered = 0;
|
||||
cellinfo->x = x;
|
||||
cellinfo->y = y;
|
||||
cellinfo->leftOff = 0;
|
||||
cellinfo->rightOff = 0;
|
||||
cellinfo->tx1 = (jfloat)cellinfo->x / cache->width;
|
||||
cellinfo->ty1 = (jfloat)cellinfo->y / cache->height;
|
||||
cellinfo->tx2 = cellinfo->tx1 + ((jfloat)w / cache->width);
|
||||
@ -152,6 +169,7 @@ AccelGlyphCache_AddGlyph(GlyphCacheInfo *cache, GlyphInfo *glyph)
|
||||
// add the new cell to the end of the list
|
||||
cache->tail = cellinfo;
|
||||
cellinfo->next = NULL;
|
||||
cellinfo->nextGCI = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -210,9 +228,9 @@ AccelGlyphCache_AddGlyph(GlyphCacheInfo *cache, GlyphInfo *glyph)
|
||||
cache->Flush();
|
||||
}
|
||||
|
||||
// if the cell is occupied, notify the base glyph that its
|
||||
// cached version is about to be kicked out
|
||||
cellinfo->glyphInfo->cellInfo = NULL;
|
||||
// if the cell is occupied, notify the base glyph that the
|
||||
// cached version for this cache is about to be kicked out
|
||||
AccelGlyphCache_RemoveCellInfo(cellinfo->glyphInfo, cellinfo);
|
||||
}
|
||||
|
||||
// update cellinfo with glyph's occupied region information
|
||||
@ -221,8 +239,9 @@ AccelGlyphCache_AddGlyph(GlyphCacheInfo *cache, GlyphInfo *glyph)
|
||||
cellinfo->ty2 = cellinfo->ty1 + ((jfloat)h / cache->height);
|
||||
}
|
||||
|
||||
// update the glyph's reference to its cache cell
|
||||
glyph->cellInfo = cellinfo;
|
||||
// add cache cell to the glyph's cells list
|
||||
AccelGlyphCache_AddCellInfo(glyph, cellinfo);
|
||||
return cellinfo;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -251,10 +270,145 @@ AccelGlyphCache_Invalidate(GlyphCacheInfo *cache)
|
||||
while (cellinfo != NULL) {
|
||||
if (cellinfo->glyphInfo != NULL) {
|
||||
// if the cell is occupied, notify the base glyph that its
|
||||
// cached version is about to be invalidated
|
||||
cellinfo->glyphInfo->cellInfo = NULL;
|
||||
cellinfo->glyphInfo = NULL;
|
||||
// cached version for this cache is about to be invalidated
|
||||
AccelGlyphCache_RemoveCellInfo(cellinfo->glyphInfo, cellinfo);
|
||||
}
|
||||
cellinfo = cellinfo->next;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidates and frees all cells and the cache itself. The "cache" pointer
|
||||
* becomes invalid after this function returns.
|
||||
*/
|
||||
void
|
||||
AccelGlyphCache_Free(GlyphCacheInfo *cache)
|
||||
{
|
||||
CacheCellInfo *cellinfo;
|
||||
|
||||
J2dTraceLn(J2D_TRACE_INFO, "AccelGlyphCache_Free");
|
||||
|
||||
if (cache == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// flush any pending vertices that may be depending on the current
|
||||
// glyph cache
|
||||
if (cache->Flush != NULL) {
|
||||
cache->Flush();
|
||||
}
|
||||
|
||||
while (cache->head != NULL) {
|
||||
cellinfo = cache->head;
|
||||
if (cellinfo->glyphInfo != NULL) {
|
||||
// if the cell is occupied, notify the base glyph that its
|
||||
// cached version for this cache is about to be invalidated
|
||||
AccelGlyphCache_RemoveCellInfo(cellinfo->glyphInfo, cellinfo);
|
||||
}
|
||||
cache->head = cellinfo->next;
|
||||
free(cellinfo);
|
||||
}
|
||||
free(cache);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add cell info to the head of the glyph's list of cached cells.
|
||||
*/
|
||||
void
|
||||
AccelGlyphCache_AddCellInfo(GlyphInfo *glyph, CacheCellInfo *cellInfo)
|
||||
{
|
||||
// assert (glyph != NULL && cellInfo != NULL)
|
||||
J2dTraceLn(J2D_TRACE_INFO, "AccelGlyphCache_AddCellInfo");
|
||||
J2dTraceLn2(J2D_TRACE_VERBOSE, " glyph 0x%x: adding cell 0x%x to the list",
|
||||
glyph, cellInfo);
|
||||
|
||||
cellInfo->glyphInfo = glyph;
|
||||
cellInfo->nextGCI = glyph->cellInfo;
|
||||
glyph->cellInfo = cellInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes cell info from the glyph's list of cached cells.
|
||||
*/
|
||||
void
|
||||
AccelGlyphCache_RemoveCellInfo(GlyphInfo *glyph, CacheCellInfo *cellInfo)
|
||||
{
|
||||
CacheCellInfo *currCellInfo = glyph->cellInfo;
|
||||
CacheCellInfo *prevInfo = NULL;
|
||||
// assert (glyph!= NULL && glyph->cellInfo != NULL && cellInfo != NULL)
|
||||
J2dTraceLn(J2D_TRACE_INFO, "AccelGlyphCache_RemoveCellInfo");
|
||||
do {
|
||||
if (currCellInfo == cellInfo) {
|
||||
J2dTraceLn2(J2D_TRACE_VERBOSE,
|
||||
" glyph 0x%x: removing cell 0x%x from glyph's list",
|
||||
glyph, currCellInfo);
|
||||
if (prevInfo == NULL) { // it's the head, chop-chop
|
||||
glyph->cellInfo = currCellInfo->nextGCI;
|
||||
} else {
|
||||
prevInfo->nextGCI = currCellInfo->nextGCI;
|
||||
}
|
||||
currCellInfo->glyphInfo = NULL;
|
||||
currCellInfo->nextGCI = NULL;
|
||||
return;
|
||||
}
|
||||
prevInfo = currCellInfo;
|
||||
currCellInfo = currCellInfo->nextGCI;
|
||||
} while (currCellInfo != NULL);
|
||||
J2dTraceLn2(J2D_TRACE_WARNING, "AccelGlyphCache_RemoveCellInfo: "\
|
||||
"no cell 0x%x in glyph 0x%x's cell list",
|
||||
cellInfo, glyph);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes cell info from the glyph's list of cached cells.
|
||||
*/
|
||||
JNIEXPORT void
|
||||
AccelGlyphCache_RemoveAllCellInfos(GlyphInfo *glyph)
|
||||
{
|
||||
CacheCellInfo *currCell, *prevCell;
|
||||
|
||||
J2dTraceLn(J2D_TRACE_INFO, "AccelGlyphCache_RemoveAllCellInfos");
|
||||
|
||||
if (glyph == NULL || glyph->cellInfo == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// invalidate all of this glyph's accelerated cache cells
|
||||
currCell = glyph->cellInfo;
|
||||
do {
|
||||
currCell->glyphInfo = NULL;
|
||||
prevCell = currCell;
|
||||
currCell = currCell->nextGCI;
|
||||
prevCell->nextGCI = NULL;
|
||||
} while (currCell != NULL);
|
||||
|
||||
glyph->cellInfo = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns cell info associated with particular cache from the glyph's list of
|
||||
* cached cells.
|
||||
*/
|
||||
CacheCellInfo *
|
||||
AccelGlyphCache_GetCellInfoForCache(GlyphInfo *glyph, GlyphCacheInfo *cache)
|
||||
{
|
||||
// assert (glyph != NULL && cache != NULL)
|
||||
J2dTraceLn(J2D_TRACE_VERBOSE2, "AccelGlyphCache_GetCellInfoForCache");
|
||||
|
||||
if (glyph->cellInfo != NULL) {
|
||||
CacheCellInfo *cellInfo = glyph->cellInfo;
|
||||
do {
|
||||
if (cellInfo->cacheInfo == cache) {
|
||||
J2dTraceLn3(J2D_TRACE_VERBOSE2,
|
||||
" glyph 0x%x: found cell 0x%x for cache 0x%x",
|
||||
glyph, cellInfo, cache);
|
||||
return cellInfo;
|
||||
}
|
||||
cellInfo = cellInfo->nextGCI;
|
||||
} while (cellInfo != NULL);
|
||||
}
|
||||
J2dTraceLn2(J2D_TRACE_VERBOSE2, " glyph 0x%x: no cell for cache 0x%x",
|
||||
glyph, cache);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,6 +26,10 @@
|
||||
#ifndef AccelGlyphCache_h_Included
|
||||
#define AccelGlyphCache_h_Included
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "jni.h"
|
||||
#include "fontscalerdefs.h"
|
||||
|
||||
@ -48,10 +52,18 @@ typedef struct {
|
||||
struct _CacheCellInfo {
|
||||
GlyphCacheInfo *cacheInfo;
|
||||
struct GlyphInfo *glyphInfo;
|
||||
// next cell info in the cache's list
|
||||
CacheCellInfo *next;
|
||||
// REMIND: find better name?
|
||||
// next cell info in the glyph's cell list (next Glyph Cache Info)
|
||||
CacheCellInfo *nextGCI;
|
||||
jint timesRendered;
|
||||
jint x;
|
||||
jint y;
|
||||
// number of pixels from the left or right edge not considered touched
|
||||
// by the glyph
|
||||
jint leftOff;
|
||||
jint rightOff;
|
||||
jfloat tx1;
|
||||
jfloat ty1;
|
||||
jfloat tx2;
|
||||
@ -62,9 +74,24 @@ GlyphCacheInfo *
|
||||
AccelGlyphCache_Init(jint width, jint height,
|
||||
jint cellWidth, jint cellHeight,
|
||||
FlushFunc *func);
|
||||
void
|
||||
CacheCellInfo *
|
||||
AccelGlyphCache_AddGlyph(GlyphCacheInfo *cache, struct GlyphInfo *glyph);
|
||||
void
|
||||
AccelGlyphCache_Invalidate(GlyphCacheInfo *cache);
|
||||
void
|
||||
AccelGlyphCache_AddCellInfo(struct GlyphInfo *glyph, CacheCellInfo *cellInfo);
|
||||
void
|
||||
AccelGlyphCache_RemoveCellInfo(struct GlyphInfo *glyph, CacheCellInfo *cellInfo);
|
||||
CacheCellInfo *
|
||||
AccelGlyphCache_GetCellInfoForCache(struct GlyphInfo *glyph,
|
||||
GlyphCacheInfo *cache);
|
||||
JNIEXPORT void
|
||||
AccelGlyphCache_RemoveAllCellInfos(struct GlyphInfo *glyph);
|
||||
void
|
||||
AccelGlyphCache_Free(GlyphCacheInfo *cache);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* AccelGlyphCache_h_Included */
|
||||
|
@ -770,11 +770,9 @@ Java_sun_font_FreetypeFontScaler_getGlyphImageNative(
|
||||
glyphInfo->topLeftX = (float) ftglyph->bitmap_left;
|
||||
glyphInfo->topLeftY = (float) -ftglyph->bitmap_top;
|
||||
|
||||
if (context->aaType == TEXT_AA_LCD_HRGB ||
|
||||
context->aaType == TEXT_AA_LCD_HBGR) {
|
||||
if (ftglyph->bitmap.pixel_mode == FT_PIXEL_MODE_LCD) {
|
||||
glyphInfo->width = width/3;
|
||||
} else if (context->aaType == TEXT_AA_LCD_VRGB ||
|
||||
context->aaType == TEXT_AA_LCD_VBGR) {
|
||||
} else if (ftglyph->bitmap.pixel_mode == FT_PIXEL_MODE_LCD_V) {
|
||||
glyphInfo->height = glyphInfo->height/3;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -35,6 +35,8 @@
|
||||
#include "sun_font_StrikeCache.h"
|
||||
|
||||
static void *theNullScalerContext = NULL;
|
||||
extern void AccelGlyphCache_RemoveAllCellInfos(GlyphInfo *glyph);
|
||||
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_sun_font_NullFontScaler_getNullScalerContext
|
||||
@ -294,7 +296,7 @@ JNIEXPORT void JNICALL Java_sun_font_StrikeCache_freeIntMemory
|
||||
GlyphInfo *ginfo = (GlyphInfo *)ptrs[i];
|
||||
if (ginfo->cellInfo != NULL) {
|
||||
// invalidate this glyph's accelerated cache cell
|
||||
ginfo->cellInfo->glyphInfo = NULL;
|
||||
AccelGlyphCache_RemoveAllCellInfos(ginfo);
|
||||
}
|
||||
free((void*)ginfo);
|
||||
}
|
||||
@ -324,8 +326,7 @@ JNIEXPORT void JNICALL Java_sun_font_StrikeCache_freeLongMemory
|
||||
if (ptrs[i] != 0L) {
|
||||
GlyphInfo *ginfo = (GlyphInfo *) jlong_to_ptr(ptrs[i]);
|
||||
if (ginfo->cellInfo != NULL) {
|
||||
// invalidate this glyph's accelerated cache cell
|
||||
ginfo->cellInfo->glyphInfo = NULL;
|
||||
AccelGlyphCache_RemoveAllCellInfos(ginfo);
|
||||
}
|
||||
free((void*)ginfo);
|
||||
}
|
||||
|
143
jdk/src/share/native/sun/java2d/ShaderList.c
Normal file
143
jdk/src/share/native/sun/java2d/ShaderList.c
Normal file
@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ShaderList.h"
|
||||
#include "Trace.h"
|
||||
|
||||
/**
|
||||
* Creates a new ShaderInfo that wraps the given fragment program handle
|
||||
* and related data and stores it at the front of the provided ShaderList.
|
||||
* If the addition causes the ShaderList to outgrow its defined capacity,
|
||||
* the least-recently used item in the list (including its fragment program
|
||||
* object) will be disposed.
|
||||
*/
|
||||
void
|
||||
ShaderList_AddProgram(ShaderList *programList,
|
||||
jlong programID,
|
||||
jint compType, jint compMode, jint flags)
|
||||
{
|
||||
ShaderInfo *info;
|
||||
|
||||
J2dTraceLn(J2D_TRACE_INFO, "ShaderList_AddProgram");
|
||||
|
||||
// create new ShaderInfo
|
||||
info = (ShaderInfo *)malloc(sizeof(ShaderInfo));
|
||||
if (info == NULL) {
|
||||
J2dTraceLn(J2D_TRACE_ERROR,
|
||||
"OGLContext_AddProgram: could not allocate ShaderInfo");
|
||||
return;
|
||||
}
|
||||
|
||||
// fill in the information
|
||||
info->next = programList->head;
|
||||
info->programID = programID;
|
||||
info->compType = compType;
|
||||
info->compMode = compMode;
|
||||
info->flags = flags;
|
||||
|
||||
// insert it at the head of the list
|
||||
programList->head = info;
|
||||
|
||||
// run through the list and see if we need to delete the least
|
||||
// recently used item
|
||||
{
|
||||
int i = 1;
|
||||
ShaderInfo *prev = NULL;
|
||||
ShaderInfo *curr = info->next;
|
||||
while (curr != NULL) {
|
||||
if (i >= programList->maxItems) {
|
||||
prev->next = NULL;
|
||||
programList->dispose(curr->programID);
|
||||
free(curr);
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
prev = curr;
|
||||
curr = curr->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Locates a fragment program handle given a list of shader programs
|
||||
* (ShaderInfos), using the provided composite state and flags as search
|
||||
* parameters. The "flags" parameter is a bitwise-or'd value that helps
|
||||
* differentiate one program for another; the interpretation of this value
|
||||
* varies depending on the type of shader (BufImgOp, Paint, etc) but here
|
||||
* it is only used to find another ShaderInfo with that same "flags" value.
|
||||
* If no matching program can be located, this method returns 0.
|
||||
*/
|
||||
jlong
|
||||
ShaderList_FindProgram(ShaderList *programList,
|
||||
jint compType, jint compMode, jint flags)
|
||||
{
|
||||
ShaderInfo *prev = NULL;
|
||||
ShaderInfo *info = programList->head;
|
||||
|
||||
J2dTraceLn(J2D_TRACE_INFO, "ShaderList_FindProgram");
|
||||
|
||||
while (info != NULL) {
|
||||
if (compType == info->compType &&
|
||||
compMode == info->compMode &&
|
||||
flags == info->flags)
|
||||
{
|
||||
// it's a match: move it to the front of the list (if it's not
|
||||
// there already) and patch up the links
|
||||
if (info != programList->head) {
|
||||
prev->next = info->next;
|
||||
info->next = programList->head;
|
||||
programList->head = info;
|
||||
}
|
||||
return info->programID;
|
||||
}
|
||||
prev = info;
|
||||
info = info->next;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disposes all entries (and their associated shader program objects)
|
||||
* contained in the given ShaderList.
|
||||
*/
|
||||
void
|
||||
ShaderList_Dispose(ShaderList *programList)
|
||||
{
|
||||
ShaderInfo *info = programList->head;
|
||||
|
||||
J2dTraceLn(J2D_TRACE_INFO, "ShaderList_Dispose");
|
||||
|
||||
while (info != NULL) {
|
||||
ShaderInfo *tmp = info->next;
|
||||
programList->dispose(info->programID);
|
||||
free(info);
|
||||
info = tmp;
|
||||
}
|
||||
|
||||
programList->head = NULL;
|
||||
}
|
85
jdk/src/share/native/sun/java2d/ShaderList.h
Normal file
85
jdk/src/share/native/sun/java2d/ShaderList.h
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
#ifndef ShaderList_h_Included
|
||||
#define ShaderList_h_Included
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "jni.h"
|
||||
#include "jlong.h"
|
||||
|
||||
typedef void (ShaderDisposeFunc)(jlong programID);
|
||||
|
||||
/**
|
||||
* The following structures are used to maintain a list of fragment program
|
||||
* objects and their associated attributes. Each logical shader (e.g.
|
||||
* RadialGradientPaint shader, ConvolveOp shader) can have a number of
|
||||
* different variants depending on a number of factors, such as whether
|
||||
* antialiasing is enabled or the current composite mode. Since the number
|
||||
* of possible combinations of these factors is in the hundreds, we need
|
||||
* some way to create fragment programs on an as-needed basis, and also
|
||||
* keep them in a limited sized cache to avoid creating too many objects.
|
||||
*
|
||||
* The ShaderInfo structure keeps a reference to the fragment program's
|
||||
* handle, as well as some other values that help differentiate one ShaderInfo
|
||||
* from another. ShaderInfos can be chained together to form a linked list.
|
||||
*
|
||||
* The ShaderList structure acts as a cache for ShaderInfos, placing
|
||||
* most-recently used items at the front, and removing items from the
|
||||
* cache when its size exceeds the "maxItems" limit.
|
||||
*/
|
||||
typedef struct _ShaderInfo ShaderInfo;
|
||||
|
||||
typedef struct {
|
||||
ShaderInfo *head;
|
||||
ShaderDisposeFunc *dispose;
|
||||
jint maxItems;
|
||||
} ShaderList;
|
||||
|
||||
struct _ShaderInfo {
|
||||
ShaderInfo *next;
|
||||
jlong programID;
|
||||
jint compType;
|
||||
jint compMode;
|
||||
jint flags;
|
||||
};
|
||||
|
||||
void ShaderList_AddProgram(ShaderList *programList,
|
||||
jlong programID,
|
||||
jint compType, jint compMode,
|
||||
jint flags);
|
||||
jlong ShaderList_FindProgram(ShaderList *programList,
|
||||
jint compType, jint compMode,
|
||||
jint flags);
|
||||
void ShaderList_Dispose(ShaderList *programList);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* ShaderList_h_Included */
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -62,12 +62,18 @@ J2dTraceInit();
|
||||
#define J2dTrace3(level, string, arg1, arg2, arg3)
|
||||
#define J2dTrace4(level, string, arg1, arg2, arg3, arg4)
|
||||
#define J2dTrace5(level, string, arg1, arg2, arg3, arg4, arg5)
|
||||
#define J2dTrace6(level, string, arg1, arg2, arg3, arg4, arg5, arg6)
|
||||
#define J2dTrace7(level, string, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
|
||||
#define J2dTrace8(level, string, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
|
||||
#define J2dTraceLn(level, string)
|
||||
#define J2dTraceLn1(level, string, arg1)
|
||||
#define J2dTraceLn2(level, string, arg1, arg2)
|
||||
#define J2dTraceLn3(level, string, arg1, arg2, arg3)
|
||||
#define J2dTraceLn4(level, string, arg1, arg2, arg3, arg4)
|
||||
#define J2dTraceLn5(level, string, arg1, arg2, arg3, arg4, arg5)
|
||||
#define J2dTraceLn6(level, string, arg1, arg2, arg3, arg4, arg5, arg6)
|
||||
#define J2dTraceLn7(level, string, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
|
||||
#define J2dTraceLn8(level, string, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
|
||||
#else /* DEBUG */
|
||||
#define J2dTrace(level, string) { \
|
||||
J2dTraceImpl(level, JNI_FALSE, string); \
|
||||
@ -87,6 +93,15 @@ J2dTraceInit();
|
||||
#define J2dTrace5(level, string, arg1, arg2, arg3, arg4, arg5) { \
|
||||
J2dTraceImpl(level, JNI_FALSE, string, arg1, arg2, arg3, arg4, arg5); \
|
||||
}
|
||||
#define J2dTrace6(level, string, arg1, arg2, arg3, arg4, arg5, arg6) { \
|
||||
J2dTraceImpl(level, JNI_FALSE, string, arg1, arg2, arg3, arg4, arg5, arg6); \
|
||||
}
|
||||
#define J2dTrace7(level, string, arg1, arg2, arg3, arg4, arg5, arg6, arg7) { \
|
||||
J2dTraceImpl(level, JNI_FALSE, string, arg1, arg2, arg3, arg4, arg5, arg6, arg7); \
|
||||
}
|
||||
#define J2dTrace8(level, string, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) { \
|
||||
J2dTraceImpl(level, JNI_FALSE, string, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); \
|
||||
}
|
||||
#define J2dTraceLn(level, string) { \
|
||||
J2dTraceImpl(level, JNI_TRUE, string); \
|
||||
}
|
||||
@ -105,6 +120,15 @@ J2dTraceInit();
|
||||
#define J2dTraceLn5(level, string, arg1, arg2, arg3, arg4, arg5) { \
|
||||
J2dTraceImpl(level, JNI_TRUE, string, arg1, arg2, arg3, arg4, arg5); \
|
||||
}
|
||||
#define J2dTraceLn6(level, string, arg1, arg2, arg3, arg4, arg5, arg6) { \
|
||||
J2dTraceImpl(level, JNI_TRUE, string, arg1, arg2, arg3, arg4, arg5, arg6); \
|
||||
}
|
||||
#define J2dTraceLn7(level, string, arg1, arg2, arg3, arg4, arg5, arg6, arg7) { \
|
||||
J2dTraceImpl(level, JNI_TRUE, string, arg1, arg2, arg3, arg4, arg5, arg6, arg7); \
|
||||
}
|
||||
#define J2dTraceLn8(level, string, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) { \
|
||||
J2dTraceImpl(level, JNI_TRUE, string, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); \
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2003 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -31,12 +31,12 @@
|
||||
/*
|
||||
* Class: sun_java2d_loops_BlitBg
|
||||
* Method: BlitBg
|
||||
* Signature: (Lsun/java2d/SurfaceData;Lsun/java2d/SurfaceData;Ljava/awt/Composite;Ljava/awt/Color;IIIIII)V
|
||||
* Signature: (Lsun/java2d/SurfaceData;Lsun/java2d/SurfaceData;Ljava/awt/Composite;IIIIIII)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_sun_java2d_loops_BlitBg_BlitBg
|
||||
(JNIEnv *env, jobject self,
|
||||
jobject srcData, jobject dstData,
|
||||
jobject comp, jobject clip, jobject bgColor,
|
||||
jobject comp, jobject clip, jint bgColor,
|
||||
jint srcx, jint srcy, jint dstx, jint dsty, jint width, jint height)
|
||||
{
|
||||
SurfaceDataOps *srcOps;
|
||||
@ -93,7 +93,7 @@ JNIEXPORT void JNICALL Java_sun_java2d_loops_BlitBg_BlitBg
|
||||
Region_IntersectBounds(&clipInfo, &dstInfo.bounds);
|
||||
|
||||
if (!Region_IsEmpty(&clipInfo)) {
|
||||
jint bgpixel = GrPrim_ColorGetRGB(env, bgColor);
|
||||
jint bgpixel = bgColor;
|
||||
srcOps->GetRasInfo(env, srcOps, &srcInfo);
|
||||
dstOps->GetRasInfo(env, dstOps, &dstInfo);
|
||||
if (pPrim->pDstType->pixelFor) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -50,7 +50,6 @@ static jfieldID eargbID;
|
||||
static jfieldID clipRegionID;
|
||||
static jfieldID compositeID;
|
||||
static jfieldID lcdTextContrastID;
|
||||
static jfieldID valueID;
|
||||
static jfieldID xorPixelID;
|
||||
static jfieldID xorColorID;
|
||||
static jfieldID alphaMaskID;
|
||||
@ -64,6 +63,8 @@ static jfieldID m10ID;
|
||||
static jfieldID m11ID;
|
||||
static jfieldID m12ID;
|
||||
|
||||
static jmethodID getRgbID;
|
||||
|
||||
static jboolean InitPrimTypes(JNIEnv *env);
|
||||
static jboolean InitSurfaceTypes(JNIEnv *env, jclass SurfaceType);
|
||||
static jboolean InitCompositeTypes(JNIEnv *env, jclass CompositeType);
|
||||
@ -114,7 +115,7 @@ Java_sun_java2d_loops_GraphicsPrimitiveMgr_initIDs
|
||||
"Ljava/awt/Composite;");
|
||||
lcdTextContrastID =
|
||||
(*env)->GetFieldID(env, SG2D, "lcdTextContrast", "I");
|
||||
valueID = (*env)->GetFieldID(env, Color, "value", "I");
|
||||
getRgbID = (*env)->GetMethodID(env, Color, "getRGB", "()I");
|
||||
xorPixelID = (*env)->GetFieldID(env, XORComp, "xorPixel", "I");
|
||||
xorColorID = (*env)->GetFieldID(env, XORComp, "xorColor",
|
||||
"Ljava/awt/Color;");
|
||||
@ -138,7 +139,6 @@ Java_sun_java2d_loops_GraphicsPrimitiveMgr_initIDs
|
||||
sg2dStrokeHintID = (*env)->GetFieldID(env, SG2D, "strokeHint", "I");
|
||||
fid = (*env)->GetStaticFieldID(env, SHints, "INTVAL_STROKE_PURE", "I");
|
||||
sunHints_INTVAL_STROKE_PURE = (*env)->GetStaticIntField(env, SHints, fid);
|
||||
|
||||
}
|
||||
|
||||
void GrPrim_RefineBounds(SurfaceDataBounds *bounds, jint transX, jint transY,
|
||||
@ -467,7 +467,7 @@ GrPrim_CompGetXorColor(JNIEnv *env, jobject comp)
|
||||
jint rgb;
|
||||
|
||||
color = (*env)->GetObjectField(env, comp, xorColorID);
|
||||
rgb = (*env)->GetIntField(env, color, valueID);
|
||||
rgb = (*env)->CallIntMethod(env, color, getRgbID);
|
||||
(*env)->DeleteLocalRef(env, color);
|
||||
|
||||
return rgb;
|
||||
@ -492,11 +492,6 @@ GrPrim_Sg2dGetEaRGB(JNIEnv *env, jobject sg2d)
|
||||
return (*env)->GetIntField(env, sg2d, eargbID);
|
||||
}
|
||||
|
||||
jint GrPrim_ColorGetRGB(JNIEnv *env, jobject color)
|
||||
{
|
||||
return (*env)->GetIntField(env, color, valueID);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
GrPrim_Sg2dGetLCDTextContrast(JNIEnv *env, jobject sg2d)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -501,7 +501,6 @@ extern JNIEXPORT jint JNICALL
|
||||
GrPrim_Sg2dGetEaRGB(JNIEnv *env, jobject sg2d);
|
||||
extern JNIEXPORT jint JNICALL
|
||||
GrPrim_Sg2dGetLCDTextContrast(JNIEnv *env, jobject sg2d);
|
||||
extern jint GrPrim_ColorGetRGB(JNIEnv *env, jobject color);
|
||||
|
||||
/*
|
||||
* Data structure and functions to retrieve and use
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2004-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -852,28 +852,58 @@ OGLContext_GetExtensionInfo(JNIEnv *env, jint *caps)
|
||||
|
||||
J2dTraceLn(J2D_TRACE_INFO, "OGLContext_GetExtensionInfo");
|
||||
|
||||
*caps |= CAPS_TEXNONSQUARE;
|
||||
if (OGLContext_IsExtensionAvailable(e, "GL_ARB_multitexture")) {
|
||||
*caps |= sun_java2d_opengl_OGLContext_CAPS_EXT_MULTITEXTURE;
|
||||
*caps |= CAPS_MULTITEXTURE;
|
||||
}
|
||||
if (OGLContext_IsExtensionAvailable(e, "GL_ARB_texture_non_power_of_two")){
|
||||
*caps |= sun_java2d_opengl_OGLContext_CAPS_EXT_TEXNONPOW2;
|
||||
*caps |= CAPS_TEXNONPOW2;
|
||||
}
|
||||
if (OGLContext_IsExtensionAvailable(e, "GL_ARB_texture_rectangle")) {
|
||||
*caps |= sun_java2d_opengl_OGLContext_CAPS_EXT_TEXRECT;
|
||||
// 6656574: Use of the GL_ARB_texture_rectangle extension by Java 2D
|
||||
// complicates any third-party libraries that try to interact with
|
||||
// the OGL pipeline (and we've run into driver bugs in the past related
|
||||
// to this extension), so for now we will disable its use by default (unless
|
||||
// forced). We will still make use of the GL_ARB_texture_non_power_of_two
|
||||
// extension when available, which is the better choice going forward
|
||||
// anyway.
|
||||
if (OGLContext_IsExtensionAvailable(e, "GL_ARB_texture_rectangle") &&
|
||||
getenv("J2D_OGL_TEXRECT") != NULL)
|
||||
{
|
||||
*caps |= CAPS_EXT_TEXRECT;
|
||||
}
|
||||
if (OGLContext_IsFBObjectExtensionAvailable(env, e)) {
|
||||
*caps |= sun_java2d_opengl_OGLContext_CAPS_EXT_FBOBJECT;
|
||||
*caps |= CAPS_EXT_FBOBJECT;
|
||||
}
|
||||
if (OGLContext_IsLCDShaderSupportAvailable(env, fragShaderAvail)) {
|
||||
*caps |= sun_java2d_opengl_OGLContext_CAPS_EXT_LCD_SHADER;
|
||||
*caps |= CAPS_EXT_LCD_SHADER | CAPS_PS20;
|
||||
}
|
||||
if (OGLContext_IsBIOpShaderSupportAvailable(env, fragShaderAvail)) {
|
||||
*caps |= sun_java2d_opengl_OGLContext_CAPS_EXT_BIOP_SHADER;
|
||||
*caps |= CAPS_EXT_BIOP_SHADER | CAPS_PS20;
|
||||
}
|
||||
if (OGLContext_IsGradShaderSupportAvailable(env, fragShaderAvail)) {
|
||||
*caps |= sun_java2d_opengl_OGLContext_CAPS_EXT_GRAD_SHADER;
|
||||
*caps |= CAPS_EXT_GRAD_SHADER | CAPS_PS20;
|
||||
}
|
||||
if (OGLContext_IsExtensionAvailable(e, "GL_NV_fragment_program")) {
|
||||
// this is an Nvidia board, at least PS 2.0, but we can't
|
||||
// use the "max instructions" heuristic since GeForce FX
|
||||
// boards report 1024 even though they're only PS 2.0,
|
||||
// so we'll check the following, which does imply PS 3.0
|
||||
if (OGLContext_IsExtensionAvailable(e, "GL_NV_fragment_program2")) {
|
||||
*caps |= CAPS_PS30;
|
||||
}
|
||||
} else {
|
||||
// for all other boards, we look at the "max instructions"
|
||||
// count reported by the GL_ARB_fragment_program extension
|
||||
// as a heuristic for detecting PS 3.0 compatible hardware
|
||||
if (OGLContext_IsExtensionAvailable(e, "GL_ARB_fragment_program")) {
|
||||
GLint instr;
|
||||
j2d_glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB,
|
||||
GL_MAX_PROGRAM_INSTRUCTIONS_ARB, &instr);
|
||||
if (instr > 512) {
|
||||
*caps |= CAPS_PS30;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// stuff vendor descriptor in the upper bits of the caps
|
||||
if (vendor != NULL) {
|
||||
if (strncmp(vendor, "ATI", 3) == 0) {
|
||||
@ -883,8 +913,10 @@ OGLContext_GetExtensionInfo(JNIEnv *env, jint *caps)
|
||||
} else if (strncmp(vendor, "Sun", 3) == 0) {
|
||||
vcap = OGLC_VENDOR_SUN;
|
||||
}
|
||||
// REMIND: new in 7 - check if needs fixing
|
||||
*caps |= ((vcap & OGLC_VCAP_MASK) << OGLC_VCAP_OFFSET);
|
||||
}
|
||||
*caps |= ((vcap & OGLC_VCAP_MASK) << OGLC_VCAP_OFFSET);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -983,4 +1015,49 @@ OGLContext_CreateFragmentProgram(const char *fragmentShaderSource)
|
||||
return fragmentProgram;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_java2d_opengl_OGLContext
|
||||
* Method: getOGLIdString
|
||||
* Signature: ()Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_sun_java2d_opengl_OGLContext_getOGLIdString
|
||||
(JNIEnv *env, jclass oglcc)
|
||||
{
|
||||
char *vendor, *renderer, *version;
|
||||
char *pAdapterId;
|
||||
jobject ret = NULL;
|
||||
int len;
|
||||
|
||||
J2dTraceLn(J2D_TRACE_INFO, "OGLContext_getOGLIdString");
|
||||
|
||||
vendor = (char*)j2d_glGetString(GL_VENDOR);
|
||||
if (vendor == NULL) {
|
||||
vendor = "Unknown Vendor";
|
||||
}
|
||||
renderer = (char*)j2d_glGetString(GL_RENDERER);
|
||||
if (renderer == NULL) {
|
||||
renderer = "Unknown Renderer";
|
||||
}
|
||||
version = (char*)j2d_glGetString(GL_VERSION);
|
||||
if (version == NULL) {
|
||||
version = "unknown version";
|
||||
}
|
||||
|
||||
// 'vendor renderer (version)0'
|
||||
len = strlen(vendor) + 1 + strlen(renderer) + 1 + 1+strlen(version)+1 + 1;
|
||||
pAdapterId = malloc(len);
|
||||
if (pAdapterId != NULL) {
|
||||
|
||||
jio_snprintf(pAdapterId, len, "%s %s (%s)", vendor, renderer, version);
|
||||
|
||||
J2dTraceLn1(J2D_TRACE_VERBOSE, " id=%s", pAdapterId);
|
||||
|
||||
ret = JNU_NewStringPlatform(env, pAdapterId);
|
||||
|
||||
free(pAdapterId);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* !HEADLESS */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2004-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,6 +28,7 @@
|
||||
|
||||
#include "sun_java2d_pipe_BufferedContext.h"
|
||||
#include "sun_java2d_opengl_OGLContext.h"
|
||||
#include "sun_java2d_opengl_OGLContext_OGLContextCaps.h"
|
||||
|
||||
#include "j2d_md.h"
|
||||
#include "J2D_GL/gl.h"
|
||||
@ -95,14 +96,51 @@ typedef struct {
|
||||
#define OGLC_USE_MASK \
|
||||
sun_java2d_pipe_BufferedContext_USE_MASK
|
||||
|
||||
/**
|
||||
* See OGLContext.java for more on these flags.
|
||||
*/
|
||||
#define CAPS_EMPTY \
|
||||
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EMPTY
|
||||
#define CAPS_RT_PLAIN_ALPHA \
|
||||
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_RT_PLAIN_ALPHA
|
||||
#define CAPS_RT_TEXTURE_ALPHA \
|
||||
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_RT_TEXTURE_ALPHA
|
||||
#define CAPS_RT_TEXTURE_OPAQUE \
|
||||
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_RT_TEXTURE_OPAQUE
|
||||
#define CAPS_MULTITEXTURE \
|
||||
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_MULTITEXTURE
|
||||
#define CAPS_TEXNONPOW2 \
|
||||
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_TEXNONPOW2
|
||||
#define CAPS_TEXNONSQUARE \
|
||||
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_TEXNONSQUARE
|
||||
#define CAPS_PS20 \
|
||||
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_PS20
|
||||
#define CAPS_PS30 \
|
||||
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_PS30
|
||||
#define LAST_SHARED_CAP \
|
||||
sun_java2d_opengl_OGLContext_OGLContextCaps_LAST_SHARED_CAP
|
||||
#define CAPS_EXT_FBOBJECT \
|
||||
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_FBOBJECT
|
||||
#define CAPS_STORED_ALPHA \
|
||||
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_STORED_ALPHA
|
||||
#define CAPS_DOUBLEBUFFERED \
|
||||
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_DOUBLEBUFFERED
|
||||
#define CAPS_EXT_LCD_SHADER \
|
||||
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_LCD_SHADER
|
||||
#define CAPS_EXT_BIOP_SHADER \
|
||||
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_BIOP_SHADER
|
||||
#define CAPS_EXT_GRAD_SHADER \
|
||||
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_GRAD_SHADER
|
||||
#define CAPS_EXT_TEXRECT \
|
||||
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_TEXRECT
|
||||
|
||||
/**
|
||||
* Evaluates to true if the given capability bitmask is present for the
|
||||
* given OGLContext. Note that only the constant name needs to be passed as
|
||||
* a parameter, as this macro will automatically prepend the full package
|
||||
* and class name to the constant name.
|
||||
*/
|
||||
#define OGLC_IS_CAP_PRESENT(oglc, cap) \
|
||||
(((oglc)->caps & (sun_java2d_opengl_OGLContext_##cap)) != 0)
|
||||
#define OGLC_IS_CAP_PRESENT(oglc, cap) (((oglc)->caps & (cap)) != 0)
|
||||
|
||||
/**
|
||||
* At startup we will embed one of the following values in the caps field
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -91,8 +91,12 @@ typedef void (GLAPIENTRY *glPixelStoreiType)(GLenum pname, GLint param);
|
||||
typedef void (GLAPIENTRY *glPixelTransferfType)(GLenum pname, GLfloat param);
|
||||
typedef void (GLAPIENTRY *glPixelZoomType)(GLfloat xfactor, GLfloat yfactor);
|
||||
typedef void (GLAPIENTRY *glPolygonOffsetType)(GLfloat factor, GLfloat units);
|
||||
typedef void (GLAPIENTRY *glPopAttribType)(void);
|
||||
typedef void (GLAPIENTRY *glPopClientAttribType)(void);
|
||||
typedef void (GLAPIENTRY *glPopMatrixType)(void);
|
||||
typedef void (GLAPIENTRY *glPrioritizeTexturesType)(GLsizei n, const GLuint *textures, const GLclampf *priorities);
|
||||
typedef void (GLAPIENTRY *glPushAttribType)(GLbitfield);
|
||||
typedef void (GLAPIENTRY *glPushClientAttribType)(GLbitfield);
|
||||
typedef void (GLAPIENTRY *glPushMatrixType)(void);
|
||||
typedef void (GLAPIENTRY *glRasterPos2iType)(GLint x, GLint y);
|
||||
typedef void (GLAPIENTRY *glReadBufferType)(GLenum mode);
|
||||
@ -155,8 +159,10 @@ typedef void (GLAPIENTRY *glUniform2fARBType)(GLint, GLfloat, GLfloat);
|
||||
typedef void (GLAPIENTRY *glUniform3fARBType)(GLint, GLfloat, GLfloat, GLfloat);
|
||||
typedef void (GLAPIENTRY *glUniform3fvARBType)(GLint, GLsizei, const GLfloat *);
|
||||
typedef void (GLAPIENTRY *glUniform4fARBType)(GLint, GLfloat, GLfloat, GLfloat, GLfloat);
|
||||
typedef void (GLAPIENTRY *glUniform4fvARBType)(GLint, GLsizei, const GLfloat *);
|
||||
typedef GLint (GLAPIENTRY *glGetUniformLocationARBType)(GLhandleARB, const GLcharARB *);
|
||||
typedef void (GLAPIENTRY *glGetInfoLogARBType)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *);
|
||||
typedef void (GLAPIENTRY *glGetProgramivARBType)(GLenum, GLenum, GLint *);
|
||||
typedef void (GLAPIENTRY *glGetObjectParameterivARBType)(GLhandleARB, GLenum, GLint *);
|
||||
typedef GLhandleARB (GLAPIENTRY *glCreateProgramObjectARBType)(void);
|
||||
typedef void (GLAPIENTRY *glAttachObjectARBType)(GLhandleARB, GLhandleARB);
|
||||
@ -243,8 +249,12 @@ typedef void (GLAPIENTRY *glDeleteObjectARBType)(GLhandleARB);
|
||||
OGL_##action##_FUNC(glPixelTransferf); \
|
||||
OGL_##action##_FUNC(glPixelZoom); \
|
||||
OGL_##action##_FUNC(glPolygonOffset); \
|
||||
OGL_##action##_FUNC(glPopAttrib); \
|
||||
OGL_##action##_FUNC(glPopClientAttrib); \
|
||||
OGL_##action##_FUNC(glPopMatrix); \
|
||||
OGL_##action##_FUNC(glPrioritizeTextures); \
|
||||
OGL_##action##_FUNC(glPushAttrib); \
|
||||
OGL_##action##_FUNC(glPushClientAttrib); \
|
||||
OGL_##action##_FUNC(glPushMatrix); \
|
||||
OGL_##action##_FUNC(glRasterPos2i); \
|
||||
OGL_##action##_FUNC(glReadBuffer); \
|
||||
@ -298,7 +308,9 @@ typedef void (GLAPIENTRY *glDeleteObjectARBType)(GLhandleARB);
|
||||
OGL_##action##_EXT_FUNC(glUniform3fARB); \
|
||||
OGL_##action##_EXT_FUNC(glUniform3fvARB); \
|
||||
OGL_##action##_EXT_FUNC(glUniform4fARB); \
|
||||
OGL_##action##_EXT_FUNC(glUniform4fvARB); \
|
||||
OGL_##action##_EXT_FUNC(glGetUniformLocationARB); \
|
||||
OGL_##action##_EXT_FUNC(glGetProgramivARB); \
|
||||
OGL_##action##_EXT_FUNC(glGetInfoLogARB); \
|
||||
OGL_##action##_EXT_FUNC(glGetObjectParameterivARB); \
|
||||
OGL_##action##_EXT_FUNC(glDeleteObjectARB);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -88,8 +88,9 @@ Java_sun_java2d_opengl_OGLRenderQueue_flushBuffer
|
||||
while (b < end) {
|
||||
jint opcode = NEXT_INT(b);
|
||||
|
||||
J2dTraceLn1(J2D_TRACE_VERBOSE,
|
||||
"OGLRenderQueue_flushBuffer: opcode=%d", opcode);
|
||||
J2dTraceLn2(J2D_TRACE_VERBOSE,
|
||||
"OGLRenderQueue_flushBuffer: opcode=%d, rem=%d",
|
||||
opcode, (end-b));
|
||||
|
||||
switch (opcode) {
|
||||
|
||||
@ -148,6 +149,40 @@ Java_sun_java2d_opengl_OGLRenderQueue_flushBuffer
|
||||
SKIP_BYTES(b, count * BYTES_PER_SCANLINE);
|
||||
}
|
||||
break;
|
||||
case sun_java2d_pipe_BufferedOpCodes_DRAW_PARALLELOGRAM:
|
||||
{
|
||||
jfloat x11 = NEXT_FLOAT(b);
|
||||
jfloat y11 = NEXT_FLOAT(b);
|
||||
jfloat dx21 = NEXT_FLOAT(b);
|
||||
jfloat dy21 = NEXT_FLOAT(b);
|
||||
jfloat dx12 = NEXT_FLOAT(b);
|
||||
jfloat dy12 = NEXT_FLOAT(b);
|
||||
jfloat lwr21 = NEXT_FLOAT(b);
|
||||
jfloat lwr12 = NEXT_FLOAT(b);
|
||||
OGLRenderer_DrawParallelogram(oglc,
|
||||
x11, y11,
|
||||
dx21, dy21,
|
||||
dx12, dy12,
|
||||
lwr21, lwr12);
|
||||
}
|
||||
break;
|
||||
case sun_java2d_pipe_BufferedOpCodes_DRAW_AAPARALLELOGRAM:
|
||||
{
|
||||
jfloat x11 = NEXT_FLOAT(b);
|
||||
jfloat y11 = NEXT_FLOAT(b);
|
||||
jfloat dx21 = NEXT_FLOAT(b);
|
||||
jfloat dy21 = NEXT_FLOAT(b);
|
||||
jfloat dx12 = NEXT_FLOAT(b);
|
||||
jfloat dy12 = NEXT_FLOAT(b);
|
||||
jfloat lwr21 = NEXT_FLOAT(b);
|
||||
jfloat lwr12 = NEXT_FLOAT(b);
|
||||
OGLRenderer_DrawAAParallelogram(oglc, dstOps,
|
||||
x11, y11,
|
||||
dx21, dy21,
|
||||
dx12, dy12,
|
||||
lwr21, lwr12);
|
||||
}
|
||||
break;
|
||||
|
||||
// fill ops
|
||||
case sun_java2d_pipe_BufferedOpCodes_FILL_RECT:
|
||||
@ -166,6 +201,34 @@ Java_sun_java2d_opengl_OGLRenderQueue_flushBuffer
|
||||
SKIP_BYTES(b, count * BYTES_PER_SPAN);
|
||||
}
|
||||
break;
|
||||
case sun_java2d_pipe_BufferedOpCodes_FILL_PARALLELOGRAM:
|
||||
{
|
||||
jfloat x11 = NEXT_FLOAT(b);
|
||||
jfloat y11 = NEXT_FLOAT(b);
|
||||
jfloat dx21 = NEXT_FLOAT(b);
|
||||
jfloat dy21 = NEXT_FLOAT(b);
|
||||
jfloat dx12 = NEXT_FLOAT(b);
|
||||
jfloat dy12 = NEXT_FLOAT(b);
|
||||
OGLRenderer_FillParallelogram(oglc,
|
||||
x11, y11,
|
||||
dx21, dy21,
|
||||
dx12, dy12);
|
||||
}
|
||||
break;
|
||||
case sun_java2d_pipe_BufferedOpCodes_FILL_AAPARALLELOGRAM:
|
||||
{
|
||||
jfloat x11 = NEXT_FLOAT(b);
|
||||
jfloat y11 = NEXT_FLOAT(b);
|
||||
jfloat dx21 = NEXT_FLOAT(b);
|
||||
jfloat dy21 = NEXT_FLOAT(b);
|
||||
jfloat dx12 = NEXT_FLOAT(b);
|
||||
jfloat dy12 = NEXT_FLOAT(b);
|
||||
OGLRenderer_FillAAParallelogram(oglc, dstOps,
|
||||
x11, y11,
|
||||
dx21, dy21,
|
||||
dx12, dy12);
|
||||
}
|
||||
break;
|
||||
|
||||
// text-related ops
|
||||
case sun_java2d_pipe_BufferedOpCodes_DRAW_GLYPH_LIST:
|
||||
@ -438,6 +501,31 @@ Java_sun_java2d_opengl_OGLRenderQueue_flushBuffer
|
||||
dstOps = NULL;
|
||||
}
|
||||
break;
|
||||
case sun_java2d_pipe_BufferedOpCodes_SAVE_STATE:
|
||||
{
|
||||
j2d_glPushAttrib(GL_ALL_ATTRIB_BITS);
|
||||
j2d_glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);
|
||||
j2d_glMatrixMode(GL_MODELVIEW);
|
||||
j2d_glPushMatrix();
|
||||
j2d_glMatrixMode(GL_PROJECTION);
|
||||
j2d_glPushMatrix();
|
||||
j2d_glMatrixMode(GL_TEXTURE);
|
||||
j2d_glPushMatrix();
|
||||
}
|
||||
break;
|
||||
|
||||
case sun_java2d_pipe_BufferedOpCodes_RESTORE_STATE:
|
||||
{
|
||||
j2d_glPopAttrib();
|
||||
j2d_glPopClientAttrib();
|
||||
j2d_glMatrixMode(GL_MODELVIEW);
|
||||
j2d_glPopMatrix();
|
||||
j2d_glMatrixMode(GL_PROJECTION);
|
||||
j2d_glPopMatrix();
|
||||
j2d_glMatrixMode(GL_TEXTURE);
|
||||
j2d_glPopMatrix();
|
||||
}
|
||||
break;
|
||||
case sun_java2d_pipe_BufferedOpCodes_SYNC:
|
||||
{
|
||||
sync = JNI_TRUE;
|
||||
@ -691,6 +779,9 @@ OGLRenderQueue_CheckPreviousOp(jint op)
|
||||
return;
|
||||
}
|
||||
|
||||
J2dTraceLn1(J2D_TRACE_VERBOSE,
|
||||
"OGLRenderQueue_CheckPreviousOp: new op=%d", op);
|
||||
|
||||
switch (previousOp) {
|
||||
case GL_TEXTURE_2D:
|
||||
case GL_TEXTURE_RECTANGLE_ARB:
|
||||
@ -718,6 +809,9 @@ OGLRenderQueue_CheckPreviousOp(jint op)
|
||||
case OGL_STATE_GLYPH_OP:
|
||||
OGLTR_DisableGlyphVertexCache(oglc);
|
||||
break;
|
||||
case OGL_STATE_PGRAM_OP:
|
||||
OGLRenderer_DisableAAParallelogramProgram();
|
||||
break;
|
||||
case OGL_STATE_RESET:
|
||||
case OGL_STATE_CHANGE:
|
||||
// No-op
|
||||
@ -745,6 +839,9 @@ OGLRenderQueue_CheckPreviousOp(jint op)
|
||||
case OGL_STATE_GLYPH_OP:
|
||||
OGLTR_EnableGlyphVertexCache(oglc);
|
||||
break;
|
||||
case OGL_STATE_PGRAM_OP:
|
||||
OGLRenderer_EnableAAParallelogramProgram();
|
||||
break;
|
||||
case OGL_STATE_RESET:
|
||||
case OGL_STATE_CHANGE:
|
||||
// No-op
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -89,6 +89,13 @@
|
||||
*/
|
||||
#define OGL_STATE_GLYPH_OP -4
|
||||
|
||||
/*
|
||||
* Parameter passed to the CHECK_PREVIOUS_OP() macro to indicate that the
|
||||
* following operation represents an operation that renders a
|
||||
* parallelogram via a fragment program (see OGLRenderer).
|
||||
*/
|
||||
#define OGL_STATE_PGRAM_OP -5
|
||||
|
||||
/*
|
||||
* Initializes the "previous operation" state to its default value.
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,6 +27,7 @@
|
||||
|
||||
#include <jlong.h>
|
||||
#include <jni_util.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "sun_java2d_opengl_OGLRenderer.h"
|
||||
|
||||
@ -326,4 +327,486 @@ OGLRenderer_FillSpans(OGLContext *oglc, jint spanCount, jint *spans)
|
||||
}
|
||||
}
|
||||
|
||||
#define FILL_PGRAM(fx11, fy11, dx21, dy21, dx12, dy12) \
|
||||
do { \
|
||||
j2d_glVertex2f(fx11, fy11); \
|
||||
j2d_glVertex2f(fx11 + dx21, fy11 + dy21); \
|
||||
j2d_glVertex2f(fx11 + dx21 + dx12, fy11 + dy21 + dy12); \
|
||||
j2d_glVertex2f(fx11 + dx12, fy11 + dy12); \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
OGLRenderer_FillParallelogram(OGLContext *oglc,
|
||||
jfloat fx11, jfloat fy11,
|
||||
jfloat dx21, jfloat dy21,
|
||||
jfloat dx12, jfloat dy12)
|
||||
{
|
||||
J2dTraceLn6(J2D_TRACE_INFO,
|
||||
"OGLRenderer_FillParallelogram "
|
||||
"(x=%6.2f y=%6.2f "
|
||||
"dx1=%6.2f dy1=%6.2f "
|
||||
"dx2=%6.2f dy2=%6.2f)",
|
||||
fx11, fy11,
|
||||
dx21, dy21,
|
||||
dx12, dy12);
|
||||
|
||||
RETURN_IF_NULL(oglc);
|
||||
|
||||
CHECK_PREVIOUS_OP(GL_QUADS);
|
||||
|
||||
FILL_PGRAM(fx11, fy11, dx21, dy21, dx12, dy12);
|
||||
}
|
||||
|
||||
void
|
||||
OGLRenderer_DrawParallelogram(OGLContext *oglc,
|
||||
jfloat fx11, jfloat fy11,
|
||||
jfloat dx21, jfloat dy21,
|
||||
jfloat dx12, jfloat dy12,
|
||||
jfloat lwr21, jfloat lwr12)
|
||||
{
|
||||
// dx,dy for line width in the "21" and "12" directions.
|
||||
jfloat ldx21 = dx21 * lwr21;
|
||||
jfloat ldy21 = dy21 * lwr21;
|
||||
jfloat ldx12 = dx12 * lwr12;
|
||||
jfloat ldy12 = dy12 * lwr12;
|
||||
|
||||
// calculate origin of the outer parallelogram
|
||||
jfloat ox11 = fx11 - (ldx21 + ldx12) / 2.0f;
|
||||
jfloat oy11 = fy11 - (ldy21 + ldy12) / 2.0f;
|
||||
|
||||
J2dTraceLn8(J2D_TRACE_INFO,
|
||||
"OGLRenderer_DrawParallelogram "
|
||||
"(x=%6.2f y=%6.2f "
|
||||
"dx1=%6.2f dy1=%6.2f lwr1=%6.2f "
|
||||
"dx2=%6.2f dy2=%6.2f lwr2=%6.2f)",
|
||||
fx11, fy11,
|
||||
dx21, dy21, lwr21,
|
||||
dx12, dy12, lwr12);
|
||||
|
||||
RETURN_IF_NULL(oglc);
|
||||
|
||||
CHECK_PREVIOUS_OP(GL_QUADS);
|
||||
|
||||
// Only need to generate 4 quads if the interior still
|
||||
// has a hole in it (i.e. if the line width ratio was
|
||||
// less than 1.0)
|
||||
if (lwr21 < 1.0f && lwr12 < 1.0f) {
|
||||
// Note: "TOP", "BOTTOM", "LEFT" and "RIGHT" here are
|
||||
// relative to whether the dxNN variables are positive
|
||||
// and negative. The math works fine regardless of
|
||||
// their signs, but for conceptual simplicity the
|
||||
// comments will refer to the sides as if the dxNN
|
||||
// were all positive. "TOP" and "BOTTOM" segments
|
||||
// are defined by the dxy21 deltas. "LEFT" and "RIGHT"
|
||||
// segments are defined by the dxy12 deltas.
|
||||
|
||||
// Each segment includes its starting corner and comes
|
||||
// to just short of the following corner. Thus, each
|
||||
// corner is included just once and the only lengths
|
||||
// needed are the original parallelogram delta lengths
|
||||
// and the "line width deltas". The sides will cover
|
||||
// the following relative territories:
|
||||
//
|
||||
// T T T T T R
|
||||
// L R
|
||||
// L R
|
||||
// L R
|
||||
// L R
|
||||
// L B B B B B
|
||||
|
||||
// TOP segment, to left side of RIGHT edge
|
||||
// "width" of original pgram, "height" of hor. line size
|
||||
fx11 = ox11;
|
||||
fy11 = oy11;
|
||||
FILL_PGRAM(fx11, fy11, dx21, dy21, ldx12, ldy12);
|
||||
|
||||
// RIGHT segment, to top of BOTTOM edge
|
||||
// "width" of vert. line size , "height" of original pgram
|
||||
fx11 = ox11 + dx21;
|
||||
fy11 = oy11 + dy21;
|
||||
FILL_PGRAM(fx11, fy11, ldx21, ldy21, dx12, dy12);
|
||||
|
||||
// BOTTOM segment, from right side of LEFT edge
|
||||
// "width" of original pgram, "height" of hor. line size
|
||||
fx11 = ox11 + dx12 + ldx21;
|
||||
fy11 = oy11 + dy12 + ldy21;
|
||||
FILL_PGRAM(fx11, fy11, dx21, dy21, ldx12, ldy12);
|
||||
|
||||
// LEFT segment, from bottom of TOP edge
|
||||
// "width" of vert. line size , "height" of inner pgram
|
||||
fx11 = ox11 + ldx12;
|
||||
fy11 = oy11 + ldy12;
|
||||
FILL_PGRAM(fx11, fy11, ldx21, ldy21, dx12, dy12);
|
||||
} else {
|
||||
// The line width ratios were large enough to consume
|
||||
// the entire hole in the middle of the parallelogram
|
||||
// so we can just issue one large quad for the outer
|
||||
// parallelogram.
|
||||
dx21 += ldx21;
|
||||
dy21 += ldy21;
|
||||
dx12 += ldx12;
|
||||
dy12 += ldy12;
|
||||
FILL_PGRAM(ox11, oy11, dx21, dy21, dx12, dy12);
|
||||
}
|
||||
}
|
||||
|
||||
static GLhandleARB aaPgramProgram = 0;
|
||||
|
||||
/*
|
||||
* This shader fills the space between an outer and inner parallelogram.
|
||||
* It can be used to draw an outline by specifying both inner and outer
|
||||
* values. It fills pixels by estimating what portion falls inside the
|
||||
* outer shape, and subtracting an estimate of what portion falls inside
|
||||
* the inner shape. Specifying both inner and outer values produces a
|
||||
* standard "wide outline". Specifying an inner shape that falls far
|
||||
* outside the outer shape allows the same shader to fill the outer
|
||||
* shape entirely since pixels that fall within the outer shape are never
|
||||
* inside the inner shape and so they are filled based solely on their
|
||||
* coverage of the outer shape.
|
||||
*
|
||||
* The setup code renders this shader over the bounds of the outer
|
||||
* shape (or the only shape in the case of a fill operation) and
|
||||
* sets the texture 0 coordinates so that 0,0=>0,1=>1,1=>1,0 in those
|
||||
* texture coordinates map to the four corners of the parallelogram.
|
||||
* Similarly the texture 1 coordinates map the inner shape to the
|
||||
* unit square as well, but in a different coordinate system.
|
||||
*
|
||||
* When viewed in the texture coordinate systems the parallelograms
|
||||
* we are filling are unit squares, but the pixels have then become
|
||||
* tiny parallelograms themselves. Both of the texture coordinate
|
||||
* systems are affine transforms so the rate of change in X and Y
|
||||
* of the texture coordinates are essentially constants and happen
|
||||
* to correspond to the size and direction of the slanted sides of
|
||||
* the distorted pixels relative to the "square mapped" boundary
|
||||
* of the parallelograms.
|
||||
*
|
||||
* The shader uses the dFdx() and dFdy() functions to measure the "rate
|
||||
* of change" of these texture coordinates and thus gets an accurate
|
||||
* measure of the size and shape of a pixel relative to the two
|
||||
* parallelograms. It then uses the bounds of the size and shape
|
||||
* of a pixel to intersect with the unit square to estimate the
|
||||
* coverage of the pixel. Unfortunately, without a lot more work
|
||||
* to calculate the exact area of intersection between a unit
|
||||
* square (the original parallelogram) and a parallelogram (the
|
||||
* distorted pixel), this shader only approximates the pixel
|
||||
* coverage, but emperically the estimate is very useful and
|
||||
* produces visually pleasing results, if not theoretically accurate.
|
||||
*/
|
||||
static const char *aaPgramShaderSource =
|
||||
"void main() {"
|
||||
// Calculate the vectors for the "legs" of the pixel parallelogram
|
||||
// for the outer parallelogram.
|
||||
" vec2 oleg1 = dFdx(gl_TexCoord[0].st);"
|
||||
" vec2 oleg2 = dFdy(gl_TexCoord[0].st);"
|
||||
// Calculate the bounds of the distorted pixel parallelogram.
|
||||
" vec2 corner = gl_TexCoord[0].st - (oleg1+oleg2)/2.0;"
|
||||
" vec2 omin = min(corner, corner+oleg1);"
|
||||
" omin = min(omin, corner+oleg2);"
|
||||
" omin = min(omin, corner+oleg1+oleg2);"
|
||||
" vec2 omax = max(corner, corner+oleg1);"
|
||||
" omax = max(omax, corner+oleg2);"
|
||||
" omax = max(omax, corner+oleg1+oleg2);"
|
||||
// Calculate the vectors for the "legs" of the pixel parallelogram
|
||||
// for the inner parallelogram.
|
||||
" vec2 ileg1 = dFdx(gl_TexCoord[1].st);"
|
||||
" vec2 ileg2 = dFdy(gl_TexCoord[1].st);"
|
||||
// Calculate the bounds of the distorted pixel parallelogram.
|
||||
" corner = gl_TexCoord[1].st - (ileg1+ileg2)/2.0;"
|
||||
" vec2 imin = min(corner, corner+ileg1);"
|
||||
" imin = min(imin, corner+ileg2);"
|
||||
" imin = min(imin, corner+ileg1+ileg2);"
|
||||
" vec2 imax = max(corner, corner+ileg1);"
|
||||
" imax = max(imax, corner+ileg2);"
|
||||
" imax = max(imax, corner+ileg1+ileg2);"
|
||||
// Clamp the bounds of the parallelograms to the unit square to
|
||||
// estimate the intersection of the pixel parallelogram with
|
||||
// the unit square. The ratio of the 2 rectangle areas is a
|
||||
// reasonable estimate of the proportion of coverage.
|
||||
" vec2 o1 = clamp(omin, 0.0, 1.0);"
|
||||
" vec2 o2 = clamp(omax, 0.0, 1.0);"
|
||||
" float oint = (o2.y-o1.y)*(o2.x-o1.x);"
|
||||
" float oarea = (omax.y-omin.y)*(omax.x-omin.x);"
|
||||
" vec2 i1 = clamp(imin, 0.0, 1.0);"
|
||||
" vec2 i2 = clamp(imax, 0.0, 1.0);"
|
||||
" float iint = (i2.y-i1.y)*(i2.x-i1.x);"
|
||||
" float iarea = (imax.y-imin.y)*(imax.x-imin.x);"
|
||||
// Proportion of pixel in outer shape minus the proportion
|
||||
// of pixel in the inner shape == the coverage of the pixel
|
||||
// in the area between the two.
|
||||
" float coverage = oint/oarea - iint / iarea;"
|
||||
" gl_FragColor = gl_Color * coverage;"
|
||||
"}";
|
||||
|
||||
#define ADJUST_PGRAM(V1, DV, V2) \
|
||||
do { \
|
||||
if ((DV) >= 0) { \
|
||||
(V2) += (DV); \
|
||||
} else { \
|
||||
(V1) += (DV); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
// Invert the following transform:
|
||||
// DeltaT(0, 0) == (0, 0)
|
||||
// DeltaT(1, 0) == (DX1, DY1)
|
||||
// DeltaT(0, 1) == (DX2, DY2)
|
||||
// DeltaT(1, 1) == (DX1+DX2, DY1+DY2)
|
||||
// TM00 = DX1, TM01 = DX2, (TM02 = X11)
|
||||
// TM10 = DY1, TM11 = DY2, (TM12 = Y11)
|
||||
// Determinant = TM00*TM11 - TM01*TM10
|
||||
// = DX1*DY2 - DX2*DY1
|
||||
// Inverse is:
|
||||
// IM00 = TM11/det, IM01 = -TM01/det
|
||||
// IM10 = -TM10/det, IM11 = TM00/det
|
||||
// IM02 = (TM01 * TM12 - TM11 * TM02) / det,
|
||||
// IM12 = (TM10 * TM02 - TM00 * TM12) / det,
|
||||
|
||||
#define DECLARE_MATRIX(MAT) \
|
||||
jfloat MAT ## 00, MAT ## 01, MAT ## 02, MAT ## 10, MAT ## 11, MAT ## 12
|
||||
|
||||
#define GET_INVERTED_MATRIX(MAT, X11, Y11, DX1, DY1, DX2, DY2, RET_CODE) \
|
||||
do { \
|
||||
jfloat det = DX1*DY2 - DX2*DY1; \
|
||||
if (det == 0) { \
|
||||
RET_CODE; \
|
||||
} \
|
||||
MAT ## 00 = DY2/det; \
|
||||
MAT ## 01 = -DX2/det; \
|
||||
MAT ## 10 = -DY1/det; \
|
||||
MAT ## 11 = DX1/det; \
|
||||
MAT ## 02 = (DX2 * Y11 - DY2 * X11) / det; \
|
||||
MAT ## 12 = (DY1 * X11 - DX1 * Y11) / det; \
|
||||
} while (0)
|
||||
|
||||
#define TRANSFORM(MAT, TX, TY, X, Y) \
|
||||
do { \
|
||||
TX = (X) * MAT ## 00 + (Y) * MAT ## 01 + MAT ## 02; \
|
||||
TY = (X) * MAT ## 10 + (Y) * MAT ## 11 + MAT ## 12; \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
OGLRenderer_FillAAParallelogram(OGLContext *oglc, OGLSDOps *dstOps,
|
||||
jfloat fx11, jfloat fy11,
|
||||
jfloat dx21, jfloat dy21,
|
||||
jfloat dx12, jfloat dy12)
|
||||
{
|
||||
DECLARE_MATRIX(om);
|
||||
// parameters for parallelogram bounding box
|
||||
jfloat bx11, by11, bx22, by22;
|
||||
// parameters for uv texture coordinates of parallelogram corners
|
||||
jfloat u11, v11, u12, v12, u21, v21, u22, v22;
|
||||
|
||||
J2dTraceLn6(J2D_TRACE_INFO,
|
||||
"OGLRenderer_FillAAParallelogram "
|
||||
"(x=%6.2f y=%6.2f "
|
||||
"dx1=%6.2f dy1=%6.2f "
|
||||
"dx2=%6.2f dy2=%6.2f)",
|
||||
fx11, fy11,
|
||||
dx21, dy21,
|
||||
dx12, dy12);
|
||||
|
||||
RETURN_IF_NULL(oglc);
|
||||
RETURN_IF_NULL(dstOps);
|
||||
|
||||
GET_INVERTED_MATRIX(om, fx11, fy11, dx21, dy21, dx12, dy12,
|
||||
return);
|
||||
|
||||
CHECK_PREVIOUS_OP(OGL_STATE_PGRAM_OP);
|
||||
|
||||
bx11 = bx22 = fx11;
|
||||
by11 = by22 = fy11;
|
||||
ADJUST_PGRAM(bx11, dx21, bx22);
|
||||
ADJUST_PGRAM(by11, dy21, by22);
|
||||
ADJUST_PGRAM(bx11, dx12, bx22);
|
||||
ADJUST_PGRAM(by11, dy12, by22);
|
||||
bx11 = (jfloat) floor(bx11);
|
||||
by11 = (jfloat) floor(by11);
|
||||
bx22 = (jfloat) ceil(bx22);
|
||||
by22 = (jfloat) ceil(by22);
|
||||
|
||||
TRANSFORM(om, u11, v11, bx11, by11);
|
||||
TRANSFORM(om, u21, v21, bx22, by11);
|
||||
TRANSFORM(om, u12, v12, bx11, by22);
|
||||
TRANSFORM(om, u22, v22, bx22, by22);
|
||||
|
||||
j2d_glBegin(GL_QUADS);
|
||||
j2d_glMultiTexCoord2fARB(GL_TEXTURE0_ARB, u11, v11);
|
||||
j2d_glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 5.f, 5.f);
|
||||
j2d_glVertex2f(bx11, by11);
|
||||
j2d_glMultiTexCoord2fARB(GL_TEXTURE0_ARB, u21, v21);
|
||||
j2d_glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 6.f, 5.f);
|
||||
j2d_glVertex2f(bx22, by11);
|
||||
j2d_glMultiTexCoord2fARB(GL_TEXTURE0_ARB, u22, v22);
|
||||
j2d_glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 6.f, 6.f);
|
||||
j2d_glVertex2f(bx22, by22);
|
||||
j2d_glMultiTexCoord2fARB(GL_TEXTURE0_ARB, u12, v12);
|
||||
j2d_glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 5.f, 6.f);
|
||||
j2d_glVertex2f(bx11, by22);
|
||||
j2d_glEnd();
|
||||
}
|
||||
|
||||
void
|
||||
OGLRenderer_FillAAParallelogramInnerOuter(OGLContext *oglc, OGLSDOps *dstOps,
|
||||
jfloat ox11, jfloat oy11,
|
||||
jfloat ox21, jfloat oy21,
|
||||
jfloat ox12, jfloat oy12,
|
||||
jfloat ix11, jfloat iy11,
|
||||
jfloat ix21, jfloat iy21,
|
||||
jfloat ix12, jfloat iy12)
|
||||
{
|
||||
DECLARE_MATRIX(om);
|
||||
DECLARE_MATRIX(im);
|
||||
// parameters for parallelogram bounding box
|
||||
jfloat bx11, by11, bx22, by22;
|
||||
// parameters for uv texture coordinates of outer parallelogram corners
|
||||
jfloat ou11, ov11, ou12, ov12, ou21, ov21, ou22, ov22;
|
||||
// parameters for uv texture coordinates of inner parallelogram corners
|
||||
jfloat iu11, iv11, iu12, iv12, iu21, iv21, iu22, iv22;
|
||||
|
||||
RETURN_IF_NULL(oglc);
|
||||
RETURN_IF_NULL(dstOps);
|
||||
|
||||
GET_INVERTED_MATRIX(im, ix11, iy11, ix21, iy21, ix12, iy12,
|
||||
// inner parallelogram is degenerate
|
||||
// therefore it encloses no area
|
||||
// fill outer
|
||||
OGLRenderer_FillAAParallelogram(oglc, dstOps,
|
||||
ox11, oy11,
|
||||
ox21, oy21,
|
||||
ox12, oy12);
|
||||
return);
|
||||
GET_INVERTED_MATRIX(om, ox11, oy11, ox21, oy21, ox12, oy12,
|
||||
return);
|
||||
|
||||
CHECK_PREVIOUS_OP(OGL_STATE_PGRAM_OP);
|
||||
|
||||
bx11 = bx22 = ox11;
|
||||
by11 = by22 = oy11;
|
||||
ADJUST_PGRAM(bx11, ox21, bx22);
|
||||
ADJUST_PGRAM(by11, oy21, by22);
|
||||
ADJUST_PGRAM(bx11, ox12, bx22);
|
||||
ADJUST_PGRAM(by11, oy12, by22);
|
||||
bx11 = (jfloat) floor(bx11);
|
||||
by11 = (jfloat) floor(by11);
|
||||
bx22 = (jfloat) ceil(bx22);
|
||||
by22 = (jfloat) ceil(by22);
|
||||
|
||||
TRANSFORM(om, ou11, ov11, bx11, by11);
|
||||
TRANSFORM(om, ou21, ov21, bx22, by11);
|
||||
TRANSFORM(om, ou12, ov12, bx11, by22);
|
||||
TRANSFORM(om, ou22, ov22, bx22, by22);
|
||||
|
||||
TRANSFORM(im, iu11, iv11, bx11, by11);
|
||||
TRANSFORM(im, iu21, iv21, bx22, by11);
|
||||
TRANSFORM(im, iu12, iv12, bx11, by22);
|
||||
TRANSFORM(im, iu22, iv22, bx22, by22);
|
||||
|
||||
j2d_glBegin(GL_QUADS);
|
||||
j2d_glMultiTexCoord2fARB(GL_TEXTURE0_ARB, ou11, ov11);
|
||||
j2d_glMultiTexCoord2fARB(GL_TEXTURE1_ARB, iu11, iv11);
|
||||
j2d_glVertex2f(bx11, by11);
|
||||
j2d_glMultiTexCoord2fARB(GL_TEXTURE0_ARB, ou21, ov21);
|
||||
j2d_glMultiTexCoord2fARB(GL_TEXTURE1_ARB, iu21, iv21);
|
||||
j2d_glVertex2f(bx22, by11);
|
||||
j2d_glMultiTexCoord2fARB(GL_TEXTURE0_ARB, ou22, ov22);
|
||||
j2d_glMultiTexCoord2fARB(GL_TEXTURE1_ARB, iu22, iv22);
|
||||
j2d_glVertex2f(bx22, by22);
|
||||
j2d_glMultiTexCoord2fARB(GL_TEXTURE0_ARB, ou12, ov12);
|
||||
j2d_glMultiTexCoord2fARB(GL_TEXTURE1_ARB, iu12, iv12);
|
||||
j2d_glVertex2f(bx11, by22);
|
||||
j2d_glEnd();
|
||||
}
|
||||
|
||||
void
|
||||
OGLRenderer_DrawAAParallelogram(OGLContext *oglc, OGLSDOps *dstOps,
|
||||
jfloat fx11, jfloat fy11,
|
||||
jfloat dx21, jfloat dy21,
|
||||
jfloat dx12, jfloat dy12,
|
||||
jfloat lwr21, jfloat lwr12)
|
||||
{
|
||||
// dx,dy for line width in the "21" and "12" directions.
|
||||
jfloat ldx21, ldy21, ldx12, ldy12;
|
||||
// parameters for "outer" parallelogram
|
||||
jfloat ofx11, ofy11, odx21, ody21, odx12, ody12;
|
||||
// parameters for "inner" parallelogram
|
||||
jfloat ifx11, ify11, idx21, idy21, idx12, idy12;
|
||||
|
||||
J2dTraceLn8(J2D_TRACE_INFO,
|
||||
"OGLRenderer_DrawAAParallelogram "
|
||||
"(x=%6.2f y=%6.2f "
|
||||
"dx1=%6.2f dy1=%6.2f lwr1=%6.2f "
|
||||
"dx2=%6.2f dy2=%6.2f lwr2=%6.2f)",
|
||||
fx11, fy11,
|
||||
dx21, dy21, lwr21,
|
||||
dx12, dy12, lwr12);
|
||||
|
||||
RETURN_IF_NULL(oglc);
|
||||
RETURN_IF_NULL(dstOps);
|
||||
|
||||
// calculate true dx,dy for line widths from the "line width ratios"
|
||||
ldx21 = dx21 * lwr21;
|
||||
ldy21 = dy21 * lwr21;
|
||||
ldx12 = dx12 * lwr12;
|
||||
ldy12 = dy12 * lwr12;
|
||||
|
||||
// calculate coordinates of the outer parallelogram
|
||||
ofx11 = fx11 - (ldx21 + ldx12) / 2.0f;
|
||||
ofy11 = fy11 - (ldy21 + ldy12) / 2.0f;
|
||||
odx21 = dx21 + ldx21;
|
||||
ody21 = dy21 + ldy21;
|
||||
odx12 = dx12 + ldx12;
|
||||
ody12 = dy12 + ldy12;
|
||||
|
||||
// Only process the inner parallelogram if the line width ratio
|
||||
// did not consume the entire interior of the parallelogram
|
||||
// (i.e. if the width ratio was less than 1.0)
|
||||
if (lwr21 < 1.0f && lwr12 < 1.0f) {
|
||||
// calculate coordinates of the inner parallelogram
|
||||
ifx11 = fx11 + (ldx21 + ldx12) / 2.0f;
|
||||
ify11 = fy11 + (ldy21 + ldy12) / 2.0f;
|
||||
idx21 = dx21 - ldx21;
|
||||
idy21 = dy21 - ldy21;
|
||||
idx12 = dx12 - ldx12;
|
||||
idy12 = dy12 - ldy12;
|
||||
|
||||
OGLRenderer_FillAAParallelogramInnerOuter(oglc, dstOps,
|
||||
ofx11, ofy11,
|
||||
odx21, ody21,
|
||||
odx12, ody12,
|
||||
ifx11, ify11,
|
||||
idx21, idy21,
|
||||
idx12, idy12);
|
||||
} else {
|
||||
OGLRenderer_FillAAParallelogram(oglc, dstOps,
|
||||
ofx11, ofy11,
|
||||
odx21, ody21,
|
||||
odx12, ody12);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
OGLRenderer_EnableAAParallelogramProgram()
|
||||
{
|
||||
J2dTraceLn(J2D_TRACE_INFO, "OGLRenderer_EnableAAParallelogramProgram");
|
||||
|
||||
if (aaPgramProgram == 0) {
|
||||
aaPgramProgram = OGLContext_CreateFragmentProgram(aaPgramShaderSource);
|
||||
if (aaPgramProgram == 0) {
|
||||
J2dRlsTraceLn(J2D_TRACE_ERROR,
|
||||
"OGLRenderer_EnableAAParallelogramProgram: "
|
||||
"error creating program");
|
||||
return;
|
||||
}
|
||||
}
|
||||
j2d_glUseProgramObjectARB(aaPgramProgram);
|
||||
}
|
||||
|
||||
void
|
||||
OGLRenderer_DisableAAParallelogramProgram()
|
||||
{
|
||||
J2dTraceLn(J2D_TRACE_INFO, "OGLRenderer_DisableAAParallelogramProgram");
|
||||
|
||||
j2d_glUseProgramObjectARB(0);
|
||||
}
|
||||
|
||||
#endif /* !HEADLESS */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -46,9 +46,31 @@ void OGLRenderer_DrawPoly(OGLContext *oglc,
|
||||
jint *xPoints, jint *yPoints);
|
||||
void OGLRenderer_DrawScanlines(OGLContext *oglc,
|
||||
jint count, jint *scanlines);
|
||||
void OGLRenderer_DrawParallelogram(OGLContext *oglc,
|
||||
jfloat fx11, jfloat fy11,
|
||||
jfloat dx21, jfloat dy21,
|
||||
jfloat dx12, jfloat dy12,
|
||||
jfloat lw21, jfloat lw12);
|
||||
void OGLRenderer_DrawAAParallelogram(OGLContext *oglc, OGLSDOps *dstOps,
|
||||
jfloat fx11, jfloat fy11,
|
||||
jfloat dx21, jfloat dy21,
|
||||
jfloat dx12, jfloat dy12,
|
||||
jfloat lw21, jfloat lw12);
|
||||
|
||||
void OGLRenderer_FillRect(OGLContext *oglc,
|
||||
jint x, jint y, jint w, jint h);
|
||||
void OGLRenderer_FillSpans(OGLContext *oglc,
|
||||
jint count, jint *spans);
|
||||
void OGLRenderer_FillParallelogram(OGLContext *oglc,
|
||||
jfloat fx11, jfloat fy11,
|
||||
jfloat dx21, jfloat dy21,
|
||||
jfloat dx12, jfloat dy12);
|
||||
void OGLRenderer_FillAAParallelogram(OGLContext *oglc, OGLSDOps *dstOps,
|
||||
jfloat fx11, jfloat fy11,
|
||||
jfloat dx21, jfloat dy21,
|
||||
jfloat dx12, jfloat dy12);
|
||||
|
||||
void OGLRenderer_EnableAAParallelogramProgram();
|
||||
void OGLRenderer_DisableAAParallelogramProgram();
|
||||
|
||||
#endif /* OGLRenderer_h_Included */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -41,6 +41,8 @@ extern jlong OGLSD_GetNativeConfigInfo(OGLSDOps *oglsdo);
|
||||
extern jboolean OGLSD_InitOGLWindow(JNIEnv *env, OGLSDOps *oglsdo);
|
||||
extern void OGLSD_DestroyOGLSurface(JNIEnv *env, OGLSDOps *oglsdo);
|
||||
|
||||
void OGLSD_SetNativeDimensions(JNIEnv *env, OGLSDOps *oglsdo, jint w, jint h);
|
||||
|
||||
/**
|
||||
* This table contains the "pixel formats" for all system memory surfaces
|
||||
* that OpenGL is capable of handling, indexed by the "PF_" constants defined
|
||||
@ -269,6 +271,9 @@ Java_sun_java2d_opengl_OGLSurfaceData_initTexture
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
OGLSD_SetNativeDimensions(env, oglsdo,
|
||||
oglsdo->textureWidth, oglsdo->textureHeight);
|
||||
|
||||
oglsdo->drawableType = OGLSD_TEXTURE;
|
||||
// other fields (e.g. width, height) are set in OGLSD_InitTextureObject()
|
||||
|
||||
@ -427,6 +432,9 @@ Java_sun_java2d_opengl_OGLSurfaceData_initFBObject
|
||||
oglsdo->fbobjectID = fbobjectID;
|
||||
oglsdo->depthID = depthID;
|
||||
|
||||
OGLSD_SetNativeDimensions(env, oglsdo,
|
||||
oglsdo->textureWidth, oglsdo->textureHeight);
|
||||
|
||||
// framebuffer objects differ from other OpenGL surfaces in that the
|
||||
// value passed to glRead/DrawBuffer() must be GL_COLOR_ATTACHMENTn_EXT,
|
||||
// rather than GL_FRONT (or GL_BACK)
|
||||
@ -476,6 +484,8 @@ Java_sun_java2d_opengl_OGLSurfaceData_initFlipBackbuffer
|
||||
// explicitly use BACK_LEFT rather than BACK...
|
||||
oglsdo->activeBuffer = GL_BACK_LEFT;
|
||||
|
||||
OGLSD_SetNativeDimensions(env, oglsdo, oglsdo->width, oglsdo->height);
|
||||
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
@ -497,6 +507,45 @@ Java_sun_java2d_opengl_OGLSurfaceData_getTextureTarget
|
||||
return (jint)oglsdo->textureTarget;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_sun_java2d_opengl_OGLSurfaceData_getTextureID
|
||||
(JNIEnv *env, jobject oglsd,
|
||||
jlong pData)
|
||||
{
|
||||
OGLSDOps *oglsdo = (OGLSDOps *)jlong_to_ptr(pData);
|
||||
|
||||
J2dTraceLn(J2D_TRACE_INFO, "OGLSurfaceData_getTextureID");
|
||||
|
||||
if (oglsdo == NULL) {
|
||||
J2dRlsTraceLn(J2D_TRACE_ERROR,
|
||||
"OGLSurfaceData_getTextureID: ops are null");
|
||||
return 0L;
|
||||
}
|
||||
|
||||
return (jint)oglsdo->textureID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes nativeWidth/Height fields of the surfaceData object with
|
||||
* passed arguments.
|
||||
*/
|
||||
void
|
||||
OGLSD_SetNativeDimensions(JNIEnv *env, OGLSDOps *oglsdo,
|
||||
jint width, jint height)
|
||||
{
|
||||
jobject sdObject;
|
||||
|
||||
sdObject = (*env)->NewLocalRef(env, oglsdo->sdOps.sdObject);
|
||||
if (sdObject == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
JNU_SetFieldByName(env, NULL, sdObject, "nativeWidth", "I", width);
|
||||
JNU_SetFieldByName(env, NULL, sdObject, "nativeHeight", "I", height);
|
||||
|
||||
(*env)->DeleteLocalRef(env, sdObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disposes of all native resources associated with this surface.
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,6 +28,7 @@
|
||||
|
||||
#include "java_awt_image_AffineTransformOp.h"
|
||||
#include "sun_java2d_opengl_OGLSurfaceData.h"
|
||||
#include "sun_java2d_pipe_hw_AccelSurface.h"
|
||||
|
||||
#include "J2D_GL/gl.h"
|
||||
#include "SurfaceData.h"
|
||||
@ -215,12 +216,12 @@ struct _OGLSDOps {
|
||||
* These are shorthand names for the surface type constants defined in
|
||||
* OGLSurfaceData.java.
|
||||
*/
|
||||
#define OGLSD_UNDEFINED sun_java2d_opengl_OGLSurfaceData_UNDEFINED
|
||||
#define OGLSD_WINDOW sun_java2d_opengl_OGLSurfaceData_WINDOW
|
||||
#define OGLSD_PBUFFER sun_java2d_opengl_OGLSurfaceData_PBUFFER
|
||||
#define OGLSD_TEXTURE sun_java2d_opengl_OGLSurfaceData_TEXTURE
|
||||
#define OGLSD_FLIP_BACKBUFFER sun_java2d_opengl_OGLSurfaceData_FLIP_BACKBUFFER
|
||||
#define OGLSD_FBOBJECT sun_java2d_opengl_OGLSurfaceData_FBOBJECT
|
||||
#define OGLSD_UNDEFINED sun_java2d_pipe_hw_AccelSurface_UNDEFINED
|
||||
#define OGLSD_WINDOW sun_java2d_pipe_hw_AccelSurface_WINDOW
|
||||
#define OGLSD_PBUFFER sun_java2d_pipe_hw_AccelSurface_RT_PLAIN
|
||||
#define OGLSD_TEXTURE sun_java2d_pipe_hw_AccelSurface_TEXTURE
|
||||
#define OGLSD_FLIP_BACKBUFFER sun_java2d_pipe_hw_AccelSurface_FLIP_BACKBUFFER
|
||||
#define OGLSD_FBOBJECT sun_java2d_pipe_hw_AccelSurface_RT_TEXTURE
|
||||
|
||||
/**
|
||||
* These are shorthand names for the filtering method constants used by
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -59,7 +59,6 @@ Java_sun_java2d_pipe_BufferedMaskBlit_enqueueTile
|
||||
{
|
||||
SurfaceDataOps *srcOps = (SurfaceDataOps *)jlong_to_ptr(pSrcOps);
|
||||
SurfaceDataRasInfo srcInfo;
|
||||
unsigned char *pMask;
|
||||
unsigned char *bbuf;
|
||||
jint *pBuf;
|
||||
|
||||
@ -97,13 +96,6 @@ Java_sun_java2d_pipe_BufferedMaskBlit_enqueueTile
|
||||
return bpos;
|
||||
}
|
||||
|
||||
pMask = (*env)->GetPrimitiveArrayCritical(env, maskArray, 0);
|
||||
if (pMask == NULL) {
|
||||
J2dRlsTraceLn(J2D_TRACE_ERROR,
|
||||
"BufferedMaskBlit_enqueueTile: cannot lock mask array");
|
||||
return bpos;
|
||||
}
|
||||
|
||||
srcInfo.bounds.x1 = srcx;
|
||||
srcInfo.bounds.y1 = srcy;
|
||||
srcInfo.bounds.x2 = srcx + width;
|
||||
@ -112,8 +104,6 @@ Java_sun_java2d_pipe_BufferedMaskBlit_enqueueTile
|
||||
if (srcOps->Lock(env, srcOps, &srcInfo, SD_LOCK_READ) != SD_SUCCESS) {
|
||||
J2dRlsTraceLn(J2D_TRACE_WARNING,
|
||||
"BufferedMaskBlit_enqueueTile: could not acquire lock");
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, maskArray,
|
||||
pMask, JNI_ABORT);
|
||||
return bpos;
|
||||
}
|
||||
|
||||
@ -129,6 +119,15 @@ Java_sun_java2d_pipe_BufferedMaskBlit_enqueueTile
|
||||
PtrCoord(srcInfo.rasBase,
|
||||
srcInfo.bounds.x1, srcInfo.pixelStride,
|
||||
srcInfo.bounds.y1, srcInfo.scanStride);
|
||||
unsigned char *pMask =
|
||||
(*env)->GetPrimitiveArrayCritical(env, maskArray, 0);
|
||||
if (pMask == NULL) {
|
||||
J2dRlsTraceLn(J2D_TRACE_ERROR,
|
||||
"BufferedMaskBlit_enqueueTile: cannot lock mask array");
|
||||
SurfaceData_InvokeRelease(env, srcOps, &srcInfo);
|
||||
SurfaceData_InvokeUnlock(env, srcOps, &srcInfo);
|
||||
return bpos;
|
||||
}
|
||||
|
||||
width = srcInfo.bounds.x2 - srcInfo.bounds.x1;
|
||||
height = srcInfo.bounds.y2 - srcInfo.bounds.y1;
|
||||
@ -166,18 +165,22 @@ Java_sun_java2d_pipe_BufferedMaskBlit_enqueueTile
|
||||
do {
|
||||
jint w = width;
|
||||
do {
|
||||
jubyte pathA = *pMask++;
|
||||
jint pathA = *pMask++;
|
||||
if (!pathA) {
|
||||
pBuf[0] = 0;
|
||||
} else {
|
||||
jint cr, cg, cb, ca;
|
||||
jubyte r, g, b, a;
|
||||
LoadIntArgbTo4ByteArgb(pSrc, c, 0, ca, cr, cg, cb);
|
||||
a = MUL8(ca, pathA);
|
||||
r = MUL8(cr, a);
|
||||
g = MUL8(cg, a);
|
||||
b = MUL8(cb, a);
|
||||
pBuf[0] = (a << 24) | (r << 16) | (g << 8) | b;
|
||||
jint pixel = pSrc[0];
|
||||
if (pathA == 0xff && (pixel >> 24) + 1 == 0) {
|
||||
pBuf[0] = pixel;
|
||||
} else {
|
||||
jint r, g, b, a;
|
||||
ExtractIntDcmComponents1234(pixel, a, r, g, b);
|
||||
a = MUL8(pathA, a);
|
||||
r = MUL8(a, r);
|
||||
g = MUL8(a, g);
|
||||
b = MUL8(a, b);
|
||||
pBuf[0] = (a << 24) | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
}
|
||||
pSrc = PtrAddBytes(pSrc, srcPixelStride);
|
||||
pBuf++;
|
||||
@ -191,17 +194,17 @@ Java_sun_java2d_pipe_BufferedMaskBlit_enqueueTile
|
||||
do {
|
||||
jint w = width;
|
||||
do {
|
||||
jubyte pathA = *pMask++;
|
||||
jint pathA = *pMask++;
|
||||
if (!pathA) {
|
||||
pBuf[0] = 0;
|
||||
} else if (pathA == 0xff) {
|
||||
pBuf[0] = pSrc[0];
|
||||
} else {
|
||||
jubyte r, g, b, a;
|
||||
a = MUL8((pSrc[0] >> 24) & 0xff, pathA);
|
||||
r = MUL8((pSrc[0] >> 16) & 0xff, pathA);
|
||||
g = MUL8((pSrc[0] >> 8) & 0xff, pathA);
|
||||
b = MUL8((pSrc[0] >> 0) & 0xff, pathA);
|
||||
jint r, g, b, a;
|
||||
a = MUL8(pathA, (pSrc[0] >> 24) & 0xff);
|
||||
r = MUL8(pathA, (pSrc[0] >> 16) & 0xff);
|
||||
g = MUL8(pathA, (pSrc[0] >> 8) & 0xff);
|
||||
b = MUL8(pathA, (pSrc[0] >> 0) & 0xff);
|
||||
pBuf[0] = (a << 24) | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
pSrc = PtrAddBytes(pSrc, srcPixelStride);
|
||||
@ -216,17 +219,18 @@ Java_sun_java2d_pipe_BufferedMaskBlit_enqueueTile
|
||||
do {
|
||||
jint w = width;
|
||||
do {
|
||||
jubyte pathA = *pMask++;
|
||||
jint pathA = *pMask++;
|
||||
if (!pathA) {
|
||||
pBuf[0] = 0;
|
||||
} else if (pathA == 0xff) {
|
||||
pBuf[0] = pSrc[0] | 0xff000000;
|
||||
} else {
|
||||
jint cr, cg, cb;
|
||||
jubyte r, g, b, a;
|
||||
LoadIntRgbTo3ByteRgb(pSrc, c, 0, cr, cg, cb);
|
||||
jint r, g, b, a;
|
||||
LoadIntRgbTo3ByteRgb(pSrc, c, 0, r, g, b);
|
||||
a = pathA;
|
||||
r = MUL8(cr, a);
|
||||
g = MUL8(cg, a);
|
||||
b = MUL8(cb, a);
|
||||
r = MUL8(a, r);
|
||||
g = MUL8(a, g);
|
||||
b = MUL8(a, b);
|
||||
pBuf[0] = (a << 24) | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
pSrc = PtrAddBytes(pSrc, srcPixelStride);
|
||||
@ -241,17 +245,16 @@ Java_sun_java2d_pipe_BufferedMaskBlit_enqueueTile
|
||||
do {
|
||||
jint w = width;
|
||||
do {
|
||||
jubyte pathA = *pMask++;
|
||||
jint pathA = *pMask++;
|
||||
if (!pathA) {
|
||||
pBuf[0] = 0;
|
||||
} else {
|
||||
jint cr, cg, cb;
|
||||
jubyte r, g, b, a;
|
||||
LoadIntBgrTo3ByteRgb(pSrc, c, 0, cr, cg, cb);
|
||||
jint r, g, b, a;
|
||||
LoadIntBgrTo3ByteRgb(pSrc, c, 0, r, g, b);
|
||||
a = pathA;
|
||||
r = MUL8(cr, a);
|
||||
g = MUL8(cg, a);
|
||||
b = MUL8(cb, a);
|
||||
r = MUL8(a, r);
|
||||
g = MUL8(a, g);
|
||||
b = MUL8(a, b);
|
||||
pBuf[0] = (a << 24) | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
pSrc = PtrAddBytes(pSrc, srcPixelStride);
|
||||
@ -269,14 +272,14 @@ Java_sun_java2d_pipe_BufferedMaskBlit_enqueueTile
|
||||
|
||||
// increment current byte position
|
||||
bpos += width * height * sizeof(jint);
|
||||
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, maskArray,
|
||||
pMask, JNI_ABORT);
|
||||
}
|
||||
SurfaceData_InvokeRelease(env, srcOps, &srcInfo);
|
||||
}
|
||||
SurfaceData_InvokeUnlock(env, srcOps, &srcInfo);
|
||||
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, maskArray,
|
||||
pMask, JNI_ABORT);
|
||||
|
||||
// return the current byte position
|
||||
return bpos;
|
||||
}
|
||||
|
@ -70,9 +70,12 @@ import sun.awt.*;
|
||||
import sun.awt.event.IgnorePaintEvent;
|
||||
import sun.awt.image.SunVolatileImage;
|
||||
import sun.awt.image.ToolkitImage;
|
||||
import sun.java2d.BackBufferCapsProvider;
|
||||
import sun.java2d.pipe.Region;
|
||||
|
||||
public class XComponentPeer extends XWindow implements ComponentPeer, DropTargetPeer {
|
||||
public class XComponentPeer extends XWindow implements ComponentPeer, DropTargetPeer,
|
||||
BackBufferCapsProvider
|
||||
{
|
||||
/* FIX ME: these constants copied from java.awt.KeyboardFocusManager */
|
||||
static final int SNFH_FAILURE = 0;
|
||||
static final int SNFH_SUCCESS_HANDLED = 1;
|
||||
@ -1274,25 +1277,37 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
|
||||
* native windowing system specific actions.
|
||||
*/
|
||||
|
||||
private BufferCapabilities backBufferCaps;
|
||||
|
||||
public void createBuffers(int numBuffers, BufferCapabilities caps)
|
||||
throws AWTException
|
||||
{
|
||||
if (buffersLog.isLoggable(Level.FINE)) {
|
||||
buffersLog.fine("createBuffers(" + numBuffers + ", " + caps + ")");
|
||||
}
|
||||
// set the caps first, they're used when creating the bb
|
||||
backBufferCaps = caps;
|
||||
backBuffer = graphicsConfig.createBackBuffer(this, numBuffers, caps);
|
||||
xBackBuffer = graphicsConfig.createBackBufferImage(target,
|
||||
backBuffer);
|
||||
}
|
||||
|
||||
public void flip(BufferCapabilities.FlipContents flipAction) {
|
||||
@Override
|
||||
public BufferCapabilities getBackBufferCaps() {
|
||||
return backBufferCaps;
|
||||
}
|
||||
|
||||
public void flip(int x1, int y1, int x2, int y2,
|
||||
BufferCapabilities.FlipContents flipAction)
|
||||
{
|
||||
if (buffersLog.isLoggable(Level.FINE)) {
|
||||
buffersLog.fine("flip(" + flipAction + ")");
|
||||
}
|
||||
if (backBuffer == 0) {
|
||||
throw new IllegalStateException("Buffers have not been created");
|
||||
}
|
||||
graphicsConfig.flip(this, target, xBackBuffer, flipAction);
|
||||
graphicsConfig.flip(this, target, xBackBuffer,
|
||||
x1, y1, x2, y2, flipAction);
|
||||
}
|
||||
|
||||
public Image getBackBuffer() {
|
||||
|
@ -257,7 +257,7 @@ public class XEmbedChildProxyPeer implements ComponentPeer, XEventDispatcher{
|
||||
public void createBuffers(int numBuffers, BufferCapabilities caps)
|
||||
throws AWTException { }
|
||||
public Image getBackBuffer() { return null; }
|
||||
public void flip(BufferCapabilities.FlipContents flipAction) { }
|
||||
public void flip(int x1, int y1, int x2, int y2, BufferCapabilities.FlipContents flipAction) { }
|
||||
public void destroyBuffers() { }
|
||||
|
||||
/**
|
||||
|
@ -27,20 +27,17 @@ package sun.awt;
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.BufferCapabilities;
|
||||
import java.awt.BufferCapabilities.FlipContents;
|
||||
import java.awt.Component;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.Image;
|
||||
import java.awt.ImageCapabilities;
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.awt.Transparency;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.DirectColorModel;
|
||||
import java.awt.image.ImageProducer;
|
||||
import java.awt.image.IndexColorModel;
|
||||
import java.awt.image.Raster;
|
||||
import java.awt.image.VolatileImage;
|
||||
import java.awt.image.WritableRaster;
|
||||
import java.awt.geom.AffineTransform;
|
||||
@ -429,6 +426,7 @@ public class X11GraphicsConfig extends GraphicsConfiguration
|
||||
*/
|
||||
public void flip(X11ComponentPeer peer,
|
||||
Component target, VolatileImage xBackBuffer,
|
||||
int x1, int y1, int x2, int y2,
|
||||
BufferCapabilities.FlipContents flipAction)
|
||||
{
|
||||
long window = peer.getContentWindow();
|
||||
|
@ -385,6 +385,9 @@ public class X11GraphicsDevice
|
||||
throw new IllegalStateException("Must be in fullscreen mode " +
|
||||
"in order to set display mode");
|
||||
}
|
||||
if (getDisplayMode().equals(dm)) {
|
||||
return;
|
||||
}
|
||||
if (dm == null ||
|
||||
(dm = getMatchingDisplayMode(dm)) == null)
|
||||
{
|
||||
|
@ -44,6 +44,7 @@ import java.util.*;
|
||||
import java.util.logging.*;
|
||||
|
||||
import sun.awt.motif.MFontConfiguration;
|
||||
import sun.font.FcFontConfiguration;
|
||||
import sun.font.Font2D;
|
||||
import sun.font.FontManager;
|
||||
import sun.font.NativeFont;
|
||||
@ -350,6 +351,14 @@ public class X11GraphicsEnvironment
|
||||
* only to get called for these fonts.
|
||||
*/
|
||||
public String getFileNameFromPlatformName(String platName) {
|
||||
|
||||
/* If the FontConfig file doesn't use xlfds, or its
|
||||
* FcFontConfiguration, this may be already a file name.
|
||||
*/
|
||||
if (platName.startsWith("/")) {
|
||||
return platName;
|
||||
}
|
||||
|
||||
String fileName = null;
|
||||
String fontID = specificFontIDForName(platName);
|
||||
|
||||
@ -905,12 +914,50 @@ public class X11GraphicsEnvironment
|
||||
|
||||
// Implements SunGraphicsEnvironment.createFontConfiguration.
|
||||
protected FontConfiguration createFontConfiguration() {
|
||||
return new MFontConfiguration(this);
|
||||
|
||||
/* The logic here decides whether to use a preconfigured
|
||||
* fontconfig.properties file, or synthesise one using platform APIs.
|
||||
* On Solaris (as opposed to OpenSolaris) we try to use the
|
||||
* pre-configured ones, but if the files it specifies are missing
|
||||
* we fail-safe to synthesising one. This might happen if Solaris
|
||||
* changes its fonts.
|
||||
* For OpenSolaris I don't expect us to ever create fontconfig files,
|
||||
* so it will always synthesise. Note that if we misidentify
|
||||
* OpenSolaris as Solaris, then the test for the presence of
|
||||
* Solaris-only font files will correct this.
|
||||
* For Linux we require an exact match of distro and version to
|
||||
* use the preconfigured file, and also that it points to
|
||||
* existent fonts.
|
||||
* If synthesising fails, we fall back to any preconfigured file
|
||||
* and do the best we can. For the commercial JDK this will be
|
||||
* fine as it includes the Lucida fonts. OpenJDK should not hit
|
||||
* this as the synthesis should always work on its platforms.
|
||||
*/
|
||||
FontConfiguration mFontConfig = new MFontConfiguration(this);
|
||||
if (isOpenSolaris ||
|
||||
(isLinux &&
|
||||
(!mFontConfig.foundOsSpecificFile() ||
|
||||
!mFontConfig.fontFilesArePresent()) ||
|
||||
(isSolaris && !mFontConfig.fontFilesArePresent()))) {
|
||||
FcFontConfiguration fcFontConfig =
|
||||
new FcFontConfiguration(this);
|
||||
if (fcFontConfig.init()) {
|
||||
return fcFontConfig;
|
||||
}
|
||||
}
|
||||
mFontConfig.init();
|
||||
return mFontConfig;
|
||||
}
|
||||
public FontConfiguration
|
||||
createFontConfiguration(boolean preferLocaleFonts,
|
||||
boolean preferPropFonts) {
|
||||
|
||||
FontConfiguration config = getFontConfiguration();
|
||||
if (config instanceof FcFontConfiguration) {
|
||||
// Doesn't need to implement the alternate support.
|
||||
return config;
|
||||
}
|
||||
|
||||
return new MFontConfiguration(this,
|
||||
preferLocaleFonts, preferPropFonts);
|
||||
}
|
||||
@ -921,6 +968,7 @@ public class X11GraphicsEnvironment
|
||||
* for this platform.
|
||||
*/
|
||||
public String getDefaultFontFaceName() {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1995-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -1138,11 +1138,14 @@ abstract class MComponentPeer implements ComponentPeer, DropTargetPeer, X11Compo
|
||||
backBuffer);
|
||||
}
|
||||
|
||||
public void flip(BufferCapabilities.FlipContents flipAction) {
|
||||
public void flip(int x1, int y1, int x2, int y2,
|
||||
BufferCapabilities.FlipContents flipAction)
|
||||
{
|
||||
if (backBuffer == 0) {
|
||||
throw new IllegalStateException("Buffers have not been created");
|
||||
}
|
||||
graphicsConfig.flip(this, target, xBackBuffer, flipAction);
|
||||
graphicsConfig.flip(this, target, xBackBuffer,
|
||||
x1, y1, x2, y2, flipAction);
|
||||
}
|
||||
|
||||
public Image getBackBuffer() {
|
||||
|
517
jdk/src/solaris/classes/sun/font/FcFontConfiguration.java
Normal file
517
jdk/src/solaris/classes/sun/font/FcFontConfiguration.java
Normal file
@ -0,0 +1,517 @@
|
||||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package sun.font;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.Properties;
|
||||
import java.util.Scanner;
|
||||
import sun.awt.FontConfiguration;
|
||||
import sun.awt.FontDescriptor;
|
||||
import sun.awt.SunToolkit;
|
||||
import sun.font.CompositeFontDescriptor;
|
||||
import sun.font.FontManager;
|
||||
import sun.font.FontManager.FontConfigInfo;
|
||||
import sun.font.FontManager.FcCompFont;
|
||||
import sun.font.FontManager.FontConfigFont;
|
||||
import sun.java2d.SunGraphicsEnvironment;
|
||||
|
||||
public class FcFontConfiguration extends FontConfiguration {
|
||||
|
||||
/** Version of the cache file format understood by this code.
|
||||
* Its part of the file name so that we can rev this at
|
||||
* any time, even in a minor JDK update.
|
||||
* It is stored as the value of the "version" property.
|
||||
* This is distinct from the version of "libfontconfig" that generated
|
||||
* the cached results, and which is the "fcversion" property in the file.
|
||||
* {@code FontConfiguration.getVersion()} also returns a version string,
|
||||
* and has meant the version of the fontconfiguration.properties file
|
||||
* that was read. Since this class doesn't use such files, then what
|
||||
* that really means is whether the methods on this class return
|
||||
* values that are compatible with the classes that do directly read
|
||||
* from such files. It is a compatible subset of version "1".
|
||||
*/
|
||||
private static final String fileVersion = "1";
|
||||
private String fcInfoFileName = null;
|
||||
|
||||
private FcCompFont[] fcCompFonts = null;
|
||||
|
||||
public FcFontConfiguration(SunGraphicsEnvironment environment) {
|
||||
super(environment);
|
||||
init();
|
||||
}
|
||||
|
||||
/* This isn't called but is needed to satisfy super-class contract. */
|
||||
public FcFontConfiguration(SunGraphicsEnvironment environment,
|
||||
boolean preferLocaleFonts,
|
||||
boolean preferPropFonts) {
|
||||
super(environment, preferLocaleFonts, preferPropFonts);
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean init() {
|
||||
if (fcCompFonts != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
readFcInfo();
|
||||
if (fcCompFonts == null) {
|
||||
fcCompFonts = FontManager.loadFontConfig();
|
||||
if (fcCompFonts != null) {
|
||||
try {
|
||||
writeFcInfo();
|
||||
} catch (Exception e) {
|
||||
if (SunGraphicsEnvironment.debugFonts) {
|
||||
Logger logger =
|
||||
Logger.getLogger("sun.awt.FontConfiguration");
|
||||
logger.warning("Exception writing fcInfo " + e);
|
||||
}
|
||||
}
|
||||
} else if (SunGraphicsEnvironment.debugFonts) {
|
||||
Logger logger = Logger.getLogger("sun.awt.FontConfiguration");
|
||||
logger.warning("Failed to get info from libfontconfig");
|
||||
}
|
||||
} else {
|
||||
FontManager.populateFontConfig(fcCompFonts);
|
||||
}
|
||||
|
||||
if (fcCompFonts == null) {
|
||||
return false; // couldn't load fontconfig.
|
||||
}
|
||||
|
||||
// NB already in a privileged block from SGE
|
||||
String javaHome = System.getProperty("java.home");
|
||||
if (javaHome == null) {
|
||||
throw new Error("java.home property not set");
|
||||
}
|
||||
String javaLib = javaHome + File.separator + "lib";
|
||||
getInstalledFallbackFonts(javaLib);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFallbackFamilyName(String fontName,
|
||||
String defaultFallback) {
|
||||
// maintain compatibility with old font.properties files, which either
|
||||
// had aliases for TimesRoman & Co. or defined mappings for them.
|
||||
String compatibilityName = getCompatibilityFamilyName(fontName);
|
||||
if (compatibilityName != null) {
|
||||
return compatibilityName;
|
||||
}
|
||||
return defaultFallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String
|
||||
getFaceNameFromComponentFontName(String componentFontName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String
|
||||
getFileNameFromComponentFontName(String componentFontName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFileNameFromPlatformName(String platformName) {
|
||||
/* Platform name is the file name, but rather than returning
|
||||
* the arg, return null*/
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Charset getDefaultFontCharset(String fontName) {
|
||||
return Charset.forName("ISO8859_1");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getEncoding(String awtFontName,
|
||||
String characterSubsetName) {
|
||||
return "default";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initReorderMap() {
|
||||
reorderMap = new HashMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FontDescriptor[] getFontDescriptors(String fontName, int style) {
|
||||
throw new InternalError("Not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberCoreFonts() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlatformFontNames() {
|
||||
HashSet<String> nameSet = new HashSet<String>();
|
||||
FcCompFont[] fcCompFonts = FontManager.loadFontConfig();
|
||||
for (int i=0; i<fcCompFonts.length; i++) {
|
||||
for (int j=0; j<fcCompFonts[i].allFonts.length; j++) {
|
||||
nameSet.add(fcCompFonts[i].allFonts[j].fontFile);
|
||||
}
|
||||
}
|
||||
return nameSet.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExtraFontPath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needToSearchForFile(String fileName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private FontConfigFont[] getFcFontList(FcCompFont[] fcFonts,
|
||||
String fontname, int style) {
|
||||
|
||||
if (fontname.equals("dialog")) {
|
||||
fontname = "sansserif";
|
||||
} else if (fontname.equals("dialoginput")) {
|
||||
fontname = "monospaced";
|
||||
}
|
||||
for (int i=0; i<fcFonts.length; i++) {
|
||||
if (fontname.equals(fcFonts[i].jdkName) &&
|
||||
style == fcFonts[i].style) {
|
||||
return fcFonts[i].allFonts;
|
||||
}
|
||||
}
|
||||
return fcFonts[0].allFonts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompositeFontDescriptor[] get2DCompositeFontInfo() {
|
||||
|
||||
FcCompFont[] fcCompFonts = FontManager.loadFontConfig();
|
||||
|
||||
CompositeFontDescriptor[] result =
|
||||
new CompositeFontDescriptor[NUM_FONTS * NUM_STYLES];
|
||||
|
||||
for (int fontIndex = 0; fontIndex < NUM_FONTS; fontIndex++) {
|
||||
String fontName = publicFontNames[fontIndex];
|
||||
|
||||
for (int styleIndex = 0; styleIndex < NUM_STYLES; styleIndex++) {
|
||||
|
||||
String faceName = fontName + "." + styleNames[styleIndex];
|
||||
FontConfigFont[] fcFonts =
|
||||
getFcFontList(fcCompFonts,
|
||||
fontNames[fontIndex], styleIndex);
|
||||
|
||||
int numFonts = fcFonts.length;
|
||||
// fall back fonts listed in the lib/fonts/fallback directory
|
||||
if (installedFallbackFontFiles != null) {
|
||||
numFonts += installedFallbackFontFiles.length;
|
||||
}
|
||||
|
||||
String[] fileNames = new String[numFonts];
|
||||
|
||||
int index;
|
||||
for (index = 0; index < fcFonts.length; index++) {
|
||||
fileNames[index] = fcFonts[index].fontFile;
|
||||
}
|
||||
|
||||
if (installedFallbackFontFiles != null) {
|
||||
System.arraycopy(fileNames, index,
|
||||
installedFallbackFontFiles,
|
||||
0, installedFallbackFontFiles.length);
|
||||
}
|
||||
|
||||
result[fontIndex * NUM_STYLES + styleIndex]
|
||||
= new CompositeFontDescriptor(
|
||||
faceName,
|
||||
1,
|
||||
null,
|
||||
fileNames,
|
||||
null, null);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the OS version string from a Linux release-specific file.
|
||||
*/
|
||||
private String getVersionString(File f){
|
||||
try {
|
||||
Scanner sc = new Scanner(f);
|
||||
return sc.findInLine("(\\d)+((\\.)(\\d)+)*");
|
||||
}
|
||||
catch (Exception e){
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the OS name and version from environment information.
|
||||
*/
|
||||
@Override
|
||||
protected void setOsNameAndVersion() {
|
||||
|
||||
super.setOsNameAndVersion();
|
||||
|
||||
if (!osName.equals("Linux")) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
File f;
|
||||
if ((f = new File("/etc/lsb-release")).canRead()) {
|
||||
/* Ubuntu and (perhaps others) use only lsb-release.
|
||||
* Syntax and encoding is compatible with java properties.
|
||||
* For Ubuntu the ID is "Ubuntu".
|
||||
*/
|
||||
Properties props = new Properties();
|
||||
props.load(new FileInputStream(f));
|
||||
osName = props.getProperty("DISTRIB_ID");
|
||||
osVersion = props.getProperty("DISTRIB_RELEASE");
|
||||
} else if ((f = new File("/etc/redhat-release")).canRead()) {
|
||||
osName = "RedHat";
|
||||
osVersion = getVersionString(f);
|
||||
} else if ((f = new File("/etc/SuSE-release")).canRead()) {
|
||||
osName = "SuSE";
|
||||
osVersion = getVersionString(f);
|
||||
} else if ((f = new File("/etc/turbolinux-release")).canRead()) {
|
||||
osName = "Turbo";
|
||||
osVersion = getVersionString(f);
|
||||
} else if ((f = new File("/etc/fedora-release")).canRead()) {
|
||||
osName = "Fedora";
|
||||
osVersion = getVersionString(f);
|
||||
} else if ((f = new File("/etc/sun-release")).canRead()) {
|
||||
osName = "Sun";
|
||||
osVersion = getVersionString(f);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (SunGraphicsEnvironment.debugFonts) {
|
||||
Logger logger = Logger.getLogger("sun.awt.FontConfiguration");
|
||||
logger.warning("Exception identifying Linux distro.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private File getFcInfoFile() {
|
||||
if (fcInfoFileName == null) {
|
||||
// NB need security permissions to get true IP address, and
|
||||
// we should have those as the whole initialisation is in a
|
||||
// doPrivileged block. But in this case no exception is thrown,
|
||||
// and it returns the loop back address, and so we end up with
|
||||
// "localhost"
|
||||
String hostname;
|
||||
try {
|
||||
hostname = InetAddress.getLocalHost().getHostName();
|
||||
} catch (UnknownHostException e) {
|
||||
hostname = "localhost";
|
||||
}
|
||||
String userDir = System.getProperty("user.home");
|
||||
String version = System.getProperty("java.version");
|
||||
String fs = File.separator;
|
||||
String dir = userDir+fs+".java"+fs+"fonts"+fs+version;
|
||||
String lang = SunToolkit.getStartupLocale().getLanguage();
|
||||
String name = "fcinfo-"+fileVersion+"-"+hostname+"-"+
|
||||
osName+"-"+osVersion+"-"+lang+".properties";
|
||||
fcInfoFileName = dir+fs+name;
|
||||
}
|
||||
return new File(fcInfoFileName);
|
||||
}
|
||||
|
||||
private void writeFcInfo() {
|
||||
Properties props = new Properties();
|
||||
props.setProperty("version", fileVersion);
|
||||
FontConfigInfo fcInfo = FontManager.getFontConfigInfo();
|
||||
props.setProperty("fcversion", Integer.toString(fcInfo.fcVersion));
|
||||
if (fcInfo.cacheDirs != null) {
|
||||
for (int i=0;i<fcInfo.cacheDirs.length;i++) {
|
||||
if (fcInfo.cacheDirs[i] != null) {
|
||||
props.setProperty("cachedir."+i, fcInfo.cacheDirs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i=0; i<fcCompFonts.length; i++) {
|
||||
FcCompFont fci = fcCompFonts[i];
|
||||
String styleKey = fci.jdkName+"."+fci.style;
|
||||
props.setProperty(styleKey+".length",
|
||||
Integer.toString(fci.allFonts.length));
|
||||
for (int j=0; j<fci.allFonts.length; j++) {
|
||||
props.setProperty(styleKey+"."+j+".family",
|
||||
fci.allFonts[j].familyName);
|
||||
props.setProperty(styleKey+"."+j+".file",
|
||||
fci.allFonts[j].fontFile);
|
||||
}
|
||||
}
|
||||
try {
|
||||
/* This writes into a temp file then renames when done.
|
||||
* Since the rename is an atomic action within the same
|
||||
* directory no client will ever see a partially written file.
|
||||
*/
|
||||
File fcInfoFile = getFcInfoFile();
|
||||
File dir = fcInfoFile.getParentFile();
|
||||
dir.mkdirs();
|
||||
File tempFile = File.createTempFile("fcinfo", null, dir);
|
||||
FileOutputStream fos = new FileOutputStream(tempFile);
|
||||
props.store(fos,
|
||||
"JDK Font Configuration Generated File: *Do Not Edit*");
|
||||
fos.close();
|
||||
boolean renamed = tempFile.renameTo(fcInfoFile);
|
||||
if (!renamed && SunGraphicsEnvironment.debugFonts) {
|
||||
System.out.println("rename failed");
|
||||
Logger logger = Logger.getLogger("sun.awt.FontConfiguration");
|
||||
logger.warning("Failed renaming file to "+ getFcInfoFile());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (SunGraphicsEnvironment.debugFonts) {
|
||||
Logger logger = Logger.getLogger("sun.awt.FontConfiguration");
|
||||
logger.warning("IOException writing to "+ getFcInfoFile());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* We want to be able to use this cache instead of invoking
|
||||
* fontconfig except when we can detect the system cache has changed.
|
||||
* But there doesn't seem to be a way to find the location of
|
||||
* the system cache.
|
||||
*/
|
||||
private void readFcInfo() {
|
||||
File fcFile = getFcInfoFile();
|
||||
if (!fcFile.exists()) {
|
||||
return;
|
||||
}
|
||||
Properties props = new Properties();
|
||||
try {
|
||||
FileInputStream fis = new FileInputStream(fcFile);
|
||||
props.load(fis);
|
||||
fis.close();
|
||||
} catch (IOException e) {
|
||||
if (SunGraphicsEnvironment.debugFonts) {
|
||||
Logger logger = Logger.getLogger("sun.awt.FontConfiguration");
|
||||
logger.warning("IOException reading from "+fcFile.toString());
|
||||
}
|
||||
return;
|
||||
}
|
||||
String version = (String)props.get("version");
|
||||
if (version == null || !version.equals(fileVersion)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If there's a new, different fontconfig installed on the
|
||||
// system, we invalidate our fontconfig file.
|
||||
String fcVersionStr = (String)props.get("fcversion");
|
||||
if (fcVersionStr != null) {
|
||||
int fcVersion;
|
||||
try {
|
||||
fcVersion = Integer.parseInt(fcVersionStr);
|
||||
if (fcVersion != 0 &&
|
||||
fcVersion != FontManager.getFontConfigVersion()) {
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (SunGraphicsEnvironment.debugFonts) {
|
||||
Logger logger =
|
||||
Logger.getLogger("sun.awt.FontConfiguration");
|
||||
logger.warning("Exception parsing version " +
|
||||
fcVersionStr);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If we can locate the fontconfig cache dirs, then compare the
|
||||
// time stamp of those with our properties file. If we are out
|
||||
// of date then re-generate.
|
||||
long lastModified = fcFile.lastModified();
|
||||
int cacheDirIndex = 0;
|
||||
while (cacheDirIndex<4) { // should never be more than 2 anyway.
|
||||
String dir = (String)props.get("cachedir."+cacheDirIndex);
|
||||
if (dir == null) {
|
||||
break;
|
||||
}
|
||||
File dirFile = new File(dir);
|
||||
if (dirFile.exists() && dirFile.lastModified() > lastModified) {
|
||||
return;
|
||||
}
|
||||
cacheDirIndex++;
|
||||
}
|
||||
|
||||
String[] names = { "sansserif", "serif", "monospaced" };
|
||||
String[] fcnames = { "sans", "serif", "monospace" };
|
||||
int namesLen = names.length;
|
||||
int numStyles = 4;
|
||||
FcCompFont[] fci = new FcCompFont[namesLen*numStyles];
|
||||
|
||||
try {
|
||||
for (int i=0; i<namesLen; i++) {
|
||||
for (int s=0; s<numStyles; s++) {
|
||||
int index = i*numStyles+s;
|
||||
fci[index] = new FcCompFont();
|
||||
String key = names[i]+"."+s;
|
||||
fci[index].jdkName = names[i];
|
||||
fci[index].fcFamily = fcnames[i];
|
||||
fci[index].style = s;
|
||||
String lenStr = (String)props.get(key+".length");
|
||||
int nfonts = Integer.parseInt(lenStr);
|
||||
if (nfonts <= 0) {
|
||||
return; // bad file
|
||||
}
|
||||
fci[index].allFonts = new FontConfigFont[nfonts];
|
||||
for (int f=0; f<nfonts; f++) {
|
||||
fci[index].allFonts[f] = new FontConfigFont();
|
||||
String fkey = key+"."+f+".family";
|
||||
String family = (String)props.get(fkey);
|
||||
fci[index].allFonts[f].familyName = family;
|
||||
fkey = key+"."+f+".file";
|
||||
String file = (String)props.get(fkey);
|
||||
if (file == null) {
|
||||
return; // bad file
|
||||
}
|
||||
fci[index].allFonts[f].fontFile = file;
|
||||
}
|
||||
fci[index].firstFont = fci[index].allFonts[0];
|
||||
|
||||
}
|
||||
}
|
||||
fcCompFonts = fci;
|
||||
} catch (Throwable t) {
|
||||
if (SunGraphicsEnvironment.debugFonts) {
|
||||
Logger logger = Logger.getLogger("sun.awt.FontConfiguration");
|
||||
logger.warning(t.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package sun.java2d;
|
||||
|
||||
import java.awt.BufferCapabilities;
|
||||
|
||||
/**
|
||||
* Provides access to back-buffer's BufferCapabilities.
|
||||
*/
|
||||
public interface BackBufferCapsProvider {
|
||||
public BufferCapabilities getBackBufferCaps();
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,8 +27,11 @@ package sun.java2d.opengl;
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.BufferCapabilities;
|
||||
import java.awt.BufferCapabilities.FlipContents;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.ImageCapabilities;
|
||||
import java.awt.Transparency;
|
||||
@ -45,7 +48,19 @@ import sun.awt.X11GraphicsDevice;
|
||||
import sun.awt.X11GraphicsEnvironment;
|
||||
import sun.awt.image.OffScreenImage;
|
||||
import sun.awt.image.SunVolatileImage;
|
||||
import sun.awt.image.SurfaceManager;
|
||||
import sun.java2d.SunGraphics2D;
|
||||
import sun.java2d.Surface;
|
||||
import sun.java2d.SurfaceData;
|
||||
import sun.java2d.pipe.hw.AccelSurface;
|
||||
import sun.java2d.pipe.hw.AccelTypedVolatileImage;
|
||||
import sun.java2d.pipe.hw.ContextCapabilities;
|
||||
import static sun.java2d.opengl.OGLSurfaceData.*;
|
||||
import static sun.java2d.opengl.OGLContext.*;
|
||||
import static sun.java2d.opengl.OGLContext.OGLContextCaps.*;
|
||||
import sun.java2d.opengl.GLXSurfaceData.GLXVSyncOffScreenSurfaceData;
|
||||
import sun.java2d.pipe.hw.AccelDeviceEventListener;
|
||||
import sun.java2d.pipe.hw.AccelDeviceEventNotifier;
|
||||
|
||||
public class GLXGraphicsConfig
|
||||
extends X11GraphicsConfig
|
||||
@ -54,7 +69,7 @@ public class GLXGraphicsConfig
|
||||
private static ImageCapabilities imageCaps = new GLXImageCaps();
|
||||
private BufferCapabilities bufferCaps;
|
||||
private long pConfigInfo;
|
||||
private int oglCaps;
|
||||
private ContextCapabilities oglCaps;
|
||||
private OGLContext context;
|
||||
|
||||
private static native long getGLXConfigInfo(int screennum, int visualnum);
|
||||
@ -62,20 +77,22 @@ public class GLXGraphicsConfig
|
||||
private native void initConfig(long aData, long ctxinfo);
|
||||
|
||||
private GLXGraphicsConfig(X11GraphicsDevice device, int visualnum,
|
||||
long configInfo, int oglCaps)
|
||||
long configInfo, ContextCapabilities oglCaps)
|
||||
{
|
||||
super(device, visualnum, 0, 0,
|
||||
(oglCaps & OGLContext.CAPS_DOUBLEBUFFERED) != 0);
|
||||
(oglCaps.getCaps() & CAPS_DOUBLEBUFFERED) != 0);
|
||||
pConfigInfo = configInfo;
|
||||
initConfig(getAData(), configInfo);
|
||||
this.oglCaps = oglCaps;
|
||||
context = new OGLContext(OGLRenderQueue.getInstance());
|
||||
context = new OGLContext(OGLRenderQueue.getInstance(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getProxyKey() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SurfaceData createManagedSurface(int w, int h, int transparency) {
|
||||
return GLXSurfaceData.createData(this, w, h,
|
||||
getColorModel(transparency),
|
||||
@ -91,6 +108,7 @@ public class GLXGraphicsConfig
|
||||
}
|
||||
|
||||
long cfginfo = 0;
|
||||
final String ids[] = new String[1];
|
||||
OGLRenderQueue rq = OGLRenderQueue.getInstance();
|
||||
rq.lock();
|
||||
try {
|
||||
@ -102,6 +120,12 @@ public class GLXGraphicsConfig
|
||||
new GLXGetConfigInfo(device.getScreen(), visualnum);
|
||||
rq.flushAndInvokeNow(action);
|
||||
cfginfo = action.getConfigInfo();
|
||||
OGLContext.setScratchSurface(cfginfo);
|
||||
rq.flushAndInvokeNow(new Runnable() {
|
||||
public void run() {
|
||||
ids[0] = OGLContext.getOGLIdString();
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
rq.unlock();
|
||||
}
|
||||
@ -110,8 +134,9 @@ public class GLXGraphicsConfig
|
||||
}
|
||||
|
||||
int oglCaps = getOGLCapabilities(cfginfo);
|
||||
ContextCapabilities caps = new OGLContextCaps(oglCaps, ids[0]);
|
||||
|
||||
return new GLXGraphicsConfig(device, visualnum, cfginfo, oglCaps);
|
||||
return new GLXGraphicsConfig(device, visualnum, cfginfo, caps);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -138,14 +163,22 @@ public class GLXGraphicsConfig
|
||||
* Returns true if the provided capability bit is present for this config.
|
||||
* See OGLContext.java for a list of supported capabilities.
|
||||
*/
|
||||
@Override
|
||||
public final boolean isCapPresent(int cap) {
|
||||
return ((oglCaps & cap) != 0);
|
||||
return ((oglCaps.getCaps() & cap) != 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final long getNativeConfigInfo() {
|
||||
return pConfigInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @see sun.java2d.pipe.hw.BufferedContextProvider#getContext
|
||||
*/
|
||||
@Override
|
||||
public final OGLContext getContext() {
|
||||
return context;
|
||||
}
|
||||
@ -275,16 +308,36 @@ public class GLXGraphicsConfig
|
||||
@Override
|
||||
public void flip(X11ComponentPeer peer,
|
||||
Component target, VolatileImage xBackBuffer,
|
||||
int x1, int y1, int x2, int y2,
|
||||
BufferCapabilities.FlipContents flipAction)
|
||||
{
|
||||
if (flipAction == BufferCapabilities.FlipContents.COPIED) {
|
||||
Graphics g = peer.getGraphics();
|
||||
try {
|
||||
g.drawImage(xBackBuffer, 0, 0, null);
|
||||
} finally {
|
||||
g.dispose();
|
||||
SurfaceManager vsm = SurfaceManager.getManager(xBackBuffer);
|
||||
SurfaceData sd = vsm.getPrimarySurfaceData();
|
||||
|
||||
if (sd instanceof GLXVSyncOffScreenSurfaceData) {
|
||||
GLXVSyncOffScreenSurfaceData vsd =
|
||||
(GLXVSyncOffScreenSurfaceData)sd;
|
||||
SurfaceData bbsd = vsd.getFlipSurface();
|
||||
Graphics2D bbg =
|
||||
new SunGraphics2D(bbsd, Color.black, Color.white, null);
|
||||
try {
|
||||
bbg.drawImage(xBackBuffer, 0, 0, null);
|
||||
} finally {
|
||||
bbg.dispose();
|
||||
}
|
||||
} else {
|
||||
Graphics g = peer.getGraphics();
|
||||
try {
|
||||
g.drawImage(xBackBuffer,
|
||||
x1, y1, x2, y2,
|
||||
x1, y1, x2, y2,
|
||||
null);
|
||||
} finally {
|
||||
g.dispose();
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
} else if (flipAction == BufferCapabilities.FlipContents.PRIOR) {
|
||||
// not supported by GLX...
|
||||
return;
|
||||
@ -333,4 +386,64 @@ public class GLXGraphicsConfig
|
||||
public ImageCapabilities getImageCapabilities() {
|
||||
return imageCaps;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @see sun.java2d.pipe.hw.AccelGraphicsConfig#createCompatibleVolatileImage
|
||||
*/
|
||||
@Override
|
||||
public VolatileImage
|
||||
createCompatibleVolatileImage(int width, int height,
|
||||
int transparency, int type)
|
||||
{
|
||||
if (type == FLIP_BACKBUFFER || type == WINDOW || type == UNDEFINED ||
|
||||
transparency == Transparency.BITMASK)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (type == FBOBJECT) {
|
||||
if (!isCapPresent(CAPS_EXT_FBOBJECT)) {
|
||||
return null;
|
||||
}
|
||||
} else if (type == PBUFFER) {
|
||||
boolean isOpaque = transparency == Transparency.OPAQUE;
|
||||
if (!isOpaque && !isCapPresent(CAPS_STORED_ALPHA)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
SunVolatileImage vi = new AccelTypedVolatileImage(this, width, height,
|
||||
transparency, type);
|
||||
Surface sd = vi.getDestSurface();
|
||||
if (!(sd instanceof AccelSurface) ||
|
||||
((AccelSurface)sd).getType() != type)
|
||||
{
|
||||
vi.flush();
|
||||
vi = null;
|
||||
}
|
||||
|
||||
return vi;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @see sun.java2d.pipe.hw.AccelGraphicsConfig#getContextCapabilities
|
||||
*/
|
||||
@Override
|
||||
public ContextCapabilities getContextCapabilities() {
|
||||
return oglCaps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDeviceEventListener(AccelDeviceEventListener l) {
|
||||
AccelDeviceEventNotifier.addListener(l, screen.getScreen());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeDeviceEventListener(AccelDeviceEventListener l) {
|
||||
AccelDeviceEventNotifier.removeListener(l);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -73,13 +73,20 @@ public abstract class GLXSurfaceData extends OGLSurfaceData {
|
||||
* double-buffered on-screen Window.
|
||||
*/
|
||||
public static GLXOffScreenSurfaceData createData(X11ComponentPeer peer,
|
||||
Image image)
|
||||
Image image,
|
||||
int type)
|
||||
{
|
||||
GLXGraphicsConfig gc = getGC(peer);
|
||||
Rectangle r = peer.getBounds();
|
||||
return new GLXOffScreenSurfaceData(peer, gc, r.width, r.height,
|
||||
image, peer.getColorModel(),
|
||||
FLIP_BACKBUFFER);
|
||||
if (type == FLIP_BACKBUFFER) {
|
||||
return new GLXOffScreenSurfaceData(peer, gc, r.width, r.height,
|
||||
image, peer.getColorModel(),
|
||||
FLIP_BACKBUFFER);
|
||||
} else {
|
||||
return new GLXVSyncOffScreenSurfaceData(peer, gc, r.width, r.height,
|
||||
image, peer.getColorModel(),
|
||||
type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -134,6 +141,42 @@ public abstract class GLXSurfaceData extends OGLSurfaceData {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A surface which implements a v-synced flip back-buffer with COPIED
|
||||
* FlipContents.
|
||||
*
|
||||
* This surface serves as a back-buffer to the outside world, while
|
||||
* it is actually an offscreen surface. When the BufferStrategy this surface
|
||||
* belongs to is showed, it is first copied to the real private
|
||||
* FLIP_BACKBUFFER, which is then flipped.
|
||||
*/
|
||||
public static class GLXVSyncOffScreenSurfaceData extends
|
||||
GLXOffScreenSurfaceData
|
||||
{
|
||||
private GLXOffScreenSurfaceData flipSurface;
|
||||
|
||||
public GLXVSyncOffScreenSurfaceData(X11ComponentPeer peer,
|
||||
GLXGraphicsConfig gc,
|
||||
int width, int height,
|
||||
Image image, ColorModel cm,
|
||||
int type)
|
||||
{
|
||||
super(peer, gc, width, height, image, cm, type);
|
||||
flipSurface = GLXSurfaceData.createData(peer, image, FLIP_BACKBUFFER);
|
||||
}
|
||||
|
||||
public SurfaceData getFlipSurface() {
|
||||
return flipSurface;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
flipSurface.flush();
|
||||
super.flush();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class GLXOffScreenSurfaceData extends GLXSurfaceData {
|
||||
|
||||
private Image offscreenImage;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,16 +25,21 @@
|
||||
|
||||
package sun.java2d.opengl;
|
||||
|
||||
import java.awt.BufferCapabilities;
|
||||
import static java.awt.BufferCapabilities.FlipContents.*;
|
||||
import java.awt.Component;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.ImageCapabilities;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Transparency;
|
||||
import java.awt.image.ColorModel;
|
||||
import sun.awt.X11ComponentPeer;
|
||||
import sun.awt.image.SunVolatileImage;
|
||||
import sun.awt.image.VolatileSurfaceManager;
|
||||
import sun.java2d.BackBufferCapsProvider;
|
||||
import sun.java2d.SurfaceData;
|
||||
import static sun.java2d.opengl.OGLContext.OGLContextCaps.*;
|
||||
import sun.java2d.pipe.hw.ExtendedBufferCapabilities;
|
||||
import static sun.java2d.pipe.hw.AccelSurface.*;
|
||||
import static sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.*;
|
||||
|
||||
public class GLXVolatileSurfaceManager extends VolatileSurfaceManager {
|
||||
|
||||
@ -56,8 +61,8 @@ public class GLXVolatileSurfaceManager extends VolatileSurfaceManager {
|
||||
accelerationEnabled =
|
||||
(transparency == Transparency.OPAQUE) ||
|
||||
((transparency == Transparency.TRANSLUCENT) &&
|
||||
(gc.isCapPresent(OGLContext.CAPS_EXT_FBOBJECT) ||
|
||||
gc.isCapPresent(OGLContext.CAPS_STORED_ALPHA)));
|
||||
(gc.isCapPresent(CAPS_EXT_FBOBJECT) ||
|
||||
gc.isCapPresent(CAPS_STORED_ALPHA)));
|
||||
}
|
||||
|
||||
protected boolean isAccelerationEnabled() {
|
||||
@ -75,24 +80,49 @@ public class GLXVolatileSurfaceManager extends VolatileSurfaceManager {
|
||||
(comp != null) ? (X11ComponentPeer)comp.getPeer() : null;
|
||||
|
||||
try {
|
||||
boolean createVSynced = false;
|
||||
boolean forceback = false;
|
||||
if (context instanceof Boolean) {
|
||||
forceback = ((Boolean)context).booleanValue();
|
||||
if (forceback && peer instanceof BackBufferCapsProvider) {
|
||||
BackBufferCapsProvider provider =
|
||||
(BackBufferCapsProvider)peer;
|
||||
BufferCapabilities caps = provider.getBackBufferCaps();
|
||||
if (caps instanceof ExtendedBufferCapabilities) {
|
||||
ExtendedBufferCapabilities ebc =
|
||||
(ExtendedBufferCapabilities)caps;
|
||||
if (ebc.getVSync() == VSYNC_ON &&
|
||||
ebc.getFlipContents() == COPIED)
|
||||
{
|
||||
createVSynced = true;
|
||||
forceback = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (forceback) {
|
||||
// peer must be non-null in this case
|
||||
sData = GLXSurfaceData.createData(peer, vImg);
|
||||
sData = GLXSurfaceData.createData(peer, vImg, FLIP_BACKBUFFER);
|
||||
} else {
|
||||
GLXGraphicsConfig gc =
|
||||
(GLXGraphicsConfig)vImg.getGraphicsConfig();
|
||||
ColorModel cm = gc.getColorModel(vImg.getTransparency());
|
||||
int type = gc.isCapPresent(OGLContext.CAPS_EXT_FBOBJECT) ?
|
||||
OGLSurfaceData.FBOBJECT : OGLSurfaceData.PBUFFER;
|
||||
sData = GLXSurfaceData.createData(gc,
|
||||
vImg.getWidth(),
|
||||
vImg.getHeight(),
|
||||
cm, vImg, type);
|
||||
int type = vImg.getForcedAccelSurfaceType();
|
||||
// if acceleration type is forced (type != UNDEFINED) then
|
||||
// use the forced type, otherwise choose one based on caps
|
||||
if (type == OGLSurfaceData.UNDEFINED) {
|
||||
type = gc.isCapPresent(CAPS_EXT_FBOBJECT) ?
|
||||
OGLSurfaceData.FBOBJECT : OGLSurfaceData.PBUFFER;
|
||||
}
|
||||
if (createVSynced) {
|
||||
sData = GLXSurfaceData.createData(peer, vImg, type);
|
||||
} else {
|
||||
sData = GLXSurfaceData.createData(gc,
|
||||
vImg.getWidth(),
|
||||
vImg.getHeight(),
|
||||
cm, vImg, type);
|
||||
}
|
||||
}
|
||||
} catch (NullPointerException ex) {
|
||||
sData = null;
|
||||
@ -103,7 +133,15 @@ public class GLXVolatileSurfaceManager extends VolatileSurfaceManager {
|
||||
return sData;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isConfigValid(GraphicsConfiguration gc) {
|
||||
return ((gc == null) || (gc == vImg.getGraphicsConfig()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initContents() {
|
||||
if (vImg.getForcedAccelSurfaceType() != OGLSurfaceData.TEXTURE) {
|
||||
super.initContents();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -79,15 +79,16 @@ public class X11PMBlitBgLoops extends BlitBg {
|
||||
super(srcType, CompositeType.SrcNoEa, dstType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void BlitBg(SurfaceData src, SurfaceData dst,
|
||||
Composite comp, Region clip, Color bgColor,
|
||||
Composite comp, Region clip, int bgColor,
|
||||
int sx, int sy,
|
||||
int dx, int dy,
|
||||
int w, int h)
|
||||
{
|
||||
SunToolkit.awtLock();
|
||||
try {
|
||||
int pixel = dst.pixelFor(bgColor.getRGB());
|
||||
int pixel = dst.pixelFor(bgColor);
|
||||
X11SurfaceData x11sd = (X11SurfaceData)dst;
|
||||
// use false for needExposures since we clip to the pixmap
|
||||
long xgc = x11sd.getBlitGC(clip, false);
|
||||
|
@ -1,11 +1,7 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
*/
|
||||
/*
|
||||
* $RCSId: xc/lib/fontconfig/fontconfig/fontconfig.h,v 1.30 2002/09/26 00:17:27 keithp Exp $
|
||||
*
|
||||
* Copyright © 2001 Keith Packard
|
||||
* Copyright © 2001 Keith Packard
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
@ -29,8 +25,21 @@
|
||||
#ifndef _FONTCONFIG_H_
|
||||
#define _FONTCONFIG_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 4)
|
||||
#define FC_ATTRIBUTE_SENTINEL(x) __attribute__((__sentinel__(0)))
|
||||
#else
|
||||
#define FC_ATTRIBUTE_SENTINEL(x)
|
||||
#endif
|
||||
|
||||
#ifndef FcPublic
|
||||
#define FcPublic
|
||||
#endif
|
||||
|
||||
typedef unsigned char FcChar8;
|
||||
typedef unsigned short FcChar16;
|
||||
typedef unsigned int FcChar32;
|
||||
@ -43,7 +52,7 @@ typedef int FcBool;
|
||||
*/
|
||||
|
||||
#define FC_MAJOR 2
|
||||
#define FC_MINOR 2
|
||||
#define FC_MINOR 5
|
||||
#define FC_REVISION 0
|
||||
|
||||
#define FC_VERSION ((FC_MAJOR * 10000) + (FC_MINOR * 100) + (FC_REVISION))
|
||||
@ -58,7 +67,7 @@ typedef int FcBool;
|
||||
* it means multiple copies of the font information.
|
||||
*/
|
||||
|
||||
#define FC_CACHE_VERSION "1"
|
||||
#define FC_CACHE_VERSION "2"
|
||||
|
||||
#define FcTrue 1
|
||||
#define FcFalse 0
|
||||
@ -74,6 +83,7 @@ typedef int FcBool;
|
||||
#define FC_FOUNDRY "foundry" /* String */
|
||||
#define FC_ANTIALIAS "antialias" /* Bool (depends) */
|
||||
#define FC_HINTING "hinting" /* Bool (true) */
|
||||
#define FC_HINT_STYLE "hintstyle" /* Int */
|
||||
#define FC_VERTICAL_LAYOUT "verticallayout" /* Bool (false) */
|
||||
#define FC_AUTOHINT "autohint" /* Bool (false) */
|
||||
#define FC_GLOBAL_ADVANCE "globaladvance" /* Bool (true) */
|
||||
@ -88,11 +98,21 @@ typedef int FcBool;
|
||||
#define FC_DPI "dpi" /* double */
|
||||
#define FC_RGBA "rgba" /* Int */
|
||||
#define FC_MINSPACE "minspace" /* Bool use minimum line spacing */
|
||||
#define FC_SOURCE "source" /* String (X11, freetype) */
|
||||
#define FC_SOURCE "source" /* String (deprecated) */
|
||||
#define FC_CHARSET "charset" /* CharSet */
|
||||
#define FC_LANG "lang" /* String RFC 3066 langs */
|
||||
#define FC_FONTVERSION "fontversion" /* Int from 'head' table */
|
||||
#define FC_FULLNAME "fullname" /* String */
|
||||
#define FC_FAMILYLANG "familylang" /* String RFC 3066 langs */
|
||||
#define FC_STYLELANG "stylelang" /* String RFC 3066 langs */
|
||||
#define FC_FULLNAMELANG "fullnamelang" /* String RFC 3066 langs */
|
||||
#define FC_CAPABILITY "capability" /* String */
|
||||
#define FC_FONTFORMAT "fontformat" /* String */
|
||||
#define FC_EMBOLDEN "embolden" /* Bool - true if emboldening needed*/
|
||||
#define FC_EMBEDDED_BITMAP "embeddedbitmap" /* Bool - true to enable embedded bitmaps */
|
||||
#define FC_DECORATIVE "decorative" /* Bool - true if style is a decorative variant */
|
||||
|
||||
#define FC_CACHE_SUFFIX ".cache-"FC_CACHE_VERSION
|
||||
#define FC_DIR_CACHE_FILE "fonts.cache-"FC_CACHE_VERSION
|
||||
#define FC_USER_CACHE_FILE ".fonts.cache-"FC_CACHE_VERSION
|
||||
|
||||
@ -105,6 +125,7 @@ typedef int FcBool;
|
||||
#define FC_WEIGHT_EXTRALIGHT 40
|
||||
#define FC_WEIGHT_ULTRALIGHT FC_WEIGHT_EXTRALIGHT
|
||||
#define FC_WEIGHT_LIGHT 50
|
||||
#define FC_WEIGHT_BOOK 75
|
||||
#define FC_WEIGHT_REGULAR 80
|
||||
#define FC_WEIGHT_NORMAL FC_WEIGHT_REGULAR
|
||||
#define FC_WEIGHT_MEDIUM 100
|
||||
@ -115,6 +136,8 @@ typedef int FcBool;
|
||||
#define FC_WEIGHT_ULTRABOLD FC_WEIGHT_EXTRABOLD
|
||||
#define FC_WEIGHT_BLACK 210
|
||||
#define FC_WEIGHT_HEAVY FC_WEIGHT_BLACK
|
||||
#define FC_WEIGHT_EXTRABLACK 215
|
||||
#define FC_WEIGHT_ULTRABLACK FC_WEIGHT_EXTRABLACK
|
||||
|
||||
#define FC_SLANT_ROMAN 0
|
||||
#define FC_SLANT_ITALIC 100
|
||||
@ -131,6 +154,7 @@ typedef int FcBool;
|
||||
#define FC_WIDTH_ULTRAEXPANDED 200
|
||||
|
||||
#define FC_PROPORTIONAL 0
|
||||
#define FC_DUAL 90
|
||||
#define FC_MONO 100
|
||||
#define FC_CHARCELL 110
|
||||
|
||||
@ -142,6 +166,12 @@ typedef int FcBool;
|
||||
#define FC_RGBA_VBGR 4
|
||||
#define FC_RGBA_NONE 5
|
||||
|
||||
/* hinting style */
|
||||
#define FC_HINT_NONE 0
|
||||
#define FC_HINT_SLIGHT 1
|
||||
#define FC_HINT_MEDIUM 2
|
||||
#define FC_HINT_FULL 3
|
||||
|
||||
typedef enum _FcType {
|
||||
FcTypeVoid,
|
||||
FcTypeInteger,
|
||||
@ -180,7 +210,8 @@ typedef struct _FcConstant {
|
||||
} FcConstant;
|
||||
|
||||
typedef enum _FcResult {
|
||||
FcResultMatch, FcResultNoMatch, FcResultTypeMismatch, FcResultNoId
|
||||
FcResultMatch, FcResultNoMatch, FcResultTypeMismatch, FcResultNoId,
|
||||
FcResultOutOfMemory
|
||||
} FcResult;
|
||||
|
||||
typedef struct _FcPattern FcPattern;
|
||||
@ -197,7 +228,6 @@ typedef struct _FcValue {
|
||||
const FcMatrix *m;
|
||||
const FcCharSet *c;
|
||||
void *f;
|
||||
const FcPattern *p;
|
||||
const FcLangSet *l;
|
||||
} u;
|
||||
} FcValue;
|
||||
@ -215,11 +245,14 @@ typedef struct _FcObjectSet {
|
||||
} FcObjectSet;
|
||||
|
||||
typedef enum _FcMatchKind {
|
||||
FcMatchPattern, FcMatchFont
|
||||
FcMatchPattern, FcMatchFont, FcMatchScan
|
||||
} FcMatchKind;
|
||||
|
||||
typedef enum _FcLangResult {
|
||||
FcLangEqual, FcLangDifferentCountry, FcLangDifferentLang
|
||||
FcLangEqual = 0,
|
||||
FcLangDifferentCountry = 1,
|
||||
FcLangDifferentTerritory = 1,
|
||||
FcLangDifferentLang = 2
|
||||
} FcLangResult;
|
||||
|
||||
typedef enum _FcSetName {
|
||||
@ -249,169 +282,207 @@ typedef struct _FcStrList FcStrList;
|
||||
|
||||
typedef struct _FcStrSet FcStrSet;
|
||||
|
||||
typedef struct _FcCache FcCache;
|
||||
|
||||
_FCFUNCPROTOBEGIN
|
||||
|
||||
FcBool
|
||||
FcDirCacheValid (const FcChar8 *cache_file);
|
||||
|
||||
/* fcblanks.c */
|
||||
FcBlanks *
|
||||
FcPublic FcBlanks *
|
||||
FcBlanksCreate (void);
|
||||
|
||||
void
|
||||
FcPublic void
|
||||
FcBlanksDestroy (FcBlanks *b);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcBlanksAdd (FcBlanks *b, FcChar32 ucs4);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcBlanksIsMember (FcBlanks *b, FcChar32 ucs4);
|
||||
|
||||
/* fccache.c */
|
||||
|
||||
FcPublic const FcChar8 *
|
||||
FcCacheDir(const FcCache *c);
|
||||
|
||||
FcPublic FcFontSet *
|
||||
FcCacheCopySet(const FcCache *c);
|
||||
|
||||
FcPublic const FcChar8 *
|
||||
FcCacheSubdir (const FcCache *c, int i);
|
||||
|
||||
FcPublic int
|
||||
FcCacheNumSubdir (const FcCache *c);
|
||||
|
||||
FcPublic int
|
||||
FcCacheNumFont (const FcCache *c);
|
||||
|
||||
FcPublic FcBool
|
||||
FcDirCacheUnlink (const FcChar8 *dir, FcConfig *config);
|
||||
|
||||
FcPublic FcBool
|
||||
FcDirCacheValid (const FcChar8 *cache_file);
|
||||
|
||||
/* fccfg.c */
|
||||
FcChar8 *
|
||||
FcPublic FcChar8 *
|
||||
FcConfigHome (void);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcConfigEnableHome (FcBool enable);
|
||||
|
||||
FcChar8 *
|
||||
FcPublic FcChar8 *
|
||||
FcConfigFilename (const FcChar8 *url);
|
||||
|
||||
FcConfig *
|
||||
FcPublic FcConfig *
|
||||
FcConfigCreate (void);
|
||||
|
||||
void
|
||||
FcPublic void
|
||||
FcConfigDestroy (FcConfig *config);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcConfigSetCurrent (FcConfig *config);
|
||||
|
||||
FcConfig *
|
||||
FcPublic FcConfig *
|
||||
FcConfigGetCurrent (void);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcConfigUptoDate (FcConfig *config);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcConfigBuildFonts (FcConfig *config);
|
||||
|
||||
FcStrList *
|
||||
FcPublic FcStrList *
|
||||
FcConfigGetFontDirs (FcConfig *config);
|
||||
|
||||
FcStrList *
|
||||
FcPublic FcStrList *
|
||||
FcConfigGetConfigDirs (FcConfig *config);
|
||||
|
||||
FcStrList *
|
||||
FcPublic FcStrList *
|
||||
FcConfigGetConfigFiles (FcConfig *config);
|
||||
|
||||
FcChar8 *
|
||||
FcPublic FcChar8 *
|
||||
FcConfigGetCache (FcConfig *config);
|
||||
|
||||
FcBlanks *
|
||||
FcPublic FcBlanks *
|
||||
FcConfigGetBlanks (FcConfig *config);
|
||||
|
||||
int
|
||||
FcConfigGetRescanInverval (FcConfig *config);
|
||||
FcPublic FcStrList *
|
||||
FcConfigGetCacheDirs (FcConfig *config);
|
||||
|
||||
FcBool
|
||||
FcConfigSetRescanInverval (FcConfig *config, int rescanInterval);
|
||||
FcPublic int
|
||||
FcConfigGetRescanInterval (FcConfig *config);
|
||||
|
||||
FcFontSet *
|
||||
FcPublic FcBool
|
||||
FcConfigSetRescanInterval (FcConfig *config, int rescanInterval);
|
||||
|
||||
FcPublic FcFontSet *
|
||||
FcConfigGetFonts (FcConfig *config,
|
||||
FcSetName set);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcConfigAppFontAddFile (FcConfig *config,
|
||||
const FcChar8 *file);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcConfigAppFontAddDir (FcConfig *config,
|
||||
const FcChar8 *dir);
|
||||
|
||||
void
|
||||
FcPublic void
|
||||
FcConfigAppFontClear (FcConfig *config);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcConfigSubstituteWithPat (FcConfig *config,
|
||||
FcPattern *p,
|
||||
FcPattern *p_pat,
|
||||
FcMatchKind kind);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcConfigSubstitute (FcConfig *config,
|
||||
FcPattern *p,
|
||||
FcMatchKind kind);
|
||||
|
||||
/* fccharset.c */
|
||||
FcCharSet *
|
||||
FcPublic FcCharSet*
|
||||
FcCharSetCreate (void);
|
||||
|
||||
void
|
||||
/* deprecated alias for FcCharSetCreate */
|
||||
FcPublic FcCharSet *
|
||||
FcCharSetNew (void);
|
||||
|
||||
FcPublic void
|
||||
FcCharSetDestroy (FcCharSet *fcs);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcCharSetAddChar (FcCharSet *fcs, FcChar32 ucs4);
|
||||
|
||||
FcCharSet *
|
||||
FcPublic FcCharSet*
|
||||
FcCharSetCopy (FcCharSet *src);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcCharSetEqual (const FcCharSet *a, const FcCharSet *b);
|
||||
|
||||
FcCharSet *
|
||||
FcPublic FcCharSet*
|
||||
FcCharSetIntersect (const FcCharSet *a, const FcCharSet *b);
|
||||
|
||||
FcCharSet *
|
||||
FcPublic FcCharSet*
|
||||
FcCharSetUnion (const FcCharSet *a, const FcCharSet *b);
|
||||
|
||||
FcCharSet *
|
||||
FcPublic FcCharSet*
|
||||
FcCharSetSubtract (const FcCharSet *a, const FcCharSet *b);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcCharSetHasChar (const FcCharSet *fcs, FcChar32 ucs4);
|
||||
|
||||
FcChar32
|
||||
FcPublic FcChar32
|
||||
FcCharSetCount (const FcCharSet *a);
|
||||
|
||||
FcChar32
|
||||
FcPublic FcChar32
|
||||
FcCharSetIntersectCount (const FcCharSet *a, const FcCharSet *b);
|
||||
|
||||
FcChar32
|
||||
FcPublic FcChar32
|
||||
FcCharSetSubtractCount (const FcCharSet *a, const FcCharSet *b);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcCharSetIsSubset (const FcCharSet *a, const FcCharSet *b);
|
||||
|
||||
#define FC_CHARSET_MAP_SIZE (256/32)
|
||||
#define FC_CHARSET_DONE ((FcChar32) -1)
|
||||
|
||||
FcChar32
|
||||
FcPublic FcChar32
|
||||
FcCharSetFirstPage (const FcCharSet *a,
|
||||
FcChar32 map[FC_CHARSET_MAP_SIZE],
|
||||
FcChar32 *next);
|
||||
|
||||
FcChar32
|
||||
FcPublic FcChar32
|
||||
FcCharSetNextPage (const FcCharSet *a,
|
||||
FcChar32 map[FC_CHARSET_MAP_SIZE],
|
||||
FcChar32 *next);
|
||||
|
||||
/*
|
||||
* old coverage API, rather hard to use correctly
|
||||
*/
|
||||
|
||||
FcPublic FcChar32
|
||||
FcCharSetCoverage (const FcCharSet *a, FcChar32 page, FcChar32 *result);
|
||||
|
||||
/* fcdbg.c */
|
||||
void
|
||||
FcPublic void
|
||||
FcValuePrint (const FcValue v);
|
||||
|
||||
void
|
||||
FcPublic void
|
||||
FcPatternPrint (const FcPattern *p);
|
||||
|
||||
void
|
||||
FcPublic void
|
||||
FcFontSetPrint (const FcFontSet *s);
|
||||
|
||||
/* fcdefault.c */
|
||||
void
|
||||
FcPublic void
|
||||
FcDefaultSubstitute (FcPattern *pattern);
|
||||
|
||||
/* fcdir.c */
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcFileIsDir (const FcChar8 *file);
|
||||
|
||||
FcPublic FcBool
|
||||
FcFileScan (FcFontSet *set,
|
||||
FcStrSet *dirs,
|
||||
FcFileCache *cache,
|
||||
@ -419,7 +490,7 @@ FcFileScan (FcFontSet *set,
|
||||
const FcChar8 *file,
|
||||
FcBool force);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcDirScan (FcFontSet *set,
|
||||
FcStrSet *dirs,
|
||||
FcFileCache *cache,
|
||||
@ -427,144 +498,165 @@ FcDirScan (FcFontSet *set,
|
||||
const FcChar8 *dir,
|
||||
FcBool force);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcDirSave (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir);
|
||||
|
||||
FcPublic FcCache *
|
||||
FcDirCacheLoad (const FcChar8 *dir, FcConfig *config, FcChar8 **cache_file);
|
||||
|
||||
FcPublic FcCache *
|
||||
FcDirCacheRead (const FcChar8 *dir, FcBool force, FcConfig *config);
|
||||
|
||||
FcPublic FcCache *
|
||||
FcDirCacheLoadFile (const FcChar8 *cache_file, struct stat *file_stat);
|
||||
|
||||
FcPublic void
|
||||
FcDirCacheUnload (FcCache *cache);
|
||||
|
||||
/* fcfreetype.c */
|
||||
FcPattern *
|
||||
FcPublic FcPattern *
|
||||
FcFreeTypeQuery (const FcChar8 *file, int id, FcBlanks *blanks, int *count);
|
||||
|
||||
/* fcfs.c */
|
||||
|
||||
FcFontSet *
|
||||
FcPublic FcFontSet *
|
||||
FcFontSetCreate (void);
|
||||
|
||||
void
|
||||
FcPublic void
|
||||
FcFontSetDestroy (FcFontSet *s);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcFontSetAdd (FcFontSet *s, FcPattern *font);
|
||||
|
||||
/* fcinit.c */
|
||||
FcConfig *
|
||||
FcPublic FcConfig *
|
||||
FcInitLoadConfig (void);
|
||||
|
||||
FcConfig *
|
||||
FcPublic FcConfig *
|
||||
FcInitLoadConfigAndFonts (void);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcInit (void);
|
||||
|
||||
int
|
||||
FcPublic void
|
||||
FcFini (void);
|
||||
|
||||
FcPublic int
|
||||
FcGetVersion (void);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcInitReinitialize (void);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcInitBringUptoDate (void);
|
||||
|
||||
/* fclang.c */
|
||||
FcLangSet *
|
||||
FcPublic FcStrSet *
|
||||
FcGetLangs (void);
|
||||
|
||||
FcPublic const FcCharSet *
|
||||
FcLangGetCharSet (const FcChar8 *lang);
|
||||
|
||||
FcPublic FcLangSet*
|
||||
FcLangSetCreate (void);
|
||||
|
||||
void
|
||||
FcPublic void
|
||||
FcLangSetDestroy (FcLangSet *ls);
|
||||
|
||||
FcLangSet *
|
||||
FcPublic FcLangSet*
|
||||
FcLangSetCopy (const FcLangSet *ls);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcLangSetAdd (FcLangSet *ls, const FcChar8 *lang);
|
||||
|
||||
FcLangResult
|
||||
FcPublic FcLangResult
|
||||
FcLangSetHasLang (const FcLangSet *ls, const FcChar8 *lang);
|
||||
|
||||
FcLangResult
|
||||
FcPublic FcLangResult
|
||||
FcLangSetCompare (const FcLangSet *lsa, const FcLangSet *lsb);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcLangSetContains (const FcLangSet *lsa, const FcLangSet *lsb);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcLangSetEqual (const FcLangSet *lsa, const FcLangSet *lsb);
|
||||
|
||||
FcChar32
|
||||
FcPublic FcChar32
|
||||
FcLangSetHash (const FcLangSet *ls);
|
||||
|
||||
/* fclist.c */
|
||||
FcObjectSet *
|
||||
FcPublic FcObjectSet *
|
||||
FcObjectSetCreate (void);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcObjectSetAdd (FcObjectSet *os, const char *object);
|
||||
|
||||
void
|
||||
FcPublic void
|
||||
FcObjectSetDestroy (FcObjectSet *os);
|
||||
|
||||
FcObjectSet *
|
||||
FcPublic FcObjectSet *
|
||||
FcObjectSetVaBuild (const char *first, va_list va);
|
||||
|
||||
FcObjectSet *
|
||||
FcObjectSetBuild (const char *first, ...);
|
||||
FcPublic FcObjectSet *
|
||||
FcObjectSetBuild (const char *first, ...) FC_ATTRIBUTE_SENTINEL(0);
|
||||
|
||||
FcFontSet *
|
||||
FcPublic FcFontSet *
|
||||
FcFontSetList (FcConfig *config,
|
||||
FcFontSet **sets,
|
||||
int nsets,
|
||||
FcPattern *p,
|
||||
FcObjectSet *os);
|
||||
|
||||
FcFontSet *
|
||||
FcPublic FcFontSet *
|
||||
FcFontList (FcConfig *config,
|
||||
FcPattern *p,
|
||||
FcObjectSet *os);
|
||||
|
||||
/* fcatomic.c */
|
||||
|
||||
FcAtomic *
|
||||
FcPublic FcAtomic *
|
||||
FcAtomicCreate (const FcChar8 *file);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcAtomicLock (FcAtomic *atomic);
|
||||
|
||||
FcChar8 *
|
||||
FcPublic FcChar8 *
|
||||
FcAtomicNewFile (FcAtomic *atomic);
|
||||
|
||||
FcChar8 *
|
||||
FcPublic FcChar8 *
|
||||
FcAtomicOrigFile (FcAtomic *atomic);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcAtomicReplaceOrig (FcAtomic *atomic);
|
||||
|
||||
void
|
||||
FcPublic void
|
||||
FcAtomicDeleteNew (FcAtomic *atomic);
|
||||
|
||||
void
|
||||
FcPublic void
|
||||
FcAtomicUnlock (FcAtomic *atomic);
|
||||
|
||||
void
|
||||
FcPublic void
|
||||
FcAtomicDestroy (FcAtomic *atomic);
|
||||
|
||||
/* fcmatch.c */
|
||||
FcPattern *
|
||||
FcPublic FcPattern *
|
||||
FcFontSetMatch (FcConfig *config,
|
||||
FcFontSet **sets,
|
||||
int nsets,
|
||||
FcPattern *p,
|
||||
FcResult *result);
|
||||
|
||||
FcPattern *
|
||||
FcPublic FcPattern *
|
||||
FcFontMatch (FcConfig *config,
|
||||
FcPattern *p,
|
||||
FcResult *result);
|
||||
|
||||
FcPattern *
|
||||
FcPublic FcPattern *
|
||||
FcFontRenderPrepare (FcConfig *config,
|
||||
FcPattern *pat,
|
||||
FcPattern *font);
|
||||
|
||||
FcFontSet *
|
||||
FcPublic FcFontSet *
|
||||
FcFontSetSort (FcConfig *config,
|
||||
FcFontSet **sets,
|
||||
int nsets,
|
||||
@ -573,179 +665,198 @@ FcFontSetSort (FcConfig *config,
|
||||
FcCharSet **csp,
|
||||
FcResult *result);
|
||||
|
||||
FcFontSet *
|
||||
FcPublic FcFontSet *
|
||||
FcFontSort (FcConfig *config,
|
||||
FcPattern *p,
|
||||
FcBool trim,
|
||||
FcCharSet **csp,
|
||||
FcResult *result);
|
||||
|
||||
void
|
||||
FcPublic void
|
||||
FcFontSetSortDestroy (FcFontSet *fs);
|
||||
|
||||
/* fcmatrix.c */
|
||||
FcMatrix *
|
||||
FcPublic FcMatrix *
|
||||
FcMatrixCopy (const FcMatrix *mat);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcMatrixEqual (const FcMatrix *mat1, const FcMatrix *mat2);
|
||||
|
||||
void
|
||||
FcPublic void
|
||||
FcMatrixMultiply (FcMatrix *result, const FcMatrix *a, const FcMatrix *b);
|
||||
|
||||
void
|
||||
FcPublic void
|
||||
FcMatrixRotate (FcMatrix *m, double c, double s);
|
||||
|
||||
void
|
||||
FcPublic void
|
||||
FcMatrixScale (FcMatrix *m, double sx, double sy);
|
||||
|
||||
void
|
||||
FcPublic void
|
||||
FcMatrixShear (FcMatrix *m, double sh, double sv);
|
||||
|
||||
/* fcname.c */
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcNameRegisterObjectTypes (const FcObjectType *types, int ntype);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcNameUnregisterObjectTypes (const FcObjectType *types, int ntype);
|
||||
|
||||
const FcObjectType *
|
||||
FcPublic const FcObjectType *
|
||||
FcNameGetObjectType (const char *object);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcNameRegisterConstants (const FcConstant *consts, int nconsts);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcNameUnregisterConstants (const FcConstant *consts, int nconsts);
|
||||
|
||||
const FcConstant *
|
||||
FcPublic const FcConstant *
|
||||
FcNameGetConstant (FcChar8 *string);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcNameConstant (FcChar8 *string, int *result);
|
||||
|
||||
FcPattern *
|
||||
FcPublic FcPattern *
|
||||
FcNameParse (const FcChar8 *name);
|
||||
|
||||
FcChar8 *
|
||||
FcPublic FcChar8 *
|
||||
FcNameUnparse (FcPattern *pat);
|
||||
|
||||
/* fcpat.c */
|
||||
FcPattern *
|
||||
FcPublic FcPattern *
|
||||
FcPatternCreate (void);
|
||||
|
||||
FcPattern *
|
||||
FcPublic FcPattern *
|
||||
FcPatternDuplicate (const FcPattern *p);
|
||||
|
||||
void
|
||||
FcPublic void
|
||||
FcPatternReference (FcPattern *p);
|
||||
|
||||
void
|
||||
FcPublic void
|
||||
FcValueDestroy (FcValue v);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcValueEqual (FcValue va, FcValue vb);
|
||||
|
||||
FcValue
|
||||
FcPublic FcValue
|
||||
FcValueSave (FcValue v);
|
||||
|
||||
void
|
||||
FcPublic void
|
||||
FcPatternDestroy (FcPattern *p);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcPatternEqual (const FcPattern *pa, const FcPattern *pb);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcPatternEqualSubset (const FcPattern *pa, const FcPattern *pb, const FcObjectSet *os);
|
||||
|
||||
FcChar32
|
||||
FcPublic FcChar32
|
||||
FcPatternHash (const FcPattern *p);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcPatternAdd (FcPattern *p, const char *object, FcValue value, FcBool append);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcPatternAddWeak (FcPattern *p, const char *object, FcValue value, FcBool append);
|
||||
|
||||
FcResult
|
||||
FcPublic FcResult
|
||||
FcPatternGet (const FcPattern *p, const char *object, int id, FcValue *v);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcPatternDel (FcPattern *p, const char *object);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcPatternRemove (FcPattern *p, const char *object, int id);
|
||||
|
||||
FcPublic FcBool
|
||||
FcPatternAddInteger (FcPattern *p, const char *object, int i);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcPatternAddDouble (FcPattern *p, const char *object, double d);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcPatternAddString (FcPattern *p, const char *object, const FcChar8 *s);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcPatternAddMatrix (FcPattern *p, const char *object, const FcMatrix *s);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcPatternAddCharSet (FcPattern *p, const char *object, const FcCharSet *c);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcPatternAddBool (FcPattern *p, const char *object, FcBool b);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcPatternAddLangSet (FcPattern *p, const char *object, const FcLangSet *ls);
|
||||
|
||||
FcResult
|
||||
FcPublic FcResult
|
||||
FcPatternGetInteger (const FcPattern *p, const char *object, int n, int *i);
|
||||
|
||||
FcResult
|
||||
FcPublic FcResult
|
||||
FcPatternGetDouble (const FcPattern *p, const char *object, int n, double *d);
|
||||
|
||||
FcResult
|
||||
FcPublic FcResult
|
||||
FcPatternGetString (const FcPattern *p, const char *object, int n, FcChar8 ** s);
|
||||
|
||||
FcResult
|
||||
FcPublic FcResult
|
||||
FcPatternGetMatrix (const FcPattern *p, const char *object, int n, FcMatrix **s);
|
||||
|
||||
FcResult
|
||||
FcPublic FcResult
|
||||
FcPatternGetCharSet (const FcPattern *p, const char *object, int n, FcCharSet **c);
|
||||
|
||||
FcResult
|
||||
FcPublic FcResult
|
||||
FcPatternGetBool (const FcPattern *p, const char *object, int n, FcBool *b);
|
||||
|
||||
FcResult
|
||||
FcPublic FcResult
|
||||
FcPatternGetLangSet (const FcPattern *p, const char *object, int n, FcLangSet **ls);
|
||||
|
||||
FcPattern *
|
||||
FcPublic FcPattern *
|
||||
FcPatternVaBuild (FcPattern *orig, va_list va);
|
||||
|
||||
FcPattern *
|
||||
FcPatternBuild (FcPattern *orig, ...);
|
||||
FcPublic FcPattern *
|
||||
FcPatternBuild (FcPattern *orig, ...) FC_ATTRIBUTE_SENTINEL(0);
|
||||
|
||||
/* fcstr.c */
|
||||
|
||||
FcChar8 *
|
||||
FcPublic FcChar8 *
|
||||
FcStrCopy (const FcChar8 *s);
|
||||
|
||||
FcChar8 *
|
||||
FcPublic FcChar8 *
|
||||
FcStrCopyFilename (const FcChar8 *s);
|
||||
|
||||
#define FcIsUpper(c) (('A' <= (c) && (c) <= 'Z'))
|
||||
#define FcIsLower(c) (('a' <= (c) && (c) <= 'z'))
|
||||
#define FcToLower(c) (FcIsUpper(c) ? (c) - 'A' + 'a' : (c))
|
||||
FcPublic FcChar8 *
|
||||
FcStrPlus (const FcChar8 *s1, const FcChar8 *s2);
|
||||
|
||||
int
|
||||
FcPublic void
|
||||
FcStrFree (FcChar8 *s);
|
||||
|
||||
/* These are ASCII only, suitable only for pattern element names */
|
||||
#define FcIsUpper(c) ((0101 <= (c) && (c) <= 0132))
|
||||
#define FcIsLower(c) ((0141 <= (c) && (c) <= 0172))
|
||||
#define FcToLower(c) (FcIsUpper(c) ? (c) - 0101 + 0141 : (c))
|
||||
|
||||
FcPublic FcChar8 *
|
||||
FcStrDowncase (const FcChar8 *s);
|
||||
|
||||
FcPublic int
|
||||
FcStrCmpIgnoreCase (const FcChar8 *s1, const FcChar8 *s2);
|
||||
|
||||
int
|
||||
FcPublic int
|
||||
FcStrCmp (const FcChar8 *s1, const FcChar8 *s2);
|
||||
|
||||
int
|
||||
FcPublic const FcChar8 *
|
||||
FcStrStrIgnoreCase (const FcChar8 *s1, const FcChar8 *s2);
|
||||
|
||||
FcPublic const FcChar8 *
|
||||
FcStrStr (const FcChar8 *s1, const FcChar8 *s2);
|
||||
|
||||
FcPublic int
|
||||
FcUtf8ToUcs4 (const FcChar8 *src_orig,
|
||||
FcChar32 *dst,
|
||||
int len);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcUtf8Len (const FcChar8 *string,
|
||||
int len,
|
||||
int *nchar,
|
||||
@ -753,63 +864,78 @@ FcUtf8Len (const FcChar8 *string,
|
||||
|
||||
#define FC_UTF8_MAX_LEN 6
|
||||
|
||||
int
|
||||
FcPublic int
|
||||
FcUcs4ToUtf8 (FcChar32 ucs4,
|
||||
FcChar8 dest[FC_UTF8_MAX_LEN]);
|
||||
|
||||
int
|
||||
FcPublic int
|
||||
FcUtf16ToUcs4 (const FcChar8 *src_orig,
|
||||
FcEndian endian,
|
||||
FcChar32 *dst,
|
||||
int len); /* in bytes */
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcUtf16Len (const FcChar8 *string,
|
||||
FcEndian endian,
|
||||
int len, /* in bytes */
|
||||
int *nchar,
|
||||
int *wchar);
|
||||
|
||||
FcChar8 *
|
||||
FcPublic FcChar8 *
|
||||
FcStrDirname (const FcChar8 *file);
|
||||
|
||||
FcChar8 *
|
||||
FcPublic FcChar8 *
|
||||
FcStrBasename (const FcChar8 *file);
|
||||
|
||||
FcStrSet *
|
||||
FcPublic FcStrSet *
|
||||
FcStrSetCreate (void);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcStrSetMember (FcStrSet *set, const FcChar8 *s);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcStrSetEqual (FcStrSet *sa, FcStrSet *sb);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcStrSetAdd (FcStrSet *set, const FcChar8 *s);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcStrSetAddFilename (FcStrSet *set, const FcChar8 *s);
|
||||
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcStrSetDel (FcStrSet *set, const FcChar8 *s);
|
||||
|
||||
void
|
||||
FcPublic void
|
||||
FcStrSetDestroy (FcStrSet *set);
|
||||
|
||||
FcStrList *
|
||||
FcPublic FcStrList *
|
||||
FcStrListCreate (FcStrSet *set);
|
||||
|
||||
FcChar8 *
|
||||
FcPublic FcChar8 *
|
||||
FcStrListNext (FcStrList *list);
|
||||
|
||||
void
|
||||
FcPublic void
|
||||
FcStrListDone (FcStrList *list);
|
||||
|
||||
/* fcxml.c */
|
||||
FcBool
|
||||
FcPublic FcBool
|
||||
FcConfigParseAndLoad (FcConfig *config, const FcChar8 *file, FcBool complain);
|
||||
|
||||
_FCFUNCPROTOEND
|
||||
|
||||
#undef FC_ATTRIBUTE_SENTINEL
|
||||
|
||||
|
||||
#ifndef _FCINT_H_
|
||||
|
||||
/*
|
||||
* Deprecated functions are placed here to help users fix their code without
|
||||
* digging through documentation
|
||||
*/
|
||||
|
||||
#define FcConfigGetRescanInverval FcConfigGetRescanInverval_REPLACE_BY_FcConfigGetRescanInterval
|
||||
#define FcConfigSetRescanInverval FcConfigSetRescanInverval_REPLACE_BY_FcConfigSetRescanInterval
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _FONTCONFIG_H_ */
|
||||
|
@ -735,6 +735,25 @@ typedef FcPattern* (*FcFontMatchFuncType)(FcConfig *config,
|
||||
typedef FcFontSet* (*FcFontSetCreateFuncType)();
|
||||
typedef FcBool (*FcFontSetAddFuncType)(FcFontSet *s, FcPattern *font);
|
||||
|
||||
typedef FcResult (*FcPatternGetCharSetFuncType)(FcPattern *p,
|
||||
const char *object,
|
||||
int n,
|
||||
FcCharSet **c);
|
||||
typedef FcFontSet* (*FcFontSortFuncType)(FcConfig *config,
|
||||
FcPattern *p,
|
||||
FcBool trim,
|
||||
FcCharSet **csp,
|
||||
FcResult *result);
|
||||
typedef FcCharSet* (*FcCharSetUnionFuncType)(const FcCharSet *a,
|
||||
const FcCharSet *b);
|
||||
typedef FcChar32 (*FcCharSetSubtractCountFuncType)(const FcCharSet *a,
|
||||
const FcCharSet *b);
|
||||
|
||||
typedef int (*FcGetVersionFuncType)();
|
||||
|
||||
typedef FcStrList* (*FcConfigGetCacheDirsFuncType)(FcConfig *config);
|
||||
typedef FcChar8* (*FcStrListNextFuncType)(FcStrList *list);
|
||||
typedef FcChar8* (*FcStrListDoneFuncType)(FcStrList *list);
|
||||
|
||||
static char **getFontConfigLocations() {
|
||||
|
||||
@ -955,10 +974,35 @@ Java_sun_font_FontManager_getFontConfigAASettings
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_sun_font_FontManager_getFontConfigVersion
|
||||
(JNIEnv *env, jclass obj) {
|
||||
|
||||
void* libfontconfig;
|
||||
FcGetVersionFuncType FcGetVersion;
|
||||
int version = 0;
|
||||
|
||||
if ((libfontconfig = openFontConfig()) == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
FcGetVersion = (FcGetVersionFuncType)dlsym(libfontconfig, "FcGetVersion");
|
||||
|
||||
if (FcGetVersion == NULL) {
|
||||
closeFontConfig(libfontconfig, JNI_FALSE);
|
||||
return 0;
|
||||
}
|
||||
version = (*FcGetVersion)();
|
||||
closeFontConfig(libfontconfig, JNI_FALSE);
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_sun_font_FontManager_getFontConfig
|
||||
(JNIEnv *env, jclass obj, jstring localeStr, jobjectArray fontInfoArray) {
|
||||
(JNIEnv *env, jclass obj, jstring localeStr, jobject fcInfoObj,
|
||||
jobjectArray fcCompFontArray, jboolean includeFallbacks) {
|
||||
|
||||
FcNameParseFuncType FcNameParse;
|
||||
FcPatternAddStringFuncType FcPatternAddString;
|
||||
@ -967,33 +1011,70 @@ Java_sun_font_FontManager_getFontConfig
|
||||
FcFontMatchFuncType FcFontMatch;
|
||||
FcPatternGetStringFuncType FcPatternGetString;
|
||||
FcPatternDestroyFuncType FcPatternDestroy;
|
||||
FcPatternGetCharSetFuncType FcPatternGetCharSet;
|
||||
FcFontSortFuncType FcFontSort;
|
||||
FcFontSetDestroyFuncType FcFontSetDestroy;
|
||||
FcCharSetUnionFuncType FcCharSetUnion;
|
||||
FcCharSetSubtractCountFuncType FcCharSetSubtractCount;
|
||||
FcGetVersionFuncType FcGetVersion;
|
||||
FcConfigGetCacheDirsFuncType FcConfigGetCacheDirs;
|
||||
FcStrListNextFuncType FcStrListNext;
|
||||
FcStrListDoneFuncType FcStrListDone;
|
||||
|
||||
int i, arrlen;
|
||||
jobject fontInfoObj;
|
||||
jobject fcCompFontObj;
|
||||
jstring fcNameStr, jstr;
|
||||
const char *locale, *fcName;
|
||||
FcPattern *pattern, *matchPattern;
|
||||
FcPattern *pattern;
|
||||
FcResult result;
|
||||
void* libfontconfig;
|
||||
jfieldID fcNameID, familyNameID, fontFileID;
|
||||
jfieldID fcNameID, fcFirstFontID, fcAllFontsID, fcVersionID, fcCacheDirsID;
|
||||
jfieldID familyNameID, styleNameID, fullNameID, fontFileID;
|
||||
jmethodID fcFontCons;
|
||||
char* debugMinGlyphsStr = getenv("J2D_DEBUG_MIN_GLYPHS");
|
||||
|
||||
jclass fontInfoArrayClass =
|
||||
(*env)->FindClass(env, "[Lsun/font/FontManager$FontConfigInfo;");
|
||||
jclass fontInfoClass =
|
||||
jclass fcInfoClass =
|
||||
(*env)->FindClass(env, "sun/font/FontManager$FontConfigInfo");
|
||||
jclass fcCompFontClass =
|
||||
(*env)->FindClass(env, "sun/font/FontManager$FcCompFont");
|
||||
jclass fcFontClass =
|
||||
(*env)->FindClass(env, "sun/font/FontManager$FontConfigFont");
|
||||
|
||||
if (fontInfoArray == NULL || fontInfoClass == NULL) {
|
||||
if (fcInfoObj == NULL || fcCompFontArray == NULL || fcInfoClass == NULL ||
|
||||
fcCompFontClass == NULL || fcFontClass == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
fcNameID = (*env)->GetFieldID(env, fontInfoClass,
|
||||
fcVersionID = (*env)->GetFieldID(env, fcInfoClass, "fcVersion", "I");
|
||||
|
||||
fcCacheDirsID = (*env)->GetFieldID(env, fcInfoClass, "cacheDirs",
|
||||
"[Ljava/lang/String;");
|
||||
|
||||
fcNameID = (*env)->GetFieldID(env, fcCompFontClass,
|
||||
"fcName", "Ljava/lang/String;");
|
||||
familyNameID = (*env)->GetFieldID(env, fontInfoClass,
|
||||
fcFirstFontID =
|
||||
(*env)->GetFieldID(env, fcCompFontClass, "firstFont",
|
||||
"Lsun/font/FontManager$FontConfigFont;");
|
||||
|
||||
fcAllFontsID =
|
||||
(*env)->GetFieldID(env, fcCompFontClass, "allFonts",
|
||||
"[Lsun/font/FontManager$FontConfigFont;");
|
||||
|
||||
fcFontCons = (*env)->GetMethodID(env, fcFontClass, "<init>", "()V");
|
||||
|
||||
familyNameID = (*env)->GetFieldID(env, fcFontClass,
|
||||
"familyName", "Ljava/lang/String;");
|
||||
fontFileID = (*env)->GetFieldID(env, fontInfoClass,
|
||||
styleNameID = (*env)->GetFieldID(env, fcFontClass,
|
||||
"styleStr", "Ljava/lang/String;");
|
||||
fullNameID = (*env)->GetFieldID(env, fcFontClass,
|
||||
"fullName", "Ljava/lang/String;");
|
||||
fontFileID = (*env)->GetFieldID(env, fcFontClass,
|
||||
"fontFile", "Ljava/lang/String;");
|
||||
|
||||
if (fcNameID == NULL || familyNameID == NULL || fontFileID == NULL) {
|
||||
if (fcVersionID == NULL || fcCacheDirsID == NULL || fcNameID == NULL ||
|
||||
fcFirstFontID == NULL || fcAllFontsID == NULL || fcFontCons == NULL ||
|
||||
familyNameID == NULL || styleNameID == NULL || fullNameID == NULL ||
|
||||
fontFileID == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1013,6 +1094,19 @@ Java_sun_font_FontManager_getFontConfig
|
||||
(FcPatternGetStringFuncType)dlsym(libfontconfig, "FcPatternGetString");
|
||||
FcPatternDestroy =
|
||||
(FcPatternDestroyFuncType)dlsym(libfontconfig, "FcPatternDestroy");
|
||||
FcPatternGetCharSet =
|
||||
(FcPatternGetCharSetFuncType)dlsym(libfontconfig,
|
||||
"FcPatternGetCharSet");
|
||||
FcFontSort =
|
||||
(FcFontSortFuncType)dlsym(libfontconfig, "FcFontSort");
|
||||
FcFontSetDestroy =
|
||||
(FcFontSetDestroyFuncType)dlsym(libfontconfig, "FcFontSetDestroy");
|
||||
FcCharSetUnion =
|
||||
(FcCharSetUnionFuncType)dlsym(libfontconfig, "FcCharSetUnion");
|
||||
FcCharSetSubtractCount =
|
||||
(FcCharSetSubtractCountFuncType)dlsym(libfontconfig,
|
||||
"FcCharSetSubtractCount");
|
||||
FcGetVersion = (FcGetVersionFuncType)dlsym(libfontconfig, "FcGetVersion");
|
||||
|
||||
if (FcNameParse == NULL ||
|
||||
FcPatternAddString == NULL ||
|
||||
@ -1020,23 +1114,77 @@ Java_sun_font_FontManager_getFontConfig
|
||||
FcDefaultSubstitute == NULL ||
|
||||
FcFontMatch == NULL ||
|
||||
FcPatternGetString == NULL ||
|
||||
FcPatternDestroy == NULL) { /* problem with the library: return. */
|
||||
FcPatternDestroy == NULL ||
|
||||
FcPatternGetCharSet == NULL ||
|
||||
FcFontSetDestroy == NULL ||
|
||||
FcCharSetUnion == NULL ||
|
||||
FcGetVersion == NULL ||
|
||||
FcCharSetSubtractCount == NULL) {/* problem with the library: return.*/
|
||||
closeFontConfig(libfontconfig, JNI_FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
(*env)->SetIntField(env, fcInfoObj, fcVersionID, (*FcGetVersion)());
|
||||
|
||||
/* Optionally get the cache dir locations. This isn't
|
||||
* available until v 2.4.x, but this is OK since on those later versions
|
||||
* we can check the time stamps on the cache dirs to see if we
|
||||
* are out of date. There are a couple of assumptions here. First
|
||||
* that the time stamp on the directory changes when the contents are
|
||||
* updated. Secondly that the locations don't change. The latter is
|
||||
* most likely if a new version of fontconfig is installed, but we also
|
||||
* invalidate the cache if we detect that. Arguably even that is "rare",
|
||||
* and most likely is tied to an OS upgrade which gets a new file anyway.
|
||||
*/
|
||||
FcConfigGetCacheDirs =
|
||||
(FcConfigGetCacheDirsFuncType)dlsym(libfontconfig,
|
||||
"FcConfigGetCacheDirs");
|
||||
FcStrListNext =
|
||||
(FcStrListNextFuncType)dlsym(libfontconfig, "FcStrListNext");
|
||||
FcStrListDone =
|
||||
(FcStrListDoneFuncType)dlsym(libfontconfig, "FcStrListDone");
|
||||
if (FcStrListNext != NULL && FcStrListDone != NULL &&
|
||||
FcConfigGetCacheDirs != NULL) {
|
||||
|
||||
FcStrList* cacheDirs;
|
||||
FcChar8* cacheDir;
|
||||
int cnt = 0;
|
||||
jobject cacheDirArray =
|
||||
(*env)->GetObjectField(env, fcInfoObj, fcCacheDirsID);
|
||||
int max = (*env)->GetArrayLength(env, cacheDirArray);
|
||||
|
||||
cacheDirs = (*FcConfigGetCacheDirs)(NULL);
|
||||
if (cacheDirs != NULL) {
|
||||
while ((cnt < max) && (cacheDir = (*FcStrListNext)(cacheDirs))) {
|
||||
jstr = (*env)->NewStringUTF(env, (const char*)cacheDir);
|
||||
(*env)->SetObjectArrayElement(env, cacheDirArray, cnt++, jstr);
|
||||
}
|
||||
(*FcStrListDone)(cacheDirs);
|
||||
}
|
||||
}
|
||||
|
||||
locale = (*env)->GetStringUTFChars(env, localeStr, 0);
|
||||
|
||||
arrlen = (*env)->GetArrayLength(env, fontInfoArray);
|
||||
arrlen = (*env)->GetArrayLength(env, fcCompFontArray);
|
||||
for (i=0; i<arrlen; i++) {
|
||||
fontInfoObj = (*env)->GetObjectArrayElement(env, fontInfoArray, i);
|
||||
FcFontSet* fontset;
|
||||
int fn, j, fontCount, nfonts, minGlyphs;
|
||||
FcChar8 **family, **styleStr, **fullname, **file;
|
||||
jarray fcFontArr;
|
||||
|
||||
fcCompFontObj = (*env)->GetObjectArrayElement(env, fcCompFontArray, i);
|
||||
fcNameStr =
|
||||
(jstring)((*env)->GetObjectField(env, fontInfoObj, fcNameID));
|
||||
(jstring)((*env)->GetObjectField(env, fcCompFontObj, fcNameID));
|
||||
fcName = (*env)->GetStringUTFChars(env, fcNameStr, 0);
|
||||
if (fcName == NULL) {
|
||||
continue;
|
||||
}
|
||||
pattern = (*FcNameParse)((FcChar8 *)fcName);
|
||||
if (pattern == NULL) {
|
||||
closeFontConfig(libfontconfig, JNI_FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
/* locale may not usually be necessary as fontconfig appears to apply
|
||||
* this anyway based on the user's environment. However we want
|
||||
* to use the value of the JDK startup locale so this should take
|
||||
@ -1047,25 +1195,134 @@ Java_sun_font_FontManager_getFontConfig
|
||||
}
|
||||
(*FcConfigSubstitute)(NULL, pattern, FcMatchPattern);
|
||||
(*FcDefaultSubstitute)(pattern);
|
||||
matchPattern = (*FcFontMatch)(NULL, pattern, &result);
|
||||
if (matchPattern) {
|
||||
FcChar8 *file, *family;
|
||||
fontset = (*FcFontSort)(NULL, pattern, FcTrue, NULL, &result);
|
||||
if (fontset == NULL) {
|
||||
closeFontConfig(libfontconfig, JNI_FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
(*FcPatternGetString)(matchPattern, FC_FILE, 0, &file);
|
||||
(*FcPatternGetString)(matchPattern, FC_FAMILY, 0, &family);
|
||||
/* fontconfig returned us "nfonts". If we are just getting the
|
||||
* first font, we set nfont to zero. Otherwise we use "nfonts".
|
||||
* Next create separate C arrrays of length nfonts for family file etc.
|
||||
* Inspect the returned fonts and the ones we like (adds enough glyphs)
|
||||
* are added to the arrays and we increment 'fontCount'.
|
||||
*/
|
||||
if (includeFallbacks) {
|
||||
nfonts = fontset->nfont;
|
||||
} else {
|
||||
nfonts = 1;
|
||||
}
|
||||
family = (FcChar8**)calloc(nfonts, sizeof(FcChar8*));
|
||||
styleStr = (FcChar8**)calloc(nfonts, sizeof(FcChar8*));
|
||||
fullname = (FcChar8**)calloc(nfonts, sizeof(FcChar8*));
|
||||
file = (FcChar8**)calloc(nfonts, sizeof(FcChar8*));
|
||||
if (family == NULL || styleStr == NULL ||
|
||||
fullname == NULL || file == NULL) {
|
||||
closeFontConfig(libfontconfig, JNI_FALSE);
|
||||
return;
|
||||
}
|
||||
fontCount = 0;
|
||||
minGlyphs = 20;
|
||||
if (debugMinGlyphsStr != NULL) {
|
||||
int val = minGlyphs;
|
||||
sscanf(debugMinGlyphsStr, "%5d", &val);
|
||||
if (val >= 0 && val <= 65536) {
|
||||
minGlyphs = val;
|
||||
}
|
||||
}
|
||||
for (j=0; j<nfonts; j++) {
|
||||
FcPattern *fontPattern = fontset->fonts[j];
|
||||
FcChar8 *fontformat;
|
||||
FcCharSet *unionCharset, *charset;
|
||||
|
||||
if (file != NULL) {
|
||||
jstr = (*env)->NewStringUTF(env, (const char*)file);
|
||||
((*env)->SetObjectField(env, fontInfoObj, fontFileID, jstr));
|
||||
fontformat = NULL;
|
||||
(*FcPatternGetString)(fontPattern, FC_FONTFORMAT, 0, &fontformat);
|
||||
if (fontformat != NULL && strcmp((char*)fontformat, "TrueType")
|
||||
!= 0) {
|
||||
continue;
|
||||
}
|
||||
if (family != NULL) {
|
||||
jstr = (*env)->NewStringUTF(env, (const char*)family);
|
||||
((*env)->SetObjectField(env, fontInfoObj, familyNameID, jstr));
|
||||
result = (*FcPatternGetCharSet)(fontPattern,
|
||||
FC_CHARSET, 0, &charset);
|
||||
if (result != FcResultMatch) {
|
||||
closeFontConfig(libfontconfig, JNI_FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
/* We don't want 20 or 30 fonts, so once we hit 10 fonts,
|
||||
* then require that they really be adding value. Too many
|
||||
* adversely affects load time for minimal value-add.
|
||||
* This is still likely far more than we've had in the past.
|
||||
*/
|
||||
if (nfonts==10) {
|
||||
minGlyphs = 50;
|
||||
}
|
||||
if (j == 0) {
|
||||
unionCharset = charset;
|
||||
} else {
|
||||
if ((*FcCharSetSubtractCount)(charset, unionCharset)
|
||||
> minGlyphs) {
|
||||
unionCharset = (* FcCharSetUnion)(unionCharset, charset);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
fontCount++; // found a font we will use.
|
||||
(*FcPatternGetString)(fontPattern, FC_FILE, 0, &file[j]);
|
||||
(*FcPatternGetString)(fontPattern, FC_FAMILY, 0, &family[j]);
|
||||
(*FcPatternGetString)(fontPattern, FC_STYLE, 0, &styleStr[j]);
|
||||
(*FcPatternGetString)(fontPattern, FC_FULLNAME, 0, &fullname[j]);
|
||||
}
|
||||
|
||||
/* Once we get here 'fontCount' is the number of returned fonts
|
||||
* we actually want to use, so we create 'fcFontArr' of that length.
|
||||
* The non-null entries of "family[]" etc are those fonts.
|
||||
* Then loop again over all nfonts adding just those non-null ones
|
||||
* to 'fcFontArr'. If its null (we didn't want the font)
|
||||
* then we don't enter the main body.
|
||||
* So we should never get more than 'fontCount' entries.
|
||||
*/
|
||||
if (includeFallbacks) {
|
||||
fcFontArr =
|
||||
(*env)->NewObjectArray(env, fontCount, fcFontClass, NULL);
|
||||
(*env)->SetObjectField(env,fcCompFontObj, fcAllFontsID, fcFontArr);
|
||||
}
|
||||
fn=0;
|
||||
|
||||
for (j=0;j<nfonts;j++) {
|
||||
if (family[j] != NULL) {
|
||||
jobject fcFont =
|
||||
(*env)->NewObject(env, fcFontClass, fcFontCons);
|
||||
jstr = (*env)->NewStringUTF(env, (const char*)family[j]);
|
||||
(*env)->SetObjectField(env, fcFont, familyNameID, jstr);
|
||||
if (file[j] != NULL) {
|
||||
jstr = (*env)->NewStringUTF(env, (const char*)file[j]);
|
||||
(*env)->SetObjectField(env, fcFont, fontFileID, jstr);
|
||||
}
|
||||
if (styleStr[j] != NULL) {
|
||||
jstr = (*env)->NewStringUTF(env, (const char*)styleStr[j]);
|
||||
(*env)->SetObjectField(env, fcFont, styleNameID, jstr);
|
||||
}
|
||||
if (fullname[j] != NULL) {
|
||||
jstr = (*env)->NewStringUTF(env, (const char*)fullname[j]);
|
||||
(*env)->SetObjectField(env, fcFont, fullNameID, jstr);
|
||||
}
|
||||
if (fn==0) {
|
||||
(*env)->SetObjectField(env, fcCompFontObj,
|
||||
fcFirstFontID, fcFont);
|
||||
}
|
||||
if (includeFallbacks) {
|
||||
(*env)->SetObjectArrayElement(env, fcFontArr, fn++,fcFont);
|
||||
}
|
||||
}
|
||||
(*FcPatternDestroy)(matchPattern);
|
||||
}
|
||||
(*env)->ReleaseStringUTFChars (env, fcNameStr, (const char*)fcName);
|
||||
(*FcFontSetDestroy)(fontset);
|
||||
(*FcPatternDestroy)(pattern);
|
||||
free(family);
|
||||
free(styleStr);
|
||||
free(fullname);
|
||||
free(file);
|
||||
}
|
||||
|
||||
/* release resources and close the ".so" */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -471,7 +471,7 @@ Java_sun_java2d_opengl_GLXGraphicsConfig_getGLXConfigInfo(JNIEnv *env,
|
||||
GLXContext context;
|
||||
GLXPbuffer scratch;
|
||||
GLXGraphicsConfigInfo *glxinfo;
|
||||
jint caps = sun_java2d_opengl_OGLContext_CAPS_EMPTY;
|
||||
jint caps = CAPS_EMPTY;
|
||||
int db, alpha;
|
||||
const unsigned char *versionstr;
|
||||
|
||||
@ -581,11 +581,11 @@ Java_sun_java2d_opengl_GLXGraphicsConfig_getGLXConfigInfo(JNIEnv *env,
|
||||
// get config-specific capabilities
|
||||
j2d_glXGetFBConfigAttrib(awt_display, fbconfig, GLX_DOUBLEBUFFER, &db);
|
||||
if (db) {
|
||||
caps |= sun_java2d_opengl_OGLContext_CAPS_DOUBLEBUFFERED;
|
||||
caps |= CAPS_DOUBLEBUFFERED;
|
||||
}
|
||||
j2d_glXGetFBConfigAttrib(awt_display, fbconfig, GLX_ALPHA_SIZE, &alpha);
|
||||
if (alpha > 0) {
|
||||
caps |= sun_java2d_opengl_OGLContext_CAPS_STORED_ALPHA;
|
||||
caps |= CAPS_STORED_ALPHA;
|
||||
}
|
||||
|
||||
// initialize the OGLContext, which wraps the GLXFBConfig and GLXContext
|
||||
@ -662,11 +662,11 @@ Java_sun_java2d_opengl_GLXGraphicsConfig_getOGLCapabilities(JNIEnv *env,
|
||||
J2dTraceLn(J2D_TRACE_INFO, "GLXGraphicsConfig_getOGLCapabilities");
|
||||
|
||||
if (glxinfo == NULL || glxinfo->context == NULL) {
|
||||
return sun_java2d_opengl_OGLContext_CAPS_EMPTY;
|
||||
return CAPS_EMPTY;
|
||||
}
|
||||
|
||||
return glxinfo->context->caps;
|
||||
#else
|
||||
return sun_java2d_opengl_OGLContext_CAPS_EMPTY;
|
||||
return CAPS_EMPTY;
|
||||
#endif /* !HEADLESS */
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -47,6 +47,9 @@ extern DisposeFunc OGLSD_Dispose;
|
||||
|
||||
extern struct MComponentPeerIDs mComponentPeerIDs;
|
||||
|
||||
extern void
|
||||
OGLSD_SetNativeDimensions(JNIEnv *env, OGLSDOps *oglsdo, jint w, jint h);
|
||||
|
||||
jboolean surfaceCreationFailed = JNI_FALSE;
|
||||
|
||||
#endif /* !HEADLESS */
|
||||
@ -460,6 +463,8 @@ Java_sun_java2d_opengl_GLXSurfaceData_initPbuffer
|
||||
glxsdo->drawable = pbuffer;
|
||||
glxsdo->xdrawable = 0;
|
||||
|
||||
OGLSD_SetNativeDimensions(env, oglsdo, width, height);
|
||||
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -55,9 +55,7 @@ import sun.java2d.InvalidPipeException;
|
||||
import sun.java2d.loops.RenderLoops;
|
||||
import sun.java2d.loops.SurfaceType;
|
||||
import sun.java2d.loops.CompositeType;
|
||||
import sun.java2d.windows.Win32SurfaceData;
|
||||
import sun.java2d.windows.WinBackBuffer;
|
||||
import sun.java2d.windows.WindowsFlags;
|
||||
import sun.java2d.windows.GDIWindowSurfaceData;
|
||||
|
||||
/**
|
||||
* This is an implementation of a GraphicsConfiguration object for a
|
||||
@ -72,8 +70,6 @@ public class Win32GraphicsConfig extends GraphicsConfiguration
|
||||
protected Win32GraphicsDevice screen;
|
||||
protected int visual; //PixelFormatID
|
||||
protected RenderLoops solidloops;
|
||||
private static BufferCapabilities bufferCaps;
|
||||
private static ImageCapabilities imageCaps;
|
||||
|
||||
private static native void initIDs();
|
||||
|
||||
@ -170,32 +166,12 @@ public class Win32GraphicsConfig extends GraphicsConfiguration
|
||||
case Transparency.BITMASK:
|
||||
return new DirectColorModel(25, 0xff0000, 0xff00, 0xff, 0x1000000);
|
||||
case Transparency.TRANSLUCENT:
|
||||
return getTranslucentColorModel();
|
||||
return ColorModel.getRGBdefault();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static final int DCM_4444_RED_MASK = 0x0f00;
|
||||
private static final int DCM_4444_GRN_MASK = 0x00f0;
|
||||
private static final int DCM_4444_BLU_MASK = 0x000f;
|
||||
private static final int DCM_4444_ALP_MASK = 0xf000;
|
||||
static ColorModel translucentCM = null;
|
||||
public static ColorModel getTranslucentColorModel() {
|
||||
if (WindowsFlags.getD3DTexBpp() == 16) {
|
||||
if (translucentCM == null) {
|
||||
translucentCM = new DirectColorModel(16,
|
||||
DCM_4444_RED_MASK,
|
||||
DCM_4444_GRN_MASK,
|
||||
DCM_4444_BLU_MASK,
|
||||
DCM_4444_ALP_MASK);
|
||||
}
|
||||
return translucentCM;
|
||||
} else {
|
||||
return ColorModel.getRGBdefault();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default Transform for this configuration. This
|
||||
* Transform is typically the Identity transform for most normal
|
||||
@ -246,44 +222,6 @@ public class Win32GraphicsConfig extends GraphicsConfiguration
|
||||
return getBounds(screen.getScreen());
|
||||
}
|
||||
|
||||
private static class DDrawBufferCapabilities extends BufferCapabilities {
|
||||
public DDrawBufferCapabilities(ImageCapabilities imageCaps) {
|
||||
super(imageCaps, imageCaps, FlipContents.PRIOR);
|
||||
}
|
||||
public boolean isFullScreenRequired() { return true; }
|
||||
public boolean isMultiBufferAvailable() { return true; }
|
||||
}
|
||||
|
||||
private static class DDrawImageCapabilities extends ImageCapabilities {
|
||||
public DDrawImageCapabilities() {
|
||||
super(true);
|
||||
}
|
||||
public boolean isTrueVolatile() { return true; }
|
||||
}
|
||||
|
||||
public BufferCapabilities getBufferCapabilities() {
|
||||
if (bufferCaps == null) {
|
||||
if (WindowsFlags.isDDEnabled()) {
|
||||
bufferCaps = new DDrawBufferCapabilities(
|
||||
getImageCapabilities());
|
||||
} else {
|
||||
bufferCaps = super.getBufferCapabilities();
|
||||
}
|
||||
}
|
||||
return bufferCaps;
|
||||
}
|
||||
|
||||
public ImageCapabilities getImageCapabilities() {
|
||||
if (imageCaps == null) {
|
||||
if (WindowsFlags.isDDEnabled()) {
|
||||
imageCaps = new DDrawImageCapabilities();
|
||||
} else {
|
||||
imageCaps = super.getImageCapabilities();
|
||||
}
|
||||
}
|
||||
return imageCaps;
|
||||
}
|
||||
|
||||
public synchronized void displayChanged() {
|
||||
solidloops = null;
|
||||
}
|
||||
@ -305,11 +243,11 @@ public class Win32GraphicsConfig extends GraphicsConfiguration
|
||||
public SurfaceData createSurfaceData(WComponentPeer peer,
|
||||
int numBackBuffers)
|
||||
{
|
||||
return Win32SurfaceData.createData(peer, numBackBuffers);
|
||||
return GDIWindowSurfaceData.createData(peer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new hidden-acceleration image of the given width and height
|
||||
* Creates a new managed image of the given width and height
|
||||
* that is associated with the target Component.
|
||||
*/
|
||||
public Image createAcceleratedImage(Component target,
|
||||
@ -327,15 +265,6 @@ public class Win32GraphicsConfig extends GraphicsConfiguration
|
||||
* WComponentPeer.java...
|
||||
*/
|
||||
|
||||
private boolean isFullScreenExclusive(Component target) {
|
||||
Win32GraphicsDevice gd = (Win32GraphicsDevice)getDevice();
|
||||
while (target != null && !(target instanceof Window)) {
|
||||
target = target.getParent();
|
||||
}
|
||||
return (target == gd.getFullScreenWindow() &&
|
||||
gd.isDDEnabledOnDevice());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the requested configuration is natively supported; if not,
|
||||
* an AWTException is thrown.
|
||||
@ -345,51 +274,61 @@ public class Win32GraphicsConfig extends GraphicsConfiguration
|
||||
BufferCapabilities caps)
|
||||
throws AWTException
|
||||
{
|
||||
if (!isFullScreenExclusive(target)) {
|
||||
throw new AWTException(
|
||||
"The operation requested is only supported on a full-screen" +
|
||||
" exclusive window");
|
||||
}
|
||||
// the default pipeline doesn't support flip buffer strategy
|
||||
throw new AWTException(
|
||||
"The operation requested is not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a backbuffer for the given peer and returns the image wrapper.
|
||||
* This method is called from WComponentPeer when a surface data is replaced
|
||||
* REMIND: while the default pipeline doesn't support flipping, it may
|
||||
* happen that the accelerated device may have this graphics config
|
||||
* (like if the device restoration failed when one device exits fs mode
|
||||
* while others remain).
|
||||
*/
|
||||
public VolatileImage createBackBuffer(WComponentPeer peer) {
|
||||
// Create the back buffer object
|
||||
return new WinBackBuffer((Component)peer.getTarget(),
|
||||
(Win32SurfaceData)peer.getSurfaceData());
|
||||
Component target = (Component)peer.getTarget();
|
||||
return new SunVolatileImage(target,
|
||||
target.getWidth(), target.getHeight(),
|
||||
Boolean.TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the native flip operation for the given target Component.
|
||||
*
|
||||
* REMIND: we should really not get here because that would mean that
|
||||
* a FLIP BufferStrategy has been created, and one could only be created
|
||||
* if accelerated pipeline is present but in some rare (and transitional)
|
||||
* cases it may happen that the accelerated graphics device may have a
|
||||
* default graphics configuraiton, so this is just a precaution.
|
||||
*/
|
||||
public void flip(WComponentPeer peer,
|
||||
Component target, VolatileImage backBuffer,
|
||||
int x1, int y1, int x2, int y2,
|
||||
BufferCapabilities.FlipContents flipAction)
|
||||
{
|
||||
int width = target.getWidth();
|
||||
int height = target.getHeight();
|
||||
if (flipAction == BufferCapabilities.FlipContents.COPIED) {
|
||||
Graphics g = target.getGraphics();
|
||||
g.drawImage(backBuffer, 0, 0, width, height, null);
|
||||
g.dispose();
|
||||
return;
|
||||
}
|
||||
Win32SurfaceData sd = (Win32SurfaceData)peer.getSurfaceData();
|
||||
try {
|
||||
sd.flip(((WinBackBuffer)backBuffer).getHWSurfaceData());
|
||||
} catch (sun.java2d.InvalidPipeException e) {
|
||||
// copy software surface to the screen via gdi blit
|
||||
Graphics g = target.getGraphics();
|
||||
g.drawImage(backBuffer, 0, 0, width, height, null);
|
||||
g.dispose();
|
||||
}
|
||||
if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) {
|
||||
if (flipAction == BufferCapabilities.FlipContents.COPIED ||
|
||||
flipAction == BufferCapabilities.FlipContents.UNDEFINED) {
|
||||
Graphics g = peer.getGraphics();
|
||||
try {
|
||||
g.drawImage(backBuffer,
|
||||
x1, y1, x2, y2,
|
||||
x1, y1, x2, y2,
|
||||
null);
|
||||
} finally {
|
||||
g.dispose();
|
||||
}
|
||||
} else if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) {
|
||||
Graphics g = backBuffer.getGraphics();
|
||||
g.setColor(target.getBackground());
|
||||
g.fillRect(0, 0, width, height);
|
||||
g.dispose();
|
||||
try {
|
||||
g.setColor(target.getBackground());
|
||||
g.fillRect(0, 0,
|
||||
backBuffer.getWidth(),
|
||||
backBuffer.getHeight());
|
||||
} finally {
|
||||
g.dispose();
|
||||
}
|
||||
}
|
||||
// the rest of the flip actions are not supported
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -33,12 +33,14 @@ import java.awt.DisplayMode;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowListener;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Vector;
|
||||
import java.awt.peer.WindowPeer;
|
||||
import sun.awt.windows.WWindowPeer;
|
||||
import sun.java2d.d3d.D3DContext;
|
||||
import sun.java2d.opengl.WGLGraphicsConfig;
|
||||
import sun.java2d.windows.WindowsFlags;
|
||||
|
||||
@ -54,13 +56,11 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
|
||||
int screen;
|
||||
ColorModel dynamicColorModel; // updated with dev changes
|
||||
ColorModel colorModel; // static for device
|
||||
GraphicsConfiguration[] configs;
|
||||
GraphicsConfiguration defaultConfig;
|
||||
boolean offscreenAccelerationEnabled = true;
|
||||
private D3DContext d3dContext;
|
||||
protected GraphicsConfiguration[] configs;
|
||||
protected GraphicsConfiguration defaultConfig;
|
||||
|
||||
private final String idString;
|
||||
private final String descString;
|
||||
protected String descString;
|
||||
// Note that we do not synchronize access to this variable - it doesn't
|
||||
// really matter if a thread does an operation on graphics device which is
|
||||
// about to become invalid (or already become) - we are prepared to deal
|
||||
@ -69,12 +69,16 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
|
||||
|
||||
// keep track of top-level windows on this display
|
||||
private SunDisplayChanger topLevels = new SunDisplayChanger();
|
||||
private static boolean pfDisabled;
|
||||
// REMIND: we may disable the use of pixel formats for some accelerated
|
||||
// pipelines which are mutually exclusive with opengl, for which
|
||||
// pixel formats were added in the first place
|
||||
protected static boolean pfDisabled;
|
||||
private static AWTPermission fullScreenExclusivePermission;
|
||||
private Rectangle ownerWindowedModeBounds = null;
|
||||
// the original display mode we had before entering the fullscreen
|
||||
// mode
|
||||
private DisplayMode defaultDisplayMode;
|
||||
// activation/deactivation listener for the full-screen window
|
||||
private WindowListener fsWindowListener;
|
||||
|
||||
static {
|
||||
|
||||
@ -91,16 +95,6 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
|
||||
|
||||
private static native void initIDs();
|
||||
|
||||
/**
|
||||
* Acceleration can be disabled due to capabilities of the display
|
||||
* device discovered during ddraw initialization. This is not the
|
||||
* same as isDDEnabledOnDevice(), which returns false when ddraw
|
||||
* was disabled by the user or had problems initializing.
|
||||
*/
|
||||
public boolean isOffscreenAccelerationEnabled() {
|
||||
return offscreenAccelerationEnabled;
|
||||
}
|
||||
|
||||
native void initDevice(int screen);
|
||||
|
||||
public Win32GraphicsDevice(int screennum) {
|
||||
@ -109,6 +103,7 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
|
||||
// to reflect the original screen number (which may change if the
|
||||
// device is removed)
|
||||
idString = "\\Display"+screen;
|
||||
// REMIND: may be should use class name?
|
||||
descString = "Win32GraphicsDevice[screen=" + screen;
|
||||
valid = true;
|
||||
|
||||
@ -136,7 +131,7 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
|
||||
* Returns whether this is a valid devicie. Device can become
|
||||
* invalid as a result of device removal event.
|
||||
*/
|
||||
boolean isValid() {
|
||||
public boolean isValid() {
|
||||
return valid;
|
||||
}
|
||||
|
||||
@ -145,7 +140,7 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
|
||||
*
|
||||
* @param defaultScreen the current default screen
|
||||
*/
|
||||
void invalidate(int defaultScreen) {
|
||||
protected void invalidate(int defaultScreen) {
|
||||
valid = false;
|
||||
screen = defaultScreen;
|
||||
}
|
||||
@ -178,8 +173,7 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
|
||||
int defaultPixID = getDefaultPixID(screen);
|
||||
Vector v = new Vector( max );
|
||||
if (defaultPixID == 0) {
|
||||
// Workaround for failing GDI calls, or if DirectDraw
|
||||
// is disabled
|
||||
// Workaround for failing GDI calls
|
||||
defaultConfig = Win32GraphicsConfig.getConfig(this,
|
||||
defaultPixID);
|
||||
v.addElement(defaultConfig);
|
||||
@ -309,32 +303,6 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
|
||||
getLocalGraphicsEnvironment().getDefaultScreenDevice());
|
||||
}
|
||||
|
||||
private native boolean isDDEnabledOnDeviceNative(int screen);
|
||||
|
||||
public D3DContext getD3DContext() {
|
||||
if (d3dContext == null) {
|
||||
d3dContext = new D3DContext(this);
|
||||
}
|
||||
return d3dContext;
|
||||
}
|
||||
|
||||
|
||||
public boolean isDDEnabledOnDevice() {
|
||||
return (WindowsFlags.isDDEnabled() && isValid() &&
|
||||
isDDEnabledOnDeviceNative(screen));
|
||||
}
|
||||
|
||||
public boolean isD3DEnabledOnDevice() {
|
||||
// The conditions under which we enable the D3D pipeline for the device:
|
||||
// - d3d is not disabled via a flag
|
||||
// - either d3d is forced via property or we're in fullscreen mode
|
||||
// - the hardware/drivers meet our requirements
|
||||
return (WindowsFlags.isD3DEnabled() && isValid() &&
|
||||
(WindowsFlags.isD3DSet() || getFullScreenWindow() != null) &&
|
||||
((getD3DContext().getDeviceCaps() &
|
||||
D3DContext.J2D_D3D_ENABLED_OK) != 0));
|
||||
}
|
||||
|
||||
private static boolean isFSExclusiveModeAllowed() {
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
@ -352,31 +320,14 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
|
||||
}
|
||||
|
||||
/**
|
||||
* We support the exclusive fullscreen mode in both ddraw and
|
||||
* noddraw modes, so we return true unless we're not allowed to use
|
||||
* fullscreen mode.
|
||||
* returns true unless we're not allowed to use fullscreen mode.
|
||||
*/
|
||||
@Override
|
||||
public boolean isFullScreenSupported() {
|
||||
return isFSExclusiveModeAllowed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the owning Frame for a given Window. Used in setFSWindow below
|
||||
* to set the properties of the owning Frame when a Window goes
|
||||
* into fullscreen mode.
|
||||
*/
|
||||
private Frame getToplevelOwner(Window w) {
|
||||
Window owner = w;
|
||||
while (owner != null) {
|
||||
owner = owner.getOwner();
|
||||
if (owner instanceof Frame) {
|
||||
return (Frame) owner;
|
||||
}
|
||||
}
|
||||
// Should not get here, but return something intelligent just in case
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void setFullScreenWindow(Window w) {
|
||||
Window old = getFullScreenWindow();
|
||||
if (w == old) {
|
||||
@ -402,51 +353,25 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
|
||||
}
|
||||
WWindowPeer peer = (WWindowPeer)old.getPeer();
|
||||
if (peer != null) {
|
||||
// we used to destroy the buffers on exiting fs mode, this
|
||||
// is no longer needed since fs change will cause a surface
|
||||
// data replacement
|
||||
synchronized(peer) {
|
||||
peer.destroyBuffers();
|
||||
exitFullScreenExclusive(isDDEnabledOnDevice(),
|
||||
screen, peer);
|
||||
exitFullScreenExclusive(screen, peer);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Bug 4933099: There is some funny-business to deal with when this
|
||||
* method is called with a Window instead of a Frame. See 4836744
|
||||
* for more information on this. One side-effect of our workaround
|
||||
* for the problem is that the owning Frame of a Window may end
|
||||
* up getting resized during the fullscreen process. When we
|
||||
* return from fullscreen mode, we should resize the Frame to
|
||||
* its original size (just like the Window is being resized
|
||||
* to its original size in GraphicsDevice).
|
||||
*/
|
||||
if (!(old instanceof Frame)) {
|
||||
Frame owner = getToplevelOwner(old);
|
||||
if (owner != null && ownerWindowedModeBounds != null) {
|
||||
owner.setBounds(ownerWindowedModeBounds);
|
||||
}
|
||||
ownerWindowedModeBounds = null;
|
||||
}
|
||||
removeFSWindowListener(old);
|
||||
}
|
||||
super.setFullScreenWindow(w);
|
||||
if (w != null) {
|
||||
// always record the default display mode prior to going
|
||||
// fullscreen
|
||||
defaultDisplayMode = getDisplayMode();
|
||||
// Bug 4933099
|
||||
if (!(w instanceof Frame)) {
|
||||
Frame owner = getToplevelOwner(w);
|
||||
if (owner != null) {
|
||||
ownerWindowedModeBounds = owner.getBounds();
|
||||
// These will get set for the native window in
|
||||
// any case. Set them here so that resetting them
|
||||
// later actually does the right thing
|
||||
owner.setBounds(w.getBounds());
|
||||
}
|
||||
}
|
||||
addFSWindowListener(w);
|
||||
// Enter full screen exclusive mode.
|
||||
WWindowPeer peer = (WWindowPeer)w.getPeer();
|
||||
synchronized(peer) {
|
||||
enterFullScreenExclusive(isDDEnabledOnDevice(),
|
||||
screen, peer);
|
||||
enterFullScreenExclusive(screen, peer);
|
||||
// Note: removed replaceSurfaceData() call because
|
||||
// changing the window size or making it visible
|
||||
// will cause this anyway, and both of these events happen
|
||||
@ -463,15 +388,18 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
|
||||
// tree-lock and should never lock on any resources which are
|
||||
// required by other threads which may have them and may require
|
||||
// the tree-lock.
|
||||
private native void enterFullScreenExclusive(boolean useDD,
|
||||
int screen, WindowPeer w);
|
||||
private native void exitFullScreenExclusive(boolean useDD,
|
||||
int screen, WindowPeer w);
|
||||
// REMIND: in the future these methods may need to become protected so that
|
||||
// subclasses could override them and use appropriate api other than GDI
|
||||
// for implementing these functions.
|
||||
protected native void enterFullScreenExclusive(int screen, WindowPeer w);
|
||||
protected native void exitFullScreenExclusive(int screen, WindowPeer w);
|
||||
|
||||
@Override
|
||||
public boolean isDisplayChangeSupported() {
|
||||
return (isFullScreenSupported() && getFullScreenWindow() != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void setDisplayMode(DisplayMode dm) {
|
||||
if (!isDisplayChangeSupported()) {
|
||||
super.setDisplayMode(dm);
|
||||
@ -501,22 +429,19 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
|
||||
}
|
||||
}
|
||||
|
||||
private native DisplayMode getCurrentDisplayMode(int screen);
|
||||
private native void configDisplayMode(int screen, WindowPeer w, int width,
|
||||
protected native DisplayMode getCurrentDisplayMode(int screen);
|
||||
protected native void configDisplayMode(int screen, WindowPeer w, int width,
|
||||
int height, int bitDepth,
|
||||
int refreshRate);
|
||||
private native void enumDisplayModes(int screen, ArrayList modes);
|
||||
// This function is only available if DirectDraw is enabled, otherwise we
|
||||
// have to do the work the hard way (enumerating all of the display modes
|
||||
// and checking each one)
|
||||
private native boolean isDisplayModeAvailable(int screen, int width, int height,
|
||||
int bitDepth, int refreshRate);
|
||||
protected native void enumDisplayModes(int screen, ArrayList modes);
|
||||
|
||||
@Override
|
||||
public synchronized DisplayMode getDisplayMode() {
|
||||
DisplayMode res = getCurrentDisplayMode(screen);
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized DisplayMode[] getDisplayModes() {
|
||||
ArrayList modes = new ArrayList();
|
||||
enumDisplayModes(screen, modes);
|
||||
@ -528,33 +453,22 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
|
||||
return retArray;
|
||||
}
|
||||
|
||||
private synchronized DisplayMode getMatchingDisplayMode(DisplayMode dm) {
|
||||
protected synchronized DisplayMode getMatchingDisplayMode(DisplayMode dm) {
|
||||
if (!isDisplayChangeSupported()) {
|
||||
return null;
|
||||
}
|
||||
if (isDDEnabledOnDevice()) {
|
||||
return
|
||||
isDisplayModeAvailable(screen, dm.getWidth(), dm.getHeight(),
|
||||
dm.getBitDepth(), dm.getRefreshRate())
|
||||
? dm : null;
|
||||
} else {
|
||||
// The function isDisplayModeAvailable is only available if
|
||||
// DirectDraw is enabled, otherwise we have to do the work the
|
||||
// hard way (enumerating all of the display modes
|
||||
// and checking each one)
|
||||
DisplayMode[] modes = getDisplayModes();
|
||||
for (DisplayMode mode : modes) {
|
||||
if (dm.equals(mode) ||
|
||||
(dm.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN &&
|
||||
dm.getWidth() == mode.getWidth() &&
|
||||
dm.getHeight() == mode.getHeight() &&
|
||||
dm.getBitDepth() == mode.getBitDepth()))
|
||||
{
|
||||
return mode;
|
||||
}
|
||||
DisplayMode[] modes = getDisplayModes();
|
||||
for (DisplayMode mode : modes) {
|
||||
if (dm.equals(mode) ||
|
||||
(dm.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN &&
|
||||
dm.getWidth() == mode.getWidth() &&
|
||||
dm.getHeight() == mode.getHeight() &&
|
||||
dm.getBitDepth() == mode.getBitDepth()))
|
||||
{
|
||||
return mode;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -563,7 +477,6 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
|
||||
* changed.
|
||||
*/
|
||||
public void displayChanged() {
|
||||
d3dContext = null;
|
||||
dynamicColorModel = null;
|
||||
defaultConfig = null;
|
||||
configs = null;
|
||||
@ -621,17 +534,93 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
|
||||
return colorModel;
|
||||
}
|
||||
|
||||
private native int getDeviceMemoryNative(int screen);
|
||||
/**
|
||||
* WindowAdapter class responsible for de/iconifying full-screen window
|
||||
* of this device.
|
||||
*
|
||||
* The listener restores the default display mode when window is iconified
|
||||
* and sets it back to the one set by the user on de-iconification.
|
||||
*/
|
||||
private static class Win32FSWindowAdapter extends WindowAdapter {
|
||||
private Win32GraphicsDevice device;
|
||||
private DisplayMode dm;
|
||||
|
||||
Win32FSWindowAdapter(Win32GraphicsDevice device) {
|
||||
this.device = device;
|
||||
}
|
||||
|
||||
private void setFSWindowsState(Window other, int state) {
|
||||
GraphicsDevice gds[] =
|
||||
GraphicsEnvironment.getLocalGraphicsEnvironment().
|
||||
getScreenDevices();
|
||||
// check if the de/activation was caused by other
|
||||
// fs window and ignore the event if that's the case
|
||||
if (other != null) {
|
||||
for (GraphicsDevice gd : gds) {
|
||||
if (other == gd.getFullScreenWindow()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// otherwise apply state to all fullscreen windows
|
||||
for (GraphicsDevice gd : gds) {
|
||||
Window fsw = gd.getFullScreenWindow();
|
||||
if (fsw instanceof Frame) {
|
||||
((Frame)fsw).setExtendedState(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowDeactivated(WindowEvent e) {
|
||||
setFSWindowsState(e.getOppositeWindow(), Frame.ICONIFIED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowActivated(WindowEvent e) {
|
||||
setFSWindowsState(e.getOppositeWindow(), Frame.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowIconified(WindowEvent e) {
|
||||
// restore the default display mode for this device
|
||||
DisplayMode ddm = device.defaultDisplayMode;
|
||||
if (ddm != null) {
|
||||
dm = device.getDisplayMode();
|
||||
device.setDisplayMode(ddm);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowDeiconified(WindowEvent e) {
|
||||
// restore the user-set display mode for this device
|
||||
if (dm != null) {
|
||||
device.setDisplayMode(dm);
|
||||
dm = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns number of bytes available in VRAM on this device.
|
||||
* Adds a WindowListener to be used as
|
||||
* activation/deactivation listener for the current full-screen window.
|
||||
*
|
||||
* @param w full-screen window
|
||||
*/
|
||||
public int getAvailableAcceleratedMemory() {
|
||||
if (getDefaultConfiguration() instanceof WGLGraphicsConfig) {
|
||||
// when OGL is enabled, there is no way to determine the amount
|
||||
// of accelerated memory, so just return the default value
|
||||
return super.getAvailableAcceleratedMemory();
|
||||
}
|
||||
return getDeviceMemoryNative(screen);
|
||||
protected void addFSWindowListener(Window w) {
|
||||
// Note: even though we create a listener for Window instances of
|
||||
// fs windows they will not receive window events.
|
||||
fsWindowListener = new Win32FSWindowAdapter(this);
|
||||
w.addWindowListener(fsWindowListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the fs window listener.
|
||||
*
|
||||
* @param w full-screen window
|
||||
*/
|
||||
protected void removeFSWindowListener(Window w) {
|
||||
w.removeWindowListener(fsWindowListener);
|
||||
fsWindowListener = null;
|
||||
}
|
||||
}
|
||||
|
@ -25,9 +25,11 @@
|
||||
|
||||
package sun.awt;
|
||||
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.peer.ComponentPeer;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
@ -44,6 +46,7 @@ import sun.font.FontManager;
|
||||
import sun.java2d.SunGraphicsEnvironment;
|
||||
import sun.java2d.SurfaceManagerFactory;
|
||||
import sun.java2d.WindowsSurfaceManagerFactory;
|
||||
import sun.java2d.d3d.D3DGraphicsDevice;
|
||||
import sun.java2d.windows.WindowsFlags;
|
||||
|
||||
/**
|
||||
@ -333,12 +336,21 @@ public class Win32GraphicsEnvironment
|
||||
protected static native void deRegisterFontWithPlatform(String fontName);
|
||||
|
||||
protected GraphicsDevice makeScreenDevice(int screennum) {
|
||||
return new Win32GraphicsDevice(screennum);
|
||||
GraphicsDevice device = null;
|
||||
if (WindowsFlags.isD3DEnabled()) {
|
||||
device = D3DGraphicsDevice.createDevice(screennum);
|
||||
}
|
||||
if (device == null) {
|
||||
device = new Win32GraphicsDevice(screennum);
|
||||
}
|
||||
return device;
|
||||
}
|
||||
|
||||
// Implements SunGraphicsEnvironment.createFontConfiguration.
|
||||
protected FontConfiguration createFontConfiguration() {
|
||||
return new WFontConfiguration(this);
|
||||
FontConfiguration fc = new WFontConfiguration(this);
|
||||
fc.init();
|
||||
return fc;
|
||||
}
|
||||
|
||||
public FontConfiguration createFontConfiguration(boolean preferLocaleFonts,
|
||||
@ -346,4 +358,39 @@ public class Win32GraphicsEnvironment
|
||||
|
||||
return new WFontConfiguration(this, preferLocaleFonts,preferPropFonts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFlipStrategyPreferred(ComponentPeer peer) {
|
||||
GraphicsConfiguration gc;
|
||||
if (peer != null && (gc = peer.getGraphicsConfiguration()) != null) {
|
||||
GraphicsDevice gd = gc.getDevice();
|
||||
if (gd instanceof D3DGraphicsDevice) {
|
||||
return ((D3DGraphicsDevice)gd).isD3DEnabledOnDevice();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static volatile boolean isDWMCompositionEnabled;
|
||||
/**
|
||||
* Returns true if dwm composition is currently enabled, false otherwise.
|
||||
*
|
||||
* @return true if dwm composition is enabled, false otherwise
|
||||
*/
|
||||
public static boolean isDWMCompositionEnabled() {
|
||||
return isDWMCompositionEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from the native code when DWM composition state changed.
|
||||
* May be called multiple times during the lifetime of the application.
|
||||
* REMIND: we may want to create a listener mechanism for this.
|
||||
*
|
||||
* Note: called on the Toolkit thread, no user code or locks are allowed.
|
||||
*
|
||||
* @param enabled indicates the state of dwm composition
|
||||
*/
|
||||
private static void dwmCompositionChanged(boolean enabled) {
|
||||
isDWMCompositionEnabled = enabled;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,8 +40,10 @@ import java.awt.event.InvocationEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import sun.awt.Win32GraphicsConfig;
|
||||
import sun.java2d.InvalidPipeException;
|
||||
import sun.java2d.SunGraphics2D;
|
||||
import sun.java2d.SurfaceData;
|
||||
import sun.java2d.d3d.D3DScreenUpdateManager;
|
||||
import static sun.java2d.d3d.D3DSurfaceData.*;
|
||||
import sun.java2d.ScreenUpdateManager;
|
||||
import sun.java2d.opengl.OGLSurfaceData;
|
||||
import sun.awt.DisplayChangedListener;
|
||||
import sun.awt.PaintEventDispatcher;
|
||||
@ -51,7 +53,6 @@ import java.awt.dnd.DropTarget;
|
||||
import java.awt.dnd.peer.DropTargetPeer;
|
||||
import sun.awt.ComponentAccessor;
|
||||
|
||||
import java.util.logging.*;
|
||||
|
||||
import java.util.logging.*;
|
||||
|
||||
@ -87,6 +88,7 @@ public abstract class WComponentPeer extends WObjectPeer
|
||||
int oldHeight = -1;
|
||||
private int numBackBuffers = 0;
|
||||
private VolatileImage backBuffer = null;
|
||||
private BufferCapabilities backBufferCaps = null;
|
||||
|
||||
// foreground, background and color are cached to avoid calling back
|
||||
// into the Component.
|
||||
@ -191,10 +193,12 @@ public abstract class WComponentPeer extends WObjectPeer
|
||||
cont.invalidate();
|
||||
cont.validate();
|
||||
|
||||
if (surfaceData instanceof OGLSurfaceData) {
|
||||
// 6290245: When OGL is enabled, it is necessary to
|
||||
if (surfaceData instanceof D3DWindowSurfaceData ||
|
||||
surfaceData instanceof OGLSurfaceData)
|
||||
{
|
||||
// When OGL or D3D is enabled, it is necessary to
|
||||
// replace the SurfaceData for each dynamic layout
|
||||
// request so that the OGL viewport stays in sync
|
||||
// request so that the viewport stays in sync
|
||||
// with the window bounds.
|
||||
try {
|
||||
replaceSurfaceData();
|
||||
@ -377,7 +381,7 @@ public abstract class WComponentPeer extends WObjectPeer
|
||||
* just call that version with our current numBackBuffers.
|
||||
*/
|
||||
public void replaceSurfaceData() {
|
||||
replaceSurfaceData(this.numBackBuffers);
|
||||
replaceSurfaceData(this.numBackBuffers, this.backBufferCaps);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -386,35 +390,51 @@ public abstract class WComponentPeer extends WObjectPeer
|
||||
* order, but also needs to perform additional functions inside the
|
||||
* locks.
|
||||
*/
|
||||
public void replaceSurfaceData(int newNumBackBuffers) {
|
||||
public void replaceSurfaceData(int newNumBackBuffers,
|
||||
BufferCapabilities caps)
|
||||
{
|
||||
SurfaceData oldData = null;
|
||||
VolatileImage oldBB = null;
|
||||
synchronized(((Component)target).getTreeLock()) {
|
||||
synchronized(this) {
|
||||
if (pData == 0) {
|
||||
return;
|
||||
}
|
||||
numBackBuffers = newNumBackBuffers;
|
||||
SurfaceData oldData = surfaceData;
|
||||
Win32GraphicsConfig gc =
|
||||
(Win32GraphicsConfig)getGraphicsConfiguration();
|
||||
surfaceData = gc.createSurfaceData(this, numBackBuffers);
|
||||
(Win32GraphicsConfig)getGraphicsConfiguration();
|
||||
ScreenUpdateManager mgr = ScreenUpdateManager.getInstance();
|
||||
oldData = surfaceData;
|
||||
mgr.dropScreenSurface(oldData);
|
||||
surfaceData =
|
||||
mgr.createScreenSurface(gc, this, numBackBuffers, true);
|
||||
if (oldData != null) {
|
||||
oldData.invalidate();
|
||||
// null out the old data to make it collected faster
|
||||
oldData = null;
|
||||
}
|
||||
|
||||
if (backBuffer != null) {
|
||||
// this will remove the back buffer from the
|
||||
// display change notification list
|
||||
backBuffer.flush();
|
||||
oldBB = backBuffer;
|
||||
if (numBackBuffers > 0) {
|
||||
// set the caps first, they're used when creating the bb
|
||||
backBufferCaps = caps;
|
||||
backBuffer = gc.createBackBuffer(this);
|
||||
} else if (backBuffer != null) {
|
||||
backBufferCaps = null;
|
||||
backBuffer = null;
|
||||
}
|
||||
|
||||
if (numBackBuffers > 0) {
|
||||
backBuffer = gc.createBackBuffer(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
// it would be better to do this before we create new ones,
|
||||
// but then we'd run into deadlock issues
|
||||
if (oldData != null) {
|
||||
oldData.flush();
|
||||
// null out the old data to make it collected faster
|
||||
oldData = null;
|
||||
}
|
||||
if (oldBB != null) {
|
||||
oldBB.flush();
|
||||
// null out the old data to make it collected faster
|
||||
oldData = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void replaceSurfaceDataLater() {
|
||||
@ -518,7 +538,10 @@ public abstract class WComponentPeer extends WObjectPeer
|
||||
if (font == null) {
|
||||
font = defaultFont;
|
||||
}
|
||||
return new SunGraphics2D(surfaceData, fgColor, bgColor, font);
|
||||
ScreenUpdateManager mgr =
|
||||
ScreenUpdateManager.getInstance();
|
||||
return mgr.createGraphics(surfaceData, this, fgColor,
|
||||
bgColor, font);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -530,6 +553,7 @@ public abstract class WComponentPeer extends WObjectPeer
|
||||
protected void disposeImpl() {
|
||||
SurfaceData oldData = surfaceData;
|
||||
surfaceData = null;
|
||||
ScreenUpdateManager.getInstance().dropScreenSurface(oldData);
|
||||
oldData.invalidate();
|
||||
// remove from updater before calling targetDisposedPeer
|
||||
WToolkit.targetDisposedPeer(target, this);
|
||||
@ -546,6 +570,16 @@ public abstract class WComponentPeer extends WObjectPeer
|
||||
_setBackground(c.getRGB());
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is intentionally not synchronized as it is called while
|
||||
* holding other locks.
|
||||
*
|
||||
* @see sun.java2d.d3d.D3DScreenUpdateManager#validate(D3DWindowSurfaceData)
|
||||
*/
|
||||
public Color getBackgroundNoSync() {
|
||||
return background;
|
||||
}
|
||||
|
||||
public native void _setForeground(int rgb);
|
||||
public native void _setBackground(int rgb);
|
||||
|
||||
@ -617,8 +651,9 @@ public abstract class WComponentPeer extends WObjectPeer
|
||||
checkCreation();
|
||||
this.winGraphicsConfig =
|
||||
(Win32GraphicsConfig)getGraphicsConfiguration();
|
||||
this.surfaceData =
|
||||
winGraphicsConfig.createSurfaceData(this, numBackBuffers);
|
||||
ScreenUpdateManager mgr = ScreenUpdateManager.getInstance();
|
||||
this.surfaceData = mgr.createScreenSurface(winGraphicsConfig, this,
|
||||
numBackBuffers, false);
|
||||
initialize();
|
||||
start(); // Initialize enable/disable state, turn on callbacks
|
||||
}
|
||||
@ -793,6 +828,7 @@ public abstract class WComponentPeer extends WObjectPeer
|
||||
* native windowing system specific actions.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void createBuffers(int numBuffers, BufferCapabilities caps)
|
||||
throws AWTException
|
||||
{
|
||||
@ -802,39 +838,44 @@ public abstract class WComponentPeer extends WObjectPeer
|
||||
|
||||
// Re-create the primary surface with the new number of back buffers
|
||||
try {
|
||||
replaceSurfaceData(numBuffers - 1);
|
||||
replaceSurfaceData(numBuffers - 1, caps);
|
||||
} catch (InvalidPipeException e) {
|
||||
throw new AWTException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void destroyBuffers() {
|
||||
disposeBackBuffer();
|
||||
numBackBuffers = 0;
|
||||
@Override
|
||||
public void destroyBuffers() {
|
||||
replaceSurfaceData(0, null);
|
||||
}
|
||||
|
||||
private synchronized void disposeBackBuffer() {
|
||||
if (backBuffer == null) {
|
||||
return;
|
||||
}
|
||||
backBuffer = null;
|
||||
}
|
||||
|
||||
public synchronized void flip(BufferCapabilities.FlipContents flipAction) {
|
||||
@Override
|
||||
public void flip(int x1, int y1, int x2, int y2,
|
||||
BufferCapabilities.FlipContents flipAction)
|
||||
{
|
||||
VolatileImage backBuffer = this.backBuffer;
|
||||
if (backBuffer == null) {
|
||||
throw new IllegalStateException("Buffers have not been created");
|
||||
}
|
||||
Win32GraphicsConfig gc =
|
||||
(Win32GraphicsConfig)getGraphicsConfiguration();
|
||||
gc.flip(this, (Component)target, backBuffer, flipAction);
|
||||
gc.flip(this, (Component)target, backBuffer, x1, y1, x2, y2, flipAction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Image getBackBuffer() {
|
||||
Image backBuffer = this.backBuffer;
|
||||
if (backBuffer == null) {
|
||||
throw new IllegalStateException("Buffers have not been created");
|
||||
}
|
||||
return backBuffer;
|
||||
}
|
||||
public BufferCapabilities getBackBufferCaps() {
|
||||
return backBufferCaps;
|
||||
}
|
||||
public int getBackBuffersNum() {
|
||||
return numBackBuffers;
|
||||
}
|
||||
|
||||
/* override and return false on components that DO NOT require
|
||||
a clearRect() before painting (i.e. native components) */
|
||||
@ -866,6 +907,51 @@ public abstract class WComponentPeer extends WObjectPeer
|
||||
sun.java2d.pipe.Region region);
|
||||
|
||||
|
||||
// REMIND: Temp workaround for issues with using HW acceleration
|
||||
// in the browser on Vista when DWM is enabled.
|
||||
// @return true if the toplevel container is not an EmbeddedFrame or
|
||||
// if this EmbeddedFrame is acceleration capable, false otherwise
|
||||
private static final boolean isContainingTopLevelAccelCapable(Component c) {
|
||||
while (c != null && !(c instanceof WEmbeddedFrame)) {
|
||||
c = c.getParent();
|
||||
}
|
||||
if (c == null) {
|
||||
return true;
|
||||
}
|
||||
return ((WEmbeddedFramePeer)c.getPeer()).isAccelCapable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this component is capable of being hw accelerated.
|
||||
* More specifically, whether rendering to this component or a
|
||||
* BufferStrategy's back-buffer for this component can be hw accelerated.
|
||||
*
|
||||
* Conditions which could prevent hw acceleration include the toplevel
|
||||
* window containing this component being
|
||||
* {@link com.sun.awt.AWTUtilities.Translucency#TRANSLUCENT TRANSLUCENT}.
|
||||
*
|
||||
* @return {@code true} if this component is capable of being hw
|
||||
* accelerated, {@code false} otherwise
|
||||
* @see com.sun.awt.AWTUtilities.Translucency#TRANSLUCENT
|
||||
*/
|
||||
public boolean isAccelCapable() {
|
||||
// REMIND: Temp workaround for issues with using HW acceleration
|
||||
// in the browser on Vista when DWM is enabled
|
||||
if (!isContainingTopLevelAccelCapable((Component)target)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// REMIND: translucent windows support-related
|
||||
/*
|
||||
boolean isTranslucent =
|
||||
SunToolkit.isContainingTopLevelTranslucent((Component)target);
|
||||
// D3D/OGL and translucent windows interacted poorly in Windows XP;
|
||||
// these problems are no longer present in Vista
|
||||
return !isTranslucent || Win32GraphicsEnvironment.isVistaOS();
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the shape to the native component window.
|
||||
* @since 1.7
|
||||
|
@ -30,6 +30,7 @@ import java.awt.Graphics;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import sun.awt.EmbeddedFrame;
|
||||
import sun.awt.Win32GraphicsEnvironment;
|
||||
|
||||
public class WEmbeddedFramePeer extends WFramePeer {
|
||||
|
||||
@ -71,4 +72,13 @@ public class WEmbeddedFramePeer extends WFramePeer {
|
||||
// We don't constrain the bounds of the EmbeddedFrames
|
||||
return new Rectangle(x, y, width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccelCapable() {
|
||||
// REMIND: Temp workaround for issues with using HW acceleration
|
||||
// in the browser on Vista when DWM is enabled
|
||||
// Note: isDWMCompositionEnabled is only relevant on Vista, returns
|
||||
// false on other systems.
|
||||
return !Win32GraphicsEnvironment.isDWMCompositionEnabled();
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user