65
65
MTLRasterFormatInfo RasterFormatInfos[] = {
66
66
{ MTLPixelFormatBGRA8Unorm , 1 , 0 , nil }, /* 0 - IntArgb */ // Argb (in java notation)
67
67
{ MTLPixelFormatBGRA8Unorm , 1 , 1 , nil }, /* 1 - IntArgbPre */
68
- { MTLPixelFormatBGRA8Unorm , 0 , 1 , nil }, /* 2 - IntRgb */
68
+ { MTLPixelFormatBGRA8Unorm , 0 , 1 , @" rgb_to_rgba " }, /* 2 - IntRgb */
69
69
{ MTLPixelFormatBGRA8Unorm , 0 , 1 , @" xrgb_to_rgba" }, /* 3 - IntRgbx */
70
70
{ MTLPixelFormatBGRA8Unorm , 0 , 1 , @" bgr_to_rgba" }, /* 4 - IntBgr */
71
71
{ MTLPixelFormatBGRA8Unorm , 0 , 1 , @" xbgr_to_rgba" }, /* 5 - IntBgrx */
@@ -163,15 +163,16 @@ void drawTex2Tex(MTLContext *mtlc,
163
163
const int sh = srcInfo->bounds .y2 - srcInfo->bounds .y1 ;
164
164
const int dw = dx2 - dx1;
165
165
const int dh = dy2 - dy1;
166
+ if (dw < sw || dh < sh) {
167
+ J2dTraceLn4 (J2D_TRACE_WARNING, " replaceTextureRegion: dest size: (%d , %d ) less than source size: (%d , %d )" , dw, dh, sw, sh);
168
+ }
166
169
167
170
const void *raster = srcInfo->rasBase ;
168
171
raster += (NSUInteger )srcInfo->bounds .y1 * (NSUInteger )srcInfo->scanStride + (NSUInteger )srcInfo->bounds .x1 * (NSUInteger )srcInfo->pixelStride ;
169
172
170
173
@autoreleasepool {
171
174
J2dTraceLn4 (J2D_TRACE_VERBOSE, " replaceTextureRegion src (dw, dh) : [%d , %d ] dest (dx1, dy1) =[%d , %d ]" ,
172
175
dw, dh, dx1, dy1);
173
- // NOTE: we might want to fill alpha channel when !rfi->hasAlpha
174
-
175
176
id <MTLBuffer > buff = [[mtlc.device newBufferWithLength: (sw * sh * srcInfo->pixelStride) options: MTLResourceStorageModeManaged ] autorelease ];
176
177
177
178
// copy src pixels inside src bounds to buff
@@ -226,7 +227,7 @@ void drawTex2Tex(MTLContext *mtlc,
226
227
static void
227
228
MTLBlitSwToTextureViaPooledTexture (
228
229
MTLContext *mtlc, SurfaceDataRasInfo *srcInfo, BMTLSDOps * bmtlsdOps,
229
- MTLRasterFormatInfo * rfi, jboolean useBlitEncoder , jint hint,
230
+ MTLRasterFormatInfo *rfi, jint hint,
230
231
jdouble dx1, jdouble dy1, jdouble dx2, jdouble dy2)
231
232
{
232
233
int sw = srcInfo->bounds .x2 - srcInfo->bounds .x1 ;
@@ -246,23 +247,9 @@ void drawTex2Tex(MTLContext *mtlc,
246
247
247
248
id <MTLTexture > texBuff = texHandle.texture ;
248
249
replaceTextureRegion (mtlc, texBuff, srcInfo, rfi, 0 , 0 , sw, sh);
249
- // TODO: useBlitEncoder is always false, remove dead code
250
- if (useBlitEncoder) {
251
- id <MTLBlitCommandEncoder > blitEncoder = [mtlc.encoderManager createBlitEncoder ];
252
- [blitEncoder copyFromTexture: texBuff
253
- sourceSlice: 0
254
- sourceLevel: 0
255
- sourceOrigin: MTLOriginMake (0 , 0 , 0 )
256
- sourceSize: MTLSizeMake (sw, sh, 1 )
257
- toTexture: dest
258
- destinationSlice: 0
259
- destinationLevel: 0
260
- destinationOrigin: MTLOriginMake (dx1, dy1, 0 )];
261
- [blitEncoder endEncoding ];
262
- } else {
263
- drawTex2Tex (mtlc, texBuff, dest, !rfi->hasAlpha , bmtlsdOps->isOpaque , hint,
264
- 0 , 0 , sw, sh, dx1, dy1, dx2, dy2);
265
- }
250
+
251
+ drawTex2Tex (mtlc, texBuff, dest, !rfi->hasAlpha , bmtlsdOps->isOpaque , hint,
252
+ 0 , 0 , sw, sh, dx1, dy1, dx2, dy2);
266
253
}
267
254
268
255
static
@@ -582,28 +569,11 @@ jboolean clipDestCoords(
582
569
#endif // TRACE_BLIT
583
570
584
571
MTLRasterFormatInfo rfi = RasterFormatInfos[srctype];
585
- const jboolean useReplaceRegion = texture ||
586
- (!rfi.hasAlpha
587
- && !xform
588
- && isIntegerAndUnscaled (sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2));
589
572
590
- if (useReplaceRegion) {
591
- if (dstOps->isOpaque || rfi.hasAlpha ) {
592
- #ifdef TRACE_BLIT
593
- J2dTraceImpl (J2D_TRACE_VERBOSE, JNI_TRUE," [replaceTextureRegion]" );
594
- #endif // TRACE_BLIT
595
- replaceTextureRegion (mtlc, dest, &srcInfo, &rfi, (int ) dx1, (int ) dy1, (int ) dx2, (int ) dy2);
596
- } else {
597
- #ifdef TRACE_BLIT
598
- J2dTraceImpl (J2D_TRACE_VERBOSE, JNI_TRUE," [via pooled + blit]" );
599
- #endif // TRACE_BLIT
600
- MTLBlitSwToTextureViaPooledTexture (mtlc, &srcInfo, dstOps, &rfi, false , hint, dx1, dy1, dx2, dy2);
601
- }
602
- } else { // !useReplaceRegion
603
- #ifdef TRACE_BLIT
604
- J2dTraceImpl (J2D_TRACE_VERBOSE, JNI_TRUE," [via pooled texture]" );
605
- #endif // TRACE_BLIT
606
- MTLBlitSwToTextureViaPooledTexture (mtlc, &srcInfo, dstOps, &rfi, false , hint, dx1, dy1, dx2, dy2);
573
+ if (texture) {
574
+ replaceTextureRegion (mtlc, dest, &srcInfo, &rfi, (int ) dx1, (int ) dy1, (int ) dx2, (int ) dy2);
575
+ } else {
576
+ MTLBlitSwToTextureViaPooledTexture (mtlc, &srcInfo, dstOps, &rfi, hint, dx1, dy1, dx2, dy2);
607
577
}
608
578
}
609
579
SurfaceData_InvokeRelease (env, srcOps, &srcInfo);
0 commit comments