comparison src/share/native/sun/java2d/opengl/OGLBlitLoops.c @ 780:cd88b4ad7f25

6739267: D3D/OGL: add missing ThreeByteBgr to texture upload blit loop Reviewed-by: campbell, flar
author tdv
date Thu, 28 Aug 2008 11:27:14 -0700
parents 37a05a11f281
children 00cd9dc3c2b5
comparison
equal deleted inserted replaced
0:96979051fb33 1:26fb613c47df
201 // raster position from (0,0) to the desired location of (dx1,-dy1)... 201 // raster position from (0,0) to the desired location of (dx1,-dy1)...
202 j2d_glRasterPos2i(0, 0); 202 j2d_glRasterPos2i(0, 0);
203 j2d_glBitmap(0, 0, 0, 0, (GLfloat)dx1, (GLfloat)-dy1, NULL); 203 j2d_glBitmap(0, 0, 0, 0, (GLfloat)dx1, (GLfloat)-dy1, NULL);
204 204
205 j2d_glPixelZoom(scalex, -scaley); 205 j2d_glPixelZoom(scalex, -scaley);
206 j2d_glDrawPixels(sx2-sx1, sy2-sy1, pf->format, pf->type, srcInfo->rasBase); 206
207 // in case pixel stride is not a multiple of scanline stride the copy
208 // has to be done line by line (see 6207877)
209 if (srcInfo->scanStride % srcInfo->pixelStride != 0) {
210 jint width = sx2-sx1;
211 jint height = sy2-sy1;
212 GLvoid *pSrc = srcInfo->rasBase;
213
214 while (height > 0) {
215 j2d_glDrawPixels(width, 1, pf->format, pf->type, pSrc);
216 j2d_glBitmap(0, 0, 0, 0, (GLfloat)0, (GLfloat)-1, NULL);
217 pSrc = PtrAddBytes(pSrc, srcInfo->scanStride);
218 height--;
219 }
220 } else {
221 j2d_glDrawPixels(sx2-sx1, sy2-sy1, pf->format, pf->type, srcInfo->rasBase);
222 }
223
207 j2d_glPixelZoom(1.0, 1.0); 224 j2d_glPixelZoom(1.0, 1.0);
208 225
209 if (oglc->extraAlpha != 1.0f) { 226 if (oglc->extraAlpha != 1.0f) {
210 OGLContext_SetExtraAlpha(1.0f); 227 OGLContext_SetExtraAlpha(1.0f);
211 } 228 }
248 GLdouble dx, dy, dw, dh, cdw, cdh; 265 GLdouble dx, dy, dw, dh, cdw, cdh;
249 jint tw, th; 266 jint tw, th;
250 jint sx, sy, sw, sh; 267 jint sx, sy, sw, sh;
251 GLint glhint = (hint == OGLSD_XFORM_BILINEAR) ? GL_LINEAR : GL_NEAREST; 268 GLint glhint = (hint == OGLSD_XFORM_BILINEAR) ? GL_LINEAR : GL_NEAREST;
252 jboolean adjustAlpha = (pf != NULL && !pf->hasAlpha); 269 jboolean adjustAlpha = (pf != NULL && !pf->hasAlpha);
270 jboolean slowPath;
253 271
254 if (oglc->blitTextureID == 0) { 272 if (oglc->blitTextureID == 0) {
255 if (!OGLContext_InitBlitTileTexture(oglc)) { 273 if (!OGLContext_InitBlitTileTexture(oglc)) {
256 J2dRlsTraceLn(J2D_TRACE_ERROR, 274 J2dRlsTraceLn(J2D_TRACE_ERROR,
257 "OGLBlitToSurfaceViaTexture: could not init blit tile"); 275 "OGLBlitToSurfaceViaTexture: could not init blit tile");
277 // we need to ensure that the alpha values are forced to 1.0f 295 // we need to ensure that the alpha values are forced to 1.0f
278 j2d_glPixelTransferf(GL_ALPHA_SCALE, 0.0f); 296 j2d_glPixelTransferf(GL_ALPHA_SCALE, 0.0f);
279 j2d_glPixelTransferf(GL_ALPHA_BIAS, 1.0f); 297 j2d_glPixelTransferf(GL_ALPHA_BIAS, 1.0f);
280 } 298 }
281 299
300 // in case pixel stride is not a multiple of scanline stride the copy
301 // has to be done line by line (see 6207877)
302 slowPath = srcInfo->scanStride % srcInfo->pixelStride != 0;
303
282 for (sy = sy1, dy = dy1; sy < sy2; sy += th, dy += cdh) { 304 for (sy = sy1, dy = dy1; sy < sy2; sy += th, dy += cdh) {
283 sh = ((sy + th) > sy2) ? (sy2 - sy) : th; 305 sh = ((sy + th) > sy2) ? (sy2 - sy) : th;
284 dh = ((dy + cdh) > dy2) ? (dy2 - dy) : cdh; 306 dh = ((dy + cdh) > dy2) ? (dy2 - dy) : cdh;
285 307
286 for (sx = sx1, dx = dx1; sx < sx2; sx += tw, dx += cdw) { 308 for (sx = sx1, dx = dx1; sx < sx2; sx += tw, dx += cdw) {
289 311
290 tx2 = ((GLdouble)sw) / tw; 312 tx2 = ((GLdouble)sw) / tw;
291 ty2 = ((GLdouble)sh) / th; 313 ty2 = ((GLdouble)sh) / th;
292 314
293 if (swsurface) { 315 if (swsurface) {
294 j2d_glPixelStorei(GL_UNPACK_SKIP_PIXELS, sx); 316 if (slowPath) {
295 j2d_glPixelStorei(GL_UNPACK_SKIP_ROWS, sy); 317 jint tmph = sh;
296 318 GLvoid *pSrc = PtrCoord(srcInfo->rasBase,
297 j2d_glTexSubImage2D(GL_TEXTURE_2D, 0, 319 sx, srcInfo->pixelStride,
298 0, 0, sw, sh, 320 sy, srcInfo->scanStride);
299 pf->format, pf->type, 321
300 srcInfo->rasBase); 322 while (tmph > 0) {
323 j2d_glTexSubImage2D(GL_TEXTURE_2D, 0,
324 0, sh - tmph, sw, 1,
325 pf->format, pf->type,
326 pSrc);
327 pSrc = PtrAddBytes(pSrc, srcInfo->scanStride);
328 tmph--;
329 }
330 } else {
331 j2d_glPixelStorei(GL_UNPACK_SKIP_PIXELS, sx);
332 j2d_glPixelStorei(GL_UNPACK_SKIP_ROWS, sy);
333
334 j2d_glTexSubImage2D(GL_TEXTURE_2D, 0,
335 0, 0, sw, sh,
336 pf->format, pf->type,
337 srcInfo->rasBase);
338 }
301 339
302 // the texture image is "right side up", so we align the 340 // the texture image is "right side up", so we align the
303 // upper-left texture corner with the upper-left quad corner 341 // upper-left texture corner with the upper-left quad corner
304 j2d_glBegin(GL_QUADS); 342 j2d_glBegin(GL_QUADS);
305 j2d_glTexCoord2d(tx1, ty1); j2d_glVertex2d(dx, dy); 343 j2d_glTexCoord2d(tx1, ty1); j2d_glVertex2d(dx, dy);
354 OGLBlitSwToTexture(SurfaceDataRasInfo *srcInfo, OGLPixelFormat *pf, 392 OGLBlitSwToTexture(SurfaceDataRasInfo *srcInfo, OGLPixelFormat *pf,
355 OGLSDOps *dstOps, 393 OGLSDOps *dstOps,
356 jint dx1, jint dy1, jint dx2, jint dy2) 394 jint dx1, jint dy1, jint dx2, jint dy2)
357 { 395 {
358 j2d_glBindTexture(dstOps->textureTarget, dstOps->textureID); 396 j2d_glBindTexture(dstOps->textureTarget, dstOps->textureID);
359 j2d_glTexSubImage2D(dstOps->textureTarget, 0, 397 // in case pixel stride is not a multiple of scanline stride the copy
360 dx1, dy1, dx2-dx1, dy2-dy1, 398 // has to be done line by line (see 6207877)
361 pf->format, pf->type, srcInfo->rasBase); 399 if (srcInfo->scanStride % srcInfo->pixelStride != 0) {
400 jint width = dx2 - dx1;
401 jint height = dy2 - dy1;
402 GLvoid *pSrc = srcInfo->rasBase;
403
404 while (height > 0) {
405 j2d_glTexSubImage2D(dstOps->textureTarget, 0,
406 dx1, dy2 - height, width, 1,
407 pf->format, pf->type, pSrc);
408 pSrc = PtrAddBytes(pSrc, srcInfo->scanStride);
409 height--;
410 }
411 } else {
412 j2d_glTexSubImage2D(dstOps->textureTarget, 0,
413 dx1, dy1, dx2-dx1, dy2-dy1,
414 pf->format, pf->type, srcInfo->rasBase);
415 }
362 } 416 }
363 417
364 /** 418 /**
365 * General blit method for copying a native OpenGL surface (of type "Surface" 419 * General blit method for copying a native OpenGL surface (of type "Surface"
366 * or "Texture") to another OpenGL "Surface". If texture is JNI_TRUE, this 420 * or "Texture") to another OpenGL "Surface". If texture is JNI_TRUE, this