8263486: Clean up MTLSurfaceDataBase.h

Reviewed-by: serb
This commit is contained in:
Ajit Ghaisas 2021-05-22 03:16:17 +00:00
parent fe333431c8
commit 72c9567b46
6 changed files with 24 additions and 79 deletions

View File

@ -701,9 +701,6 @@ MTLBlitLoops_SurfaceToSwBlit(JNIEnv *env, MTLContext *mtlc,
pDst = PtrPixelsRow(pDst, dstx, dstInfo.pixelStride);
pDst = PtrPixelsRow(pDst, dsty, dstInfo.scanStride);
// Metal texture is (0,0) at left-top
srcx = srcOps->xOffset + srcx;
srcy = srcOps->yOffset + srcy;
NSUInteger byteLength = w * h * 4; // NOTE: assume that src format is MTLPixelFormatBGRA8Unorm
// Create MTLBuffer (or use static)

View File

@ -265,13 +265,13 @@ static void setBlendingFactors(
* The MTLBlendRule structure encapsulates the two enumerated values that
* comprise a given Porter-Duff blending (compositing) rule. For example,
* the "SrcOver" rule can be represented by:
* rule.src = GL_ONE;
* rule.dst = GL_ONE_MINUS_SRC_ALPHA;
* rule.src = MTLBlendFactorZero;
* rule.dst = MTLBlendFactorOneMinusSourceAlpha;
*
* GLenum src;
* MTLBlendFactor src;
* The constant representing the source factor in this Porter-Duff rule.
*
* GLenum dst;
* MTLBlendFactor dst;
* The constant representing the destination factor in this Porter-Duff rule.
*/
struct MTLBlendRule {

View File

@ -46,10 +46,6 @@ static BMTLSDOps *dstOps = NULL;
jint mtlPreviousOp = MTL_OP_INIT;
/**
* The following methods are implemented in the windowing system (i.e. GLX
* and WGL) source files.
*/
extern void MTLGC_DestroyMTLGraphicsConfig(jlong pConfigInfo);
void MTLRenderQueue_CheckPreviousOp(jint op) {

View File

@ -28,20 +28,11 @@
#import "sun_java2d_metal_MTLSurfaceData.h"
#import "jni_util.h"
#import "MTLRenderQueue.h"
#import "MTLGraphicsConfig.h"
#import "MTLSurfaceData.h"
#import "ThreadUtilities.h"
#include "jlong.h"
/**
* The following methods are implemented in the windowing system (i.e. GLX
* and WGL) source files.
*/
extern jlong MTLSD_GetNativeConfigInfo(BMTLSDOps *bmtlsdo);
extern jboolean MTLSD_InitMTLWindow(JNIEnv *env, BMTLSDOps *bmtlsdo);
extern void MTLSD_DestroyMTLSurface(JNIEnv *env, BMTLSDOps *bmtlsdo);
jboolean MTLSD_InitMTLWindow(JNIEnv *env, BMTLSDOps *bmtlsdo);
void MTLSD_SetNativeDimensions(JNIEnv *env, BMTLSDOps *bmtlsdo, jint w, jint h);
static jboolean MTLSurfaceData_initTexture(BMTLSDOps *bmtlsdo, jboolean isOpaque, jboolean rtt, jint width, jint height) {
@ -98,12 +89,8 @@ static jboolean MTLSurfaceData_initTexture(BMTLSDOps *bmtlsdo, jboolean isOpaque
stencilTextureDescriptor.storageMode = MTLStorageModePrivate;
bmtlsdo->pStencilTexture = [ctx.device newTextureWithDescriptor:stencilTextureDescriptor];
bmtlsdo->isOpaque = isOpaque;
bmtlsdo->xOffset = 0;
bmtlsdo->yOffset = 0;
bmtlsdo->width = width;
bmtlsdo->height = height;
bmtlsdo->textureWidth = width;
bmtlsdo->textureHeight = height;
bmtlsdo->drawableType = rtt ? MTLSD_RT_TEXTURE : MTLSD_TEXTURE;
J2dTraceLn6(J2D_TRACE_VERBOSE, "MTLSurfaceData_initTexture: w=%d h=%d bp=%p [tex=%p] opaque=%d rtt=%d", width, height, bmtlsdo, bmtlsdo->pTexture, isOpaque, rtt);
@ -182,7 +169,7 @@ MTLSD_Delete(JNIEnv *env, BMTLSDOps *bmtlsdo)
{
J2dTraceLn3(J2D_TRACE_VERBOSE, "MTLSD_Delete: type=%d %p [tex=%p]", bmtlsdo->drawableType, bmtlsdo, bmtlsdo->pTexture);
if (bmtlsdo->drawableType == MTLSD_WINDOW) {
MTLSD_DestroyMTLSurface(env, bmtlsdo);
bmtlsdo->drawableType = MTLSD_UNDEFINED;
} else if (
bmtlsdo->drawableType == MTLSD_RT_TEXTURE
|| bmtlsdo->drawableType == MTLSD_TEXTURE
@ -254,18 +241,6 @@ MTLSD_Unlock(JNIEnv *env,
JNU_ThrowInternalError(env, "MTLSD_Unlock not implemented!");
}
/**
* This function disposes of any native windowing system resources associated
* with this surface.
*/
void
MTLSD_DestroyMTLSurface(JNIEnv *env, BMTLSDOps * bmtlsdo)
{
J2dTraceLn(J2D_TRACE_ERROR, "MTLSD_DestroyMTLSurface not implemented!");
JNI_COCOA_ENTER(env);
bmtlsdo->drawableType = MTLSD_UNDEFINED;
JNI_COCOA_EXIT(env);
}
/**
* This function initializes a native window surface and caches the window
@ -346,10 +321,8 @@ Java_sun_java2d_metal_MTLSurfaceData_initOps
bmtlsdo->sdOps.GetRasInfo = MTLSD_GetRasInfo;
bmtlsdo->sdOps.Unlock = MTLSD_Unlock;
bmtlsdo->sdOps.Dispose = MTLSD_Dispose;
bmtlsdo->drawableType = MTLSD_UNDEFINED;
bmtlsdo->xOffset = xoff;
bmtlsdo->yOffset = yoff;
bmtlsdo->isOpaque = isOpaque;
mtlsdo->peerData = (AWTView *)jlong_to_ptr(pPeerData);

View File

@ -27,7 +27,6 @@
#define MTLSurfaceDataBase_h_Included
#include "java_awt_image_AffineTransformOp.h"
#include "sun_java2d_metal_MTLSurfaceData.h"
#include "sun_java2d_pipe_hw_AccelSurface.h"
#include "SurfaceData.h"
@ -38,7 +37,7 @@
* information pertaining to the native surface. Some information about
* the more important/different fields:
*
* void *privOps;
* void* privOps;
* Pointer to native-specific (Metal) SurfaceData info, such as the
* native Drawable handle and GraphicsConfig data.
*
@ -48,62 +47,44 @@
*
* jboolean isOpaque;
* If true, the surface should be treated as being fully opaque. If
* the underlying surface (e.g. pbuffer) has an alpha channel and isOpaque
* is true, then we should take appropriate action (i.e. call glColorMask()
* to disable writes into the alpha channel) to ensure that the surface
* remains fully opaque.
*
* jint x/yOffset
* The offset in pixels of the Metal viewport origin from the lower-left
* corner of the heavyweight drawable. For example, a top-level frame on
* Windows XP has lower-left insets of (4,4). The Metal viewport origin
* would typically begin at the lower-left corner of the client region (inside
* the frame decorations), but AWT/Swing will take the insets into account
* when rendering into that window. So in order to account for this, we
* need to adjust the Metal viewport origin by an x/yOffset of (-4,-4). On
* X11, top-level frames typically don't have this insets issue, so their
* x/yOffset would be (0,0) (the same applies to pbuffers).
* the underlying surface (e.g. MTLTexture/MTLBuffer) has an alpha channel and
* isOpaque is true, then we should take appropriate action to ensure that the
* surface remains fully opaque.
*
* jint width/height;
* The cached surface bounds. For offscreen surface types (MTLSD_FBOBJECT,
* MTLSD_TEXTURE, etc.) these values must remain constant. Onscreen window
* surfaces (MTLSD_WINDOW, MTLSD_FLIP_BACKBUFFER, etc.) may have their
* bounds changed in response to a programmatic or user-initiated event, so
* these values represent the last known dimensions. To determine the true
* current bounds of this surface, query the native Drawable through the
* The cached surface bounds. For offscreen surface types (
* MTLSD_TEXTURE, MTLSD_RT_TEXTURE etc.) these values must remain constant.
* Onscreen window surfaces (MTLSD_WINDOW, MTLSD_FLIP_BACKBUFFER, etc.) may
* have their bounds changed in response to a programmatic or user-initiated
* event, so these values represent the last known dimensions. To determine the
* true current bounds of this surface, query the native Drawable through the
* privOps field.
*
* void* pTexture;
* The texture object handle, as generated by MTLTextureDescriptor(). If this
* value is null, the texture has not yet been initialized.
*
* jint textureWidth/Height;
* The actual bounds of the texture object for this surface.
* The texture image that we care about has dimensions specified by the width
* and height fields in this MTLSDOps structure.
* void* pStencilTexture;
* The byte buffer stencil mask used in rendering Metal rendering pass.
*/
typedef struct {
SurfaceDataOps sdOps;
void *privOps;
void* privOps;
jobject graphicsConfig;
jint drawableType;
jboolean isOpaque;
jint xOffset;
jint yOffset;
jint width;
jint height;
void* pTexture;
void* pStencilData; // stencil data to be rendered to this buffer
void* pStencilTexture; // stencil texture byte buffer stencil mask used in main rendering
jint textureWidth;
jint textureHeight;
} BMTLSDOps;
#define MTLSD_UNDEFINED sun_java2d_pipe_hw_AccelSurface_UNDEFINED
#define MTLSD_WINDOW sun_java2d_pipe_hw_AccelSurface_WINDOW
#define MTLSD_TEXTURE sun_java2d_pipe_hw_AccelSurface_TEXTURE
#define MTLSD_FLIP_BACKBUFFER sun_java2d_pipe_hw_AccelSurface_FLIP_BACKBUFFER
#define MTLSD_RT_TEXTURE sun_java2d_pipe_hw_AccelSurface_RT_TEXTURE
#define MTLSD_RT_TEXTURE sun_java2d_pipe_hw_AccelSurface_RT_TEXTURE
/**
* These are shorthand names for the filtering method constants used by

View File

@ -422,8 +422,8 @@ MTLTR_DrawLCDGlyphViaCache(MTLContext *mtlc, BMTLSDOps *dstOps,
tx2 = cell->tx2;
ty2 = cell->ty2;
J2dTraceLn4(J2D_TRACE_INFO, "tx1 %f, ty1 %f, tx2 %f, ty2 %f", tx1, ty1, tx2, ty2);
J2dTraceLn2(J2D_TRACE_INFO, "textureWidth %d textureHeight %d", dstOps->textureWidth, dstOps->textureHeight);
J2dTraceLn4(J2D_TRACE_INFO, "tx1 = %f, ty1 = %f, tx2 = %f, ty2 = %f", tx1, ty1, tx2, ty2);
J2dTraceLn2(J2D_TRACE_INFO, "width = %d height = %d", dstOps->width, dstOps->height);
LCD_ADD_TRIANGLES(tx1, ty1, tx2, ty2, x, y, x+w, y+h);
@ -557,9 +557,7 @@ MTLTR_DrawLCDGlyphNoCache(MTLContext *mtlc, BMTLSDOps *dstOps,
tx2 = 1.0f;
ty2 = 1.0f;
J2dTraceLn3(J2D_TRACE_INFO, "xOffset %d yOffset %d, dstOps->height %d", dstOps->xOffset, dstOps->yOffset, dstOps->height);
J2dTraceLn4(J2D_TRACE_INFO, "tx1 %f, ty1 %f, tx2 %f, ty2 %f", tx1, ty1, tx2, ty2);
J2dTraceLn2(J2D_TRACE_INFO, "textureWidth %d textureHeight %d", dstOps->textureWidth, dstOps->textureHeight);
J2dTraceLn2(J2D_TRACE_INFO, "MTLTR_DrawLCDGlyphNoCache : dstOps->width = %d, dstOps->height = %d", dstOps->width, dstOps->height);
LCD_ADD_TRIANGLES(tx1, ty1, tx2, ty2, x, y, x+w, y+h);