src/java.desktop/windows/native/libawt/java2d/d3d/D3DContext.cpp
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 47216 71c04702a3d5
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
     1 /*
     1 /*
     2  * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   683         }
   683         }
   684     }
   684     }
   685     return res;
   685     return res;
   686 }
   686 }
   687 
   687 
   688 HRESULT
       
   689 D3DContext::SaveState()
       
   690 {
       
   691     HRESULT res;
       
   692 
       
   693     RETURN_STATUS_IF_NULL(pd3dDevice, S_OK);
       
   694 
       
   695     J2dTraceLn(J2D_TRACE_INFO, "D3DContext::SaveState");
       
   696 
       
   697     FlushVertexQueue();
       
   698     UpdateState(STATE_CHANGE);
       
   699 
       
   700     if (pStateBlock != NULL) {
       
   701         J2dTraceLn(J2D_TRACE_WARNING,
       
   702                    "D3DContext::SaveState: existing state block!");
       
   703         SAFE_RELEASE(pStateBlock);
       
   704     }
       
   705 
       
   706     if (SUCCEEDED(res =
       
   707             pd3dDevice->CreateStateBlock(D3DSBT_ALL, &pStateBlock)))
       
   708     {
       
   709         J2dTraceLn(J2D_TRACE_VERBOSE, "  created state block");
       
   710     } else {
       
   711         J2dTraceLn(J2D_TRACE_WARNING,
       
   712                    "D3DContext::SaveState: failed to create state block");
       
   713     }
       
   714     ZeroMemory(lastTexture, sizeof(lastTexture));
       
   715 
       
   716     return res;
       
   717 }
       
   718 
       
   719 HRESULT
       
   720 D3DContext::RestoreState()
       
   721 {
       
   722     HRESULT res = S_OK;
       
   723 
       
   724     J2dTraceLn(J2D_TRACE_INFO, "D3DContext::RestoreState");
       
   725 
       
   726     FlushVertexQueue();
       
   727     UpdateState(STATE_CHANGE);
       
   728 
       
   729     if (pStateBlock != NULL) {
       
   730         if (SUCCEEDED(res = pStateBlock->Apply())) {
       
   731             J2dTraceLn(J2D_TRACE_VERBOSE, "  restored device state");
       
   732         } else {
       
   733             J2dTraceLn(J2D_TRACE_WARNING,
       
   734                        "D3DContext::RestoreState: failed to restore state");
       
   735         }
       
   736         SAFE_RELEASE(pStateBlock);
       
   737     } else {
       
   738         J2dTraceLn(J2D_TRACE_WARNING,
       
   739                    "D3DContext::RestoreState: empty state block!");
       
   740     }
       
   741     ZeroMemory(lastTexture, sizeof(lastTexture));
       
   742 
       
   743     return res;
       
   744 }
       
   745 
       
   746 #define POINT_FILTER_CAP (D3DPTFILTERCAPS_MAGFPOINT|D3DPTFILTERCAPS_MINFPOINT)
   688 #define POINT_FILTER_CAP (D3DPTFILTERCAPS_MAGFPOINT|D3DPTFILTERCAPS_MINFPOINT)
   747 #define LINEAR_FILTER_CAP (D3DPTFILTERCAPS_MAGFLINEAR|D3DPTFILTERCAPS_MINFLINEAR)
   689 #define LINEAR_FILTER_CAP (D3DPTFILTERCAPS_MAGFLINEAR|D3DPTFILTERCAPS_MINFLINEAR)
   748 
   690 
   749 BOOL
   691 BOOL
   750 D3DContext::IsStretchRectFilteringSupported(D3DTEXTUREFILTERTYPE fType)
   692 D3DContext::IsStretchRectFilteringSupported(D3DTEXTUREFILTERTYPE fType)
  1148                                 jint *pPixelsTouchedL,
  1090                                 jint *pPixelsTouchedL,
  1149                                 jint* pPixelsTouchedR)
  1091                                 jint* pPixelsTouchedR)
  1150 {
  1092 {
  1151 #ifndef PtrAddBytes
  1093 #ifndef PtrAddBytes
  1152 #define PtrAddBytes(p, b)               ((void *) (((intptr_t) (p)) + (b)))
  1094 #define PtrAddBytes(p, b)               ((void *) (((intptr_t) (p)) + (b)))
  1153 #define PtrCoord(p, x, xinc, y, yinc)   PtrAddBytes(p, (y)*(yinc) + (x)*(xinc))
  1095 #define PtrCoord(p, x, xinc, y, yinc)   PtrAddBytes(p, \
       
  1096                                                     ((ptrdiff_t)(y))*(yinc) + \
       
  1097                                                     ((ptrdiff_t)(x))*(xinc))
  1154 #endif // PtrAddBytes
  1098 #endif // PtrAddBytes
  1155 
  1099 
  1156     HRESULT res = S_OK;
  1100     HRESULT res = S_OK;
  1157     IDirect3DTexture9 *pTexture = pTextureRes->GetTexture();
  1101     IDirect3DTexture9 *pTexture = pTextureRes->GetTexture();
  1158     D3DSURFACE_DESC *pDesc = pTextureRes->GetDesc();
  1102     D3DSURFACE_DESC *pDesc = pTextureRes->GetDesc();