1 /* 2 * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 #ifndef AWT_WIN32GRAPHICSDEVICE_H 27 #define AWT_WIN32GRAPHICSDEVICE_H 28 29 #include "awt.h" 30 extern "C" { 31 #include "img_globals.h" 32 } // extern "C" 33 #include "colordata.h" 34 #include "awt_Palette.h" 35 #include "Devices.h" 36 37 class AwtPalette; 38 class Devices; 39 40 class AwtWin32GraphicsDevice { 41 public: 42 AwtWin32GraphicsDevice(int screen, HMONITOR mhnd, Devices *arr); 43 ~AwtWin32GraphicsDevice(); 44 void UpdateDeviceColorState(); 45 void SetGrayness(int grayValue); 46 int GetGrayness() { return colorData->grayscale; } 47 HDC GetDC(); 48 void ReleaseDC(HDC hDC); 49 jobject GetColorModel(JNIEnv *env, 50 jboolean useDeviceSettings); 51 void Initialize(); 52 void UpdateDynamicColorModel(); 53 BOOL UpdateSystemPalette(); 54 unsigned int *GetSystemPaletteEntries(); 55 unsigned char *GetSystemInverseLUT(); 56 void SetJavaDevice(JNIEnv *env, jobject objPtr); 57 HPALETTE SelectPalette(HDC hDC); 58 void RealizePalette(HDC hDC); 59 HPALETTE GetPalette(); 60 ColorData *GetColorData() { return cData; } 61 int GetBitDepth() { return colorData->bitsperpixel; } 62 HMONITOR GetMonitor() { return monitor; } 63 LPMONITORINFO GetMonitorInfo() { return pMonitorInfo; } 64 jobject GetJavaDevice() { return javaDevice; } 65 int GetDeviceIndex() { return screen; } 66 void Release(); 67 void DisableOffscreenAcceleration(); 68 void Invalidate(JNIEnv *env); 69 void InitDesktopScales(); 70 void SetScale(float scaleX, float scaleY); 71 float GetScaleX(); 72 float GetScaleY(); 73 int ScaleUpX(int x); 74 int ScaleUpY(int y); 75 int ScaleDownX(int x); 76 int ScaleDownY(int y); 77 78 static int DeviceIndexForWindow(HWND hWnd); 79 static jobject GetColorModel(JNIEnv *env, jboolean dynamic, 80 int deviceIndex); 81 static HPALETTE SelectPalette(HDC hDC, int deviceIndex); 82 static void RealizePalette(HDC hDC, int deviceIndex); 83 static ColorData *GetColorData(int deviceIndex); 84 static int GetGrayness(int deviceIndex); 85 static void UpdateDynamicColorModel(int deviceIndex); 86 static BOOL UpdateSystemPalette(int deviceIndex); 87 static HPALETTE GetPalette(int deviceIndex); 88 static HMONITOR GetMonitor(int deviceIndex); 89 static LPMONITORINFO GetMonitorInfo(int deviceIndex); 90 static void ResetAllMonitorInfo(); 91 static BOOL IsPrimaryPalettized() { return primaryPalettized; } 92 static int GetDefaultDeviceIndex() { return primaryIndex; } 93 static void DisableOffscreenAccelerationForDevice(HMONITOR hMonitor); 94 static HDC GetDCFromScreen(int screen); 95 static int GetScreenFromHMONITOR(HMONITOR mon); 96 97 static int primaryIndex; 98 static BOOL primaryPalettized; 99 static jclass indexCMClass; 100 static jclass wToolkitClass; 101 static jfieldID dynamicColorModelID; 102 static jfieldID indexCMrgbID; 103 static jfieldID indexCMcacheID; 104 static jmethodID paletteChangedMID; 105 106 private: 107 static BOOL AreSameMonitors(HMONITOR mon1, HMONITOR mon2); 108 ImgColorData *colorData; 109 AwtPalette *palette; 110 ColorData *cData; // Could be static, but may sometime 111 // have per-device info in this structure 112 BITMAPINFO *gpBitmapInfo; 113 int screen; 114 HMONITOR monitor; 115 LPMONITORINFO pMonitorInfo; 116 jobject javaDevice; 117 Devices *devicesArray; 118 float scaleX; 119 float scaleY; 120 121 static HDC MakeDCFromMonitor(HMONITOR); 122 }; 123 124 #endif AWT_WIN32GRAPHICSDEVICE_H