/* * Class: sun_java2d_windows_GDIRenderer * Method: doDrawOval * Signature: (Lsun/java2d/windows/GDIWindowSurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIII)V */ JNIEXPORT void JNICALL Java_sun_java2d_windows_GDIRenderer_doDrawOval (JNIEnv *env, jobject wr, jobject sData, jobject clip, jobject comp, jint color, jint x, jint y, jint w, jint h) { J2dTraceLn(J2D_TRACE_INFO, "GDIRenderer_doDrawOval"); J2dTraceLn5(J2D_TRACE_VERBOSE, " color=0x%x x=%-4d y=%-4d w=%-4d h=%-4d", color, x, y, w, h); if (w < 2 || h < 2) { // Thin enough ovals have no room for curvature. Defer to // the DrawRect method which handles degenerate sizes better. Java_sun_java2d_windows_GDIRenderer_doDrawRect(env, wr, sData, clip, comp, color, x, y, w, h); return; } GDIWinSDOps *wsdo = GDIWindowSurfaceData_GetOps(env, sData); if (wsdo == NULL) { return; } HDC hdc = wsdo->GetDC(env, wsdo, PENONLY, NULL, clip, comp, color); if (hdc == NULL) { return; } ::Ellipse(hdc, x, y, x+w+1, y+h+1); wsdo->ReleaseDC(env, wsdo, hdc); }
/* * Class: sun_java2d_windows_GDIRenderer * Method: doFillRect * Signature: (Lsun/java2d/windows/GDIWindowSurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIII)V */ JNIEXPORT void JNICALL Java_sun_java2d_windows_GDIRenderer_doFillRect (JNIEnv *env, jobject wr, jobject sData, jobject clip, jobject comp, jint color, jint x, jint y, jint w, jint h) { J2dTraceLn(J2D_TRACE_INFO, "GDIRenderer_doFillRect"); J2dTraceLn5(J2D_TRACE_VERBOSE, " color=0x%x x=%-4d y=%-4d w=%-4d h=%-4d", color, x, y, w, h); if (w <= 0 || h <= 0) { return; } GDIWinSDOps *wsdo = GDIWindowSurfaceData_GetOps(env, sData); if (wsdo == NULL) { return; } jint patrop; HDC hdc = wsdo->GetDC(env, wsdo, BRUSH, &patrop, clip, comp, color); if (hdc == NULL) { return; } ::PatBlt(hdc, x, y, w, h, patrop); wsdo->ReleaseDC(env, wsdo, hdc); }
/* * Class: sun_java2d_windows_GDIRenderer * Method: doDrawPoly * Signature: (Lsun/java2d/windows/GDIWindowSurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;III[I[IIZ)V */ JNIEXPORT void JNICALL Java_sun_java2d_windows_GDIRenderer_doDrawPoly (JNIEnv *env, jobject wr, jobject sData, jobject clip, jobject comp, jint color, jint transx, jint transy, jintArray xpointsarray, jintArray ypointsarray, jint npoints, jboolean isclosed) { J2dTraceLn(J2D_TRACE_INFO, "GDIRenderer_doDrawPoly"); J2dTraceLn5(J2D_TRACE_VERBOSE, " color=0x%x transx=%-4d transy=%-4d "\ "npoints=%-4d isclosed=%-4d", color, transx, transy, npoints, isclosed); if (JNU_IsNull(env, xpointsarray) || JNU_IsNull(env, ypointsarray)) { JNU_ThrowNullPointerException(env, "coordinate array"); return; } if (env->GetArrayLength(xpointsarray) < npoints || env->GetArrayLength(ypointsarray) < npoints) { JNU_ThrowArrayIndexOutOfBoundsException(env, "coordinate array"); return; } if (npoints < 2) { // Fix for 4067534 - assertion failure in 1.3.1 for degenerate polys // Not enough points for a line. // Note that this would be ignored later anyway, but returning // here saves us from mistakes in TransformPoly and seeing bad // return values from the Windows Polyline function. return; } GDIWinSDOps *wsdo = GDIWindowSurfaceData_GetOps(env, sData); if (wsdo == NULL) { return; } POINT tmpPts[POLYTEMPSIZE], *pPoints; jint *xpoints = (jint *) env->GetPrimitiveArrayCritical(xpointsarray, NULL); jint *ypoints = (jint *) env->GetPrimitiveArrayCritical(ypointsarray, NULL); pPoints = TransformPoly(xpoints, ypoints, transx, transy, tmpPts, &npoints, isclosed, TRUE); env->ReleasePrimitiveArrayCritical(xpointsarray, xpoints, JNI_ABORT); env->ReleasePrimitiveArrayCritical(ypointsarray, ypoints, JNI_ABORT); if (pPoints == NULL) { return; } HDC hdc = wsdo->GetDC(env, wsdo, PEN, NULL, clip, comp, color); if (hdc == NULL) { return; } ::Polyline(hdc, pPoints, npoints); wsdo->ReleaseDC(env, wsdo, hdc); if (pPoints != tmpPts) { free(pPoints); } }
/* * Class: sun_java2d_windows_GDIRenderer * Method: doFillArc * Signature: (Lsun/java2d/windows/GDIWindowSurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIIIII)V */ JNIEXPORT void JNICALL Java_sun_java2d_windows_GDIRenderer_doFillArc (JNIEnv *env, jobject wr, jobject sData, jobject clip, jobject comp, jint color, jint x, jint y, jint w, jint h, jint angleStart, jint angleExtent) { J2dTraceLn(J2D_TRACE_INFO, "GDIRenderer_doFillArc"); J2dTraceLn5(J2D_TRACE_VERBOSE, " color=0x%x x=%-4d y=%-4d w=%-4d h=%-4d", color, x, y, w, h); J2dTraceLn2(J2D_TRACE_VERBOSE, " angleStart=%-4d angleExtent=%-4d", angleStart, angleExtent); if (w <= 0 || h <= 0 || angleExtent == 0) { return; } if (angleExtent >= 360 || angleExtent <= -360) { // Fix related to 4411814 - small ovals (and arcs) do not draw // If the arc is a full circle, let the Oval method handle it // since that method can deal with degenerate sizes better. Java_sun_java2d_windows_GDIRenderer_doFillOval(env, wr, sData, clip, comp, color, x, y, w, h); return; } GDIWinSDOps *wsdo = GDIWindowSurfaceData_GetOps(env, sData); if (wsdo == NULL) { return; } long sx, sy, ex, ey; int angleEnd; if (angleExtent < 0) { angleEnd = angleStart; angleStart += angleExtent; } else { angleEnd = angleStart + angleExtent; } AngleToCoord(angleStart, w, h, &sx, &sy); sx += x + w/2; sy += y + h/2; AngleToCoord(angleEnd, w, h, &ex, &ey); ex += x + w/2; ey += y + h/2; HDC hdc = wsdo->GetDC(env, wsdo, BRUSHONLY, NULL, clip, comp, color); if (hdc == NULL) { return; } ::Pie(hdc, x, y, x+w+1, y+h+1, sx, sy, ex, ey); wsdo->ReleaseDC(env, wsdo, hdc); }
/* * Class: sun_java2d_windows_GDIRenderer * Method: doDrawArc * Signature: (Lsun/java2d/windows/GDIWindowSurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIIIII)V */ JNIEXPORT void JNICALL Java_sun_java2d_windows_GDIRenderer_doDrawArc (JNIEnv *env, jobject wr, jobject sData, jobject clip, jobject comp, jint color, jint x, jint y, jint w, jint h, jint angleStart, jint angleExtent) { J2dTraceLn(J2D_TRACE_INFO, "GDIRenderer_doDrawArc"); J2dTraceLn5(J2D_TRACE_VERBOSE, " color=0x%x x=%-4d y=%-4d w=%-4d h=%-4d", color, x, y, w, h); J2dTraceLn2(J2D_TRACE_VERBOSE, " angleStart=%-4d angleExtent=%-4d", angleStart, angleExtent); if (w < 0 || h < 0 || angleExtent == 0) { return; } GDIWinSDOps *wsdo = GDIWindowSurfaceData_GetOps(env, sData); if (wsdo == NULL) { return; } long sx, sy, ex, ey; if (angleExtent >= 360 || angleExtent <= -360) { sx = ex = x + w; sy = ey = y + h/2; } else { int angleEnd; if (angleExtent < 0) { angleEnd = angleStart; angleStart += angleExtent; } else { angleEnd = angleStart + angleExtent; } AngleToCoord(angleStart, w, h, &sx, &sy); sx += x + w/2; sy += y + h/2; AngleToCoord(angleEnd, w, h, &ex, &ey); ex += x + w/2; ey += y + h/2; } HDC hdc = wsdo->GetDC(env, wsdo, PEN, NULL, clip, comp, color); if (hdc == NULL) { return; } ::Arc(hdc, x, y, x+w+1, y+h+1, sx, sy, ex, ey); wsdo->ReleaseDC(env, wsdo, hdc); }
HRESULT D3DVertexCacher::EnsureCapacity(D3DPRIMITIVETYPE newPType, UINT vNum) { HRESULT res = D3D_OK; if (vNum > MAX_BATCH_SIZE) { // REMIND: need to define our own errors return D3DERR_NOTAVAILABLE; } if ((firstUnusedVertex + vNum) > MAX_BATCH_SIZE) { // if we can't fit new vertices in the vertex buffer, // render whatever we have in the buffer and start // from the beginning of the vertex buffer J2dTraceLn2(J2D_TRACE_VERBOSE, "D3DVC::EnsureCapacity exceeded capacity. "\ "current v: %d, requested vertices: %d\n", firstUnusedVertex, vNum); if (FAILED(res = Render(RESET_ACTION))) { return res; } } J2dTraceLn5(J2D_TRACE_VERBOSE, "D3DVC::EnsureCapacity current batch: %d "\ " batch.type=%d newType=%d vNum=%d firstUnusedV=%d", currentBatch, batches[currentBatch].pType, newPType, vNum, firstUnusedVertex); // there should not be multiple linestrips in a batch, // or they will be counted as a single line strip if (batches[currentBatch].pType != newPType || batches[currentBatch].pType == D3DPT_LINESTRIP) { // if this is a first unused batch, use it if (firstUnusedVertex == firstPendingVertex) { // record the first batch and vertex scheduled for rendering firstPendingBatch = currentBatch; firstPendingVertex = firstUnusedVertex; } else { // otherwise go to the next batch currentBatch++; } batches[currentBatch].pType = newPType; batches[currentBatch].pNum = 0; } // firstUnusedVertex is updated when new vertices are added // to the vertices array return res; }
/* * Class: sun_java2d_windows_GDIRenderer * Method: doDrawLine * Signature: (Lsun/java2d/windows/GDIWindowSurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIII)V */ JNIEXPORT void JNICALL Java_sun_java2d_windows_GDIRenderer_doDrawLine (JNIEnv *env, jobject wr, jobject sData, jobject clip, jobject comp, jint color, jint x1, jint y1, jint x2, jint y2) { J2dTraceLn(J2D_TRACE_INFO, "GDIRenderer_doDrawLine"); J2dTraceLn5(J2D_TRACE_VERBOSE, " color=0x%x x1=%-4d y1=%-4d x2=%-4d y2=%-4d", color, x1, y1, x2, y2); GDIWinSDOps *wsdo = GDIWindowSurfaceData_GetOps(env, sData); if (wsdo == NULL) { return; } HDC hdc; jint patrop; if (x1 == x2 || y1 == y2) { if (x1 > x2) { jint t = x1; x1 = x2; x2 = t; } if (y1 > y2) { jint t = y1; y1 = y2; y2 = t; } hdc = wsdo->GetDC(env, wsdo, BRUSH, &patrop, clip, comp, color); if (hdc == NULL) { return; } ::PatBlt(hdc, x1, y1, x2-x1+1, y2-y1+1, patrop); } else { hdc = wsdo->GetDC(env, wsdo, PENBRUSH, &patrop, clip, comp, color); if (hdc == NULL) { return; } ::MoveToEx(hdc, x1, y1, NULL); ::LineTo(hdc, x2, y2); ::PatBlt(hdc, x2, y2, 1, 1, patrop); } wsdo->ReleaseDC(env, wsdo, hdc); }
/* * Class: sun_java2d_windows_GDIRenderer * Method: doDrawRect * Signature: (Lsun/java2d/windows/GDIWindowSurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIII)V */ JNIEXPORT void JNICALL Java_sun_java2d_windows_GDIRenderer_doDrawRect (JNIEnv *env, jobject wr, jobject sData, jobject clip, jobject comp, jint color, jint x, jint y, jint w, jint h) { J2dTraceLn(J2D_TRACE_INFO, "GDIRenderer_doDrawRect"); J2dTraceLn5(J2D_TRACE_VERBOSE, " color=0x%x x=%-4d y=%-4d w=%-4d h=%-4d", color, x, y, w, h); if (w < 0 || h < 0) { return; } GDIWinSDOps *wsdo = GDIWindowSurfaceData_GetOps(env, sData); if (wsdo == NULL) { return; } jint patrop; HDC hdc = wsdo->GetDC(env, wsdo, BRUSH, &patrop, clip, comp, color); if (hdc == NULL) { return; } if (w < 2 || h < 2) { // If one dimension is less than 2 then there is no // gap in the middle - draw a solid filled rectangle. ::PatBlt(hdc, x, y, w+1, h+1, patrop); } else { // Avoid drawing the endpoints twice. // Also prefer including the endpoints in the // horizontal sections which draw pixels faster. ::PatBlt(hdc, x, y, w+1, 1, patrop); ::PatBlt(hdc, x, y+1, 1, h-1, patrop); ::PatBlt(hdc, x+w, y+1, 1, h-1, patrop); ::PatBlt(hdc, x, y+h, w+1, 1, patrop); } wsdo->ReleaseDC(env, wsdo, hdc); }
/* * Class: sun_java2d_windows_GDIRenderer * Method: doDrawRoundRect * Signature: (Lsun/java2d/windows/GDIWindowSurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIIIII)V */ JNIEXPORT void JNICALL Java_sun_java2d_windows_GDIRenderer_doDrawRoundRect (JNIEnv *env, jobject wr, jobject sData, jobject clip, jobject comp, jint color, jint x, jint y, jint w, jint h, jint arcW, jint arcH) { J2dTraceLn(J2D_TRACE_INFO, "GDIRenderer_doDrawRoundRect"); J2dTraceLn5(J2D_TRACE_VERBOSE, " color=0x%x x=%-4d y=%-4d w=%-4d h=%-4d", color, x, y, w, h); J2dTraceLn2(J2D_TRACE_VERBOSE, " arcW=%-4d arcH=%-4d", arcW, arcH); if (w < 2 || h < 2 || arcW <= 0 || arcH <= 0) { // Fix for 4524760 - drawRoundRect0 test case fails on Windows 98 // Thin round rects degenerate into regular rectangles // because there is no room for the arc sections. Also // if there is no arc dimension then the roundrect must // be a simple rectangle. Defer to the DrawRect function // which handles degenerate sizes better. Java_sun_java2d_windows_GDIRenderer_doDrawRect(env, wr, sData, clip, comp, color, x, y, w, h); return; } GDIWinSDOps *wsdo = GDIWindowSurfaceData_GetOps(env, sData); if (wsdo == NULL) { return; } HDC hdc = wsdo->GetDC(env, wsdo, PENONLY, NULL, clip, comp, color); if (hdc == NULL) { return; } ::RoundRect(hdc, x, y, x+w+1, y+h+1, arcW, arcH); wsdo->ReleaseDC(env, wsdo, hdc); }
/* * Class: sun_java2d_windows_GDIRenderer * Method: doFillRoundRect * Signature: (Lsun/java2d/windows/GDIWindowSurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIIIII)V */ JNIEXPORT void JNICALL Java_sun_java2d_windows_GDIRenderer_doFillRoundRect (JNIEnv *env, jobject wr, jobject sData, jobject clip, jobject comp, jint color, jint x, jint y, jint w, jint h, jint arcW, jint arcH) { J2dTraceLn(J2D_TRACE_INFO, "GDIRenderer_doFillRoundRect"); J2dTraceLn5(J2D_TRACE_VERBOSE, " color=0x%x x=%-4d y=%-4d w=%-4d h=%-4d", color, x, y, w, h); J2dTraceLn2(J2D_TRACE_VERBOSE, " arcW=%-4d arcH=%-4d", arcW, arcH); if (w < 2 || h < 2 || arcW <= 0 || arcH <= 0) { // Fix related to 4524760 - drawRoundRect0 fails on Windows 98 // Thin round rects have no room for curvature. Also, if // the curvature is empty then the primitive has degenerated // into a simple rectangle. Defer to the FillRect method // which deals with degenerate sizes better. Java_sun_java2d_windows_GDIRenderer_doFillRect(env, wr, sData, clip, comp, color, x, y, w, h); return; } GDIWinSDOps *wsdo = GDIWindowSurfaceData_GetOps(env, sData); if (wsdo == NULL) { return; } HDC hdc = wsdo->GetDC(env, wsdo, BRUSHONLY, NULL, clip, comp, color); if (hdc == NULL) { return; } ::RoundRect(hdc, x, y, x+w+1, y+h+1, arcW, arcH); wsdo->ReleaseDC(env, wsdo, hdc); }
/* * Class: sun_java2d_windows_GDIRenderer * Method: doFillOval * Signature: (Lsun/java2d/windows/GDIWindowSurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIII)V */ JNIEXPORT void JNICALL Java_sun_java2d_windows_GDIRenderer_doFillOval (JNIEnv *env, jobject wr, jobject sData, jobject clip, jobject comp, jint color, jint x, jint y, jint w, jint h) { J2dTraceLn(J2D_TRACE_INFO, "GDIRenderer_doFillOval"); J2dTraceLn5(J2D_TRACE_VERBOSE, " color=0x%x x=%-4d y=%-4d w=%-4d h=%-4d", color, x, y, w, h); if (w < 3 || h < 3) { // Fix for 4411814 - small ovals do not draw anything // (related to 4205762 on Solaris platform) // Most platform graphics packages have poor rendering // for thin ellipses and the rendering is most strikingly // different from our theoretical arcs. Ideally we should // trap all ovals less than some fairly large size and // try to draw aesthetically pleasing ellipses, but that // would require considerably more work to get the corresponding // drawArc variants to match pixel for pixel. // Thin ovals of girth 1 pixel are simple rectangles. // Thin ovals of girth 2 pixels are simple rectangles with // potentially smaller lengths. Determine the correct length // by calculating .5*.5 + scaledlen*scaledlen == 1.0 which // means that scaledlen is the sqrt(0.75). Scaledlen is // relative to the true length (w or h) and needs to be // adjusted by half a pixel in different ways for odd or // even lengths. #define SQRT_3_4 0.86602540378443864676 if (w > 2 && h > 1) { int adjw = (int) ((SQRT_3_4 * w - ((w&1)-1)) * 0.5); adjw = adjw * 2 + (w&1); x += (w-adjw)/2; w = adjw; } else if (h > 2 && w > 1) { int adjh = (int) ((SQRT_3_4 * h - ((h&1)-1)) * 0.5); adjh = adjh * 2 + (h&1); y += (h-adjh)/2; h = adjh; } #undef SQRT_3_4 if (w > 0 && h > 0) { Java_sun_java2d_windows_GDIRenderer_doFillRect(env, wr, sData, clip, comp, color, x, y, w, h); } return; } GDIWinSDOps *wsdo = GDIWindowSurfaceData_GetOps(env, sData); if (wsdo == NULL) { return; } HDC hdc = wsdo->GetDC(env, wsdo, BRUSHONLY, NULL, clip, comp, color); if (hdc == NULL) { return; } ::Ellipse(hdc, x, y, x+w+1, y+h+1); wsdo->ReleaseDC(env, wsdo, hdc); }