Index: build.xml =================================================================== --- build.xml (revision 479675) +++ build.xml (working copy) @@ -162,6 +162,13 @@ + + + + + + + @@ -208,6 +215,8 @@ target="clean"/> + Index: src/main/java/common/org/apache/harmony/awt/gl/opengl/OGLContextManager.java =================================================================== --- src/main/java/common/org/apache/harmony/awt/gl/opengl/OGLContextManager.java (revision 479675) +++ src/main/java/common/org/apache/harmony/awt/gl/opengl/OGLContextManager.java (working copy) @@ -20,24 +20,102 @@ */ package org.apache.harmony.awt.gl.opengl; +import java.util.ArrayList; + public interface OGLContextManager { public static class OffscreenBufferObject { + private static final int MAX_CACHED_BUFFERS = 10; + private static final ArrayList availableBuffers = new ArrayList(); + public final long id; public final int width; public final int height; + public final OGLContextManager config; + public final long hdc; - public OffscreenBufferObject(long id, int width, int height) { + public OffscreenBufferObject(long id, long hdc, int width, int height, OGLContextManager config) { this.id = id; + this.hdc = hdc; this.width = width; this.height = height; + this.config = config; } + + public static final OffscreenBufferObject getCachedBuffer(int w, int h, OGLContextManager config) { + for (int i = 0; i < availableBuffers.size(); i++) { // First try to find cached pbuffer + OffscreenBufferObject pbuffer = (OffscreenBufferObject) availableBuffers.get(i); + if (pbuffer.width >= w && pbuffer.height >= h && pbuffer.config == config) { + availableBuffers.remove(i); + return pbuffer; + } + } + + return null; + } + + public static final OffscreenBufferObject freeCachedBuffer(OffscreenBufferObject pbuffer) { + if (availableBuffers.size() <= MAX_CACHED_BUFFERS) { + availableBuffers.add(pbuffer); + return null; + } + + // Try to find smaller pbuffer in the cache and replace it + for (int i=0; i 0) { - defaultConfig = new WinGraphicsConfiguration(this, dci, pfd); + defaultConfig = useOpenGL ? + new WGLGraphicsConfiguration(this, dci, pfd): + new WinGraphicsConfiguration(this, dci, pfd); } else { getConfigurations(); } @@ -138,7 +146,9 @@ Vector gcv = new Vector(100); int i = 1; while (win32.DescribePixelFormat(hdc, i, pfd.size(), pfd) > 0) { - WinGraphicsConfiguration gc = new WinGraphicsConfiguration(this, i, pfd); + WinGraphicsConfiguration gc = useOpenGL ? + new WGLGraphicsConfiguration(this, i, pfd): + new WinGraphicsConfiguration(this, i, pfd); if (!gcv.contains(gc)) { gcv.add(gc); Index: src/main/java/windows/org/apache/harmony/awt/wtk/windows/WindowProcHandler.java =================================================================== --- src/main/java/windows/org/apache/harmony/awt/wtk/windows/WindowProcHandler.java (revision 479675) +++ src/main/java/windows/org/apache/harmony/awt/wtk/windows/WindowProcHandler.java (working copy) @@ -89,4 +89,9 @@ className, winError)); } } + + public static void registerWindowClass(String className) { + registerCallback(); + registerWindowClass(className, instance.windowProcPtr); + } } \ No newline at end of file Index: src/main/native/gl/linux/libgl.exp =================================================================== --- src/main/native/gl/linux/libgl.exp (revision 479675) +++ src/main/native/gl/linux/libgl.exp (working copy) @@ -16,6 +16,7 @@ Java_org_apache_harmony_awt_gl_render_NativeImageBlitter_bltBG; Java_org_apache_harmony_awt_gl_render_NativeImageBlitter_blt; Java_org_apache_harmony_awt_gl_render_NativeImageBlitter_xor; + Java_org_apache_harmony_awt_gl_ImageSurface_updateCache; Java_org_apache_harmony_awt_gl_Surface_initIDs; local : *; }; Index: src/main/native/win32wrapper/windows/makefile =================================================================== --- src/main/native/win32wrapper/windows/makefile (revision 479675) +++ src/main/native/win32wrapper/windows/makefile (working copy) @@ -30,8 +30,10 @@ BUILDFILES = \ Callback.obj \ org_apache_harmony_awt_nativebridge_windows_Win32.obj \ + org_apache_harmony_awt_nativebridge_windows_WGL.obj \ WinDataTransfer.obj \ - WinManagement.obj + WinManagement.obj \ + nativelib_common.obj VIRTFILES = $(LIBBASE).res SYSLIBFILES = ws2_32.lib Iphlpapi.lib Index: src/main/native/win32wrapper/windows/nativelib_common.h =================================================================== --- src/main/native/win32wrapper/windows/nativelib_common.h (revision 479675) +++ src/main/native/win32wrapper/windows/nativelib_common.h (working copy) @@ -33,6 +33,8 @@ #define FindFunction(lib, name) dlsym(lib, name) +#define INIT_GL_GET_PROC_ADDRESS + #ifndef __INTEL_COMPILER typedef long long __int64; #endif @@ -60,8 +62,14 @@ #define LOAD_LIB(res, name) res = ::LoadLibraryA(name) -#define FindFunction(lib, name) (void *)::GetProcAddress(lib, name) +extern void * (__stdcall * p_nbridge_wglGetProcAddress) (void *); +#undef FindFunction +extern void *findFunctionRes; +#define FindFunction(lib, name) ((findFunctionRes = (void *)::GetProcAddress(lib, name)) ? findFunctionRes : (*p_nbridge_wglGetProcAddress)(name)) + +#define INIT_GL_GET_PROC_ADDRESS p_nbridge_wglGetProcAddress = (void * (__stdcall *) (void *)) ::GetProcAddress(libOpenGL32, "wglGetProcAddress"); + // END common windows section-------------------------- #ifdef _WIN32 // ia32 windows section--------------------------------