< prev index next >

src/java.desktop/windows/native/libawt/java2d/d3d/D3DContext.cpp

Print this page


   1 /*
   2  * Copyright (c) 2007, 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 #include "D3DPipeline.h"
  27 #include "jlong.h"
  28 
  29 #include "GraphicsPrimitiveMgr.h"
  30 #include "D3DContext.h"
  31 #include "D3DSurfaceData.h"
  32 #include "D3DBufImgOps.h"
  33 #include "D3DPaints.h"
  34 #include "D3DRenderQueue.h"
  35 #include "D3DShaders.h"
  36 #include "D3DTextRenderer.h"
  37 #include "D3DPipelineManager.h"
  38 #include "D3DGlyphCache.h"

  39 
  40 typedef struct {
  41     D3DBLEND src;
  42     D3DBLEND dst;
  43 } D3DBlendRule;
  44 
  45 /**
  46  * This table contains the standard blending rules (or Porter-Duff compositing
  47  * factors) used in SetRenderState(), indexed by the rule constants from the
  48  * AlphaComposite class.
  49  */
  50 D3DBlendRule StdBlendRules[] = {
  51     { D3DBLEND_ZERO,         D3DBLEND_ZERO        }, /* 0 - Nothing      */
  52     { D3DBLEND_ZERO,         D3DBLEND_ZERO        }, /* 1 - RULE_Clear   */
  53     { D3DBLEND_ONE,          D3DBLEND_ZERO        }, /* 2 - RULE_Src     */
  54     { D3DBLEND_ONE,          D3DBLEND_INVSRCALPHA }, /* 3 - RULE_SrcOver */
  55     { D3DBLEND_INVDESTALPHA, D3DBLEND_ONE         }, /* 4 - RULE_DstOver */
  56     { D3DBLEND_DESTALPHA,    D3DBLEND_ZERO        }, /* 5 - RULE_SrcIn   */
  57     { D3DBLEND_ZERO,         D3DBLEND_SRCALPHA    }, /* 6 - RULE_DstIn   */
  58     { D3DBLEND_INVDESTALPHA, D3DBLEND_ZERO        }, /* 7 - RULE_SrcOut  */


 236     pLCDGlyphCache= NULL;
 237     pGrayscaleGlyphCache= NULL;
 238     lcdTextProgram = NULL;
 239     aaPgramProgram = NULL;
 240 
 241     contextCaps = CAPS_EMPTY;
 242     bBeginScenePending = FALSE;
 243 
 244     ZeroMemory(&devCaps, sizeof(D3DCAPS9));
 245     ZeroMemory(&curParams, sizeof(curParams));
 246 
 247     extraAlpha = 1.0f;
 248 }
 249 
 250 void D3DContext::ReleaseDefPoolResources()
 251 {
 252     J2dTraceLn(J2D_TRACE_INFO, "D3DContext::ReleaseDefPoolResources");
 253 
 254     EndScene();
 255 
 256     D3DPipelineManager::NotifyAdapterEventListeners(devCaps.AdapterOrdinal,
 257                                                     DEVICE_RESET);
 258 
 259     contextCaps = CAPS_EMPTY;
 260 
 261     SAFE_RELEASE(pSyncQuery);
 262     SAFE_RELEASE(pStateBlock);
 263 
 264     if (pVCacher != NULL) {
 265         pVCacher->ReleaseDefPoolResources();
 266     }
 267     if (pMaskCache != NULL) {
 268         pMaskCache->ReleaseDefPoolResources();
 269     }
 270     if (pLCDGlyphCache != NULL) {
 271         pLCDGlyphCache->ReleaseDefPoolResources();
 272     }
 273     if (pGrayscaleGlyphCache != NULL) {
 274         pGrayscaleGlyphCache->ReleaseDefPoolResources();
 275     }
 276     if (pResourceMgr != NULL) {
 277         if (pSyncRTRes != NULL) {
 278             pResourceMgr->ReleaseResource(pSyncRTRes);
 279             pSyncRTRes = NULL;
 280         }
 281         pResourceMgr->ReleaseDefPoolResources();
 282     }
 283     ZeroMemory(lastTexture, sizeof(lastTexture));
 284     ZeroMemory(lastTextureColorState, sizeof(lastTextureColorState));
 285 }
 286 
 287 void D3DContext::ReleaseContextResources()
 288 {
 289     J2dTraceLn1(J2D_TRACE_INFO,
 290                 "D3DContext::ReleaseContextResources: pd3dDevice = 0x%x",
 291                 pd3dDevice);
 292 
 293     ReleaseDefPoolResources();
 294 
 295     D3DPipelineManager::NotifyAdapterEventListeners(devCaps.AdapterOrdinal,
 296                                                     DEVICE_DISPOSED);
 297 
 298     // dispose shader lists
 299     ShaderList_Dispose(&convolvePrograms);
 300     ShaderList_Dispose(&rescalePrograms);
 301     ShaderList_Dispose(&lookupPrograms);
 302     ShaderList_Dispose(&basicGradPrograms);
 303     ShaderList_Dispose(&linearGradPrograms);
 304     ShaderList_Dispose(&radialGradPrograms);
 305 
 306     SAFE_DELETE(pLCDGlyphCache);
 307     SAFE_DELETE(pGrayscaleGlyphCache);
 308 
 309     SAFE_RELEASE(lcdTextProgram);
 310     SAFE_RELEASE(aaPgramProgram);
 311 
 312     SAFE_DELETE(pVCacher);
 313     SAFE_DELETE(pMaskCache);
 314     SAFE_DELETE(pResourceMgr);
 315 }
 316 


   1 /*
   2  * Copyright (c) 2007, 2016, 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 #include "D3DPipeline.h"
  27 #include "jlong.h"
  28 
  29 #include "GraphicsPrimitiveMgr.h"
  30 #include "D3DContext.h"
  31 #include "D3DSurfaceData.h"
  32 #include "D3DBufImgOps.h"
  33 #include "D3DPaints.h"
  34 #include "D3DRenderQueue.h"
  35 #include "D3DShaders.h"
  36 #include "D3DTextRenderer.h"
  37 #include "D3DPipelineManager.h"
  38 #include "D3DGlyphCache.h"
  39 #include "Devices.h"
  40 
  41 typedef struct {
  42     D3DBLEND src;
  43     D3DBLEND dst;
  44 } D3DBlendRule;
  45 
  46 /**
  47  * This table contains the standard blending rules (or Porter-Duff compositing
  48  * factors) used in SetRenderState(), indexed by the rule constants from the
  49  * AlphaComposite class.
  50  */
  51 D3DBlendRule StdBlendRules[] = {
  52     { D3DBLEND_ZERO,         D3DBLEND_ZERO        }, /* 0 - Nothing      */
  53     { D3DBLEND_ZERO,         D3DBLEND_ZERO        }, /* 1 - RULE_Clear   */
  54     { D3DBLEND_ONE,          D3DBLEND_ZERO        }, /* 2 - RULE_Src     */
  55     { D3DBLEND_ONE,          D3DBLEND_INVSRCALPHA }, /* 3 - RULE_SrcOver */
  56     { D3DBLEND_INVDESTALPHA, D3DBLEND_ONE         }, /* 4 - RULE_DstOver */
  57     { D3DBLEND_DESTALPHA,    D3DBLEND_ZERO        }, /* 5 - RULE_SrcIn   */
  58     { D3DBLEND_ZERO,         D3DBLEND_SRCALPHA    }, /* 6 - RULE_DstIn   */
  59     { D3DBLEND_INVDESTALPHA, D3DBLEND_ZERO        }, /* 7 - RULE_SrcOut  */


 237     pLCDGlyphCache= NULL;
 238     pGrayscaleGlyphCache= NULL;
 239     lcdTextProgram = NULL;
 240     aaPgramProgram = NULL;
 241 
 242     contextCaps = CAPS_EMPTY;
 243     bBeginScenePending = FALSE;
 244 
 245     ZeroMemory(&devCaps, sizeof(D3DCAPS9));
 246     ZeroMemory(&curParams, sizeof(curParams));
 247 
 248     extraAlpha = 1.0f;
 249 }
 250 
 251 void D3DContext::ReleaseDefPoolResources()
 252 {
 253     J2dTraceLn(J2D_TRACE_INFO, "D3DContext::ReleaseDefPoolResources");
 254 
 255     EndScene();
 256 



 257     contextCaps = CAPS_EMPTY;
 258 
 259     SAFE_RELEASE(pSyncQuery);
 260     SAFE_RELEASE(pStateBlock);
 261 
 262     if (pVCacher != NULL) {
 263         pVCacher->ReleaseDefPoolResources();
 264     }
 265     if (pMaskCache != NULL) {
 266         pMaskCache->ReleaseDefPoolResources();
 267     }
 268     if (pLCDGlyphCache != NULL) {
 269         pLCDGlyphCache->ReleaseDefPoolResources();
 270     }
 271     if (pGrayscaleGlyphCache != NULL) {
 272         pGrayscaleGlyphCache->ReleaseDefPoolResources();
 273     }
 274     if (pResourceMgr != NULL) {
 275         if (pSyncRTRes != NULL) {
 276             pResourceMgr->ReleaseResource(pSyncRTRes);
 277             pSyncRTRes = NULL;
 278         }
 279         pResourceMgr->ReleaseDefPoolResources();
 280     }
 281     ZeroMemory(lastTexture, sizeof(lastTexture));
 282     ZeroMemory(lastTextureColorState, sizeof(lastTextureColorState));
 283 }
 284 
 285 void D3DContext::ReleaseContextResources()
 286 {
 287     J2dTraceLn1(J2D_TRACE_INFO,
 288                 "D3DContext::ReleaseContextResources: pd3dDevice = 0x%x",
 289                 pd3dDevice);
 290 
 291     ReleaseDefPoolResources();



 292 
 293     // dispose shader lists
 294     ShaderList_Dispose(&convolvePrograms);
 295     ShaderList_Dispose(&rescalePrograms);
 296     ShaderList_Dispose(&lookupPrograms);
 297     ShaderList_Dispose(&basicGradPrograms);
 298     ShaderList_Dispose(&linearGradPrograms);
 299     ShaderList_Dispose(&radialGradPrograms);
 300 
 301     SAFE_DELETE(pLCDGlyphCache);
 302     SAFE_DELETE(pGrayscaleGlyphCache);
 303 
 304     SAFE_RELEASE(lcdTextProgram);
 305     SAFE_RELEASE(aaPgramProgram);
 306 
 307     SAFE_DELETE(pVCacher);
 308     SAFE_DELETE(pMaskCache);
 309     SAFE_DELETE(pResourceMgr);
 310 }
 311 


< prev index next >