diff --git a/jdk/src/windows/native/sun/java2d/d3d/D3DBlitLoops.cpp b/jdk/src/windows/native/sun/java2d/d3d/D3DBlitLoops.cpp index f632d195b72..c8a5d786144 100644 --- a/jdk/src/windows/native/sun/java2d/d3d/D3DBlitLoops.cpp +++ b/jdk/src/windows/native/sun/java2d/d3d/D3DBlitLoops.cpp @@ -221,12 +221,17 @@ D3DBL_CopyImageToIntXrgbSurface(SurfaceDataRasInfo *pSrcInfo, " srctype=%d rect={%-4d, %-4d, %-4d, %-4d}", srctype, r.left, r.top, r.right, r.bottom); - if (pDesc->Usage == D3DUSAGE_DYNAMIC && - dstx == 0 && dstx == 0 && - srcWidth == pDesc->Width && srcHeight == pDesc->Height) - { + if (pDesc->Usage == D3DUSAGE_DYNAMIC) { + // it is safe to lock with discard because we don't care about the + // contents of dynamic textures, and some drivers are happier if + // dynamic textures are always locked with DISCARD dwLockFlags |= D3DLOCK_DISCARD; pR = NULL; + } else { + // in non-DYNAMIC case we lock the exact rect so there's no need to + // offset the destination pointer + dstx = 0; + dsty = 0; } res = pDstSurface->LockRect(&lockedRect, pR, dwLockFlags); @@ -243,7 +248,9 @@ D3DBL_CopyImageToIntXrgbSurface(SurfaceDataRasInfo *pSrcInfo, void *pSrcBase = PtrCoord(pSrcInfo->rasBase, srcx, pSrcInfo->pixelStride, srcy, pSrcInfo->scanStride); - void *pDstBase = lockedRect.pBits; + void *pDstBase = PtrCoord(lockedRect.pBits, + dstx, dstInfo.pixelStride, + dsty, dstInfo.scanStride); switch (srctype) { case ST_INT_ARGB: diff --git a/jdk/src/windows/native/sun/java2d/d3d/D3DContext.cpp b/jdk/src/windows/native/sun/java2d/d3d/D3DContext.cpp index e3937b8d3e9..186f4d7557c 100644 --- a/jdk/src/windows/native/sun/java2d/d3d/D3DContext.cpp +++ b/jdk/src/windows/native/sun/java2d/d3d/D3DContext.cpp @@ -1174,11 +1174,10 @@ D3DContext::UploadTileToTexture(D3DResource *pTextureRes, void *pixels, " rect={%-4d, %-4d, %-4d, %-4d}", r.left, r.top, r.right, r.bottom); - // REMIND: we should also check for dstx, dsty being 0 here, - // but they're always 0 in dynamic texture case - if (pDesc->Usage == D3DUSAGE_DYNAMIC && - srcWidth == pDesc->Width && srcHeight == pDesc->Height) - { + if (pDesc->Usage == D3DUSAGE_DYNAMIC) { + // it is safe to lock with discard because we don't care about the + // contents of dynamic textures and dstx,dsty for this case is + // always 0,0 because we are uploading into a tile texture dwLockFlags |= D3DLOCK_DISCARD; pR = NULL; }