< prev index next >

src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.c

Print this page


   1 /*
   2  * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


1532 }
1533 
1534 #endif /* !HEADLESS */
1535 
1536 /*
1537  * Class:     sun_java2d_x11_X11SurfaceData
1538  * Method:    XCreateGC
1539  * Signature: (I)J
1540  */
1541 JNIEXPORT jlong JNICALL
1542 Java_sun_java2d_x11_XSurfaceData_XCreateGC
1543     (JNIEnv *env, jclass xsd, jlong pXSData)
1544 {
1545     jlong ret;
1546 
1547 #ifndef HEADLESS
1548     X11SDOps *xsdo;
1549 
1550     J2dTraceLn(J2D_TRACE_INFO, "in X11SurfaceData_XCreateGC");
1551 
1552     xsdo = (X11SDOps *) pXSData;
1553     if (xsdo == NULL) {
1554         return 0L;
1555     }
1556 
1557     xsdo->javaGC = XCreateGC(awt_display, xsdo->drawable, 0, NULL);
1558     ret = (jlong) xsdo->javaGC;
1559 #else /* !HEADLESS */
1560     ret = 0L;
1561 #endif /* !HEADLESS */
1562 
1563     return ret;
1564 }
1565 
1566 /*
1567  * Class:     sun_java2d_x11_X11SurfaceData
1568  * Method:    XResetClip
1569  * Signature: (JIIIILsun/java2d/pipe/Region;)V
1570  */
1571 JNIEXPORT void JNICALL
1572 Java_sun_java2d_x11_XSurfaceData_XResetClip
1573     (JNIEnv *env, jclass xsd, jlong xgc)
1574 {
1575 #ifndef HEADLESS
1576     J2dTraceLn(J2D_TRACE_INFO, "in X11SurfaceData_XResetClip");
1577     XSetClipMask(awt_display, (GC) xgc, None);
1578 #endif /* !HEADLESS */
1579 }
1580 
1581 /*
1582  * Class:     sun_java2d_x11_X11SurfaceData
1583  * Method:    XSetClip
1584  * Signature: (JIIIILsun/java2d/pipe/Region;)V
1585  */
1586 JNIEXPORT void JNICALL
1587 Java_sun_java2d_x11_XSurfaceData_XSetClip
1588     (JNIEnv *env, jclass xsd, jlong xgc,
1589      jint x1, jint y1, jint x2, jint y2,
1590      jobject complexclip)
1591 {
1592 #ifndef HEADLESS
1593     int numrects;
1594     XRectangle rects[256];
1595     XRectangle *pRect = rects;
1596 
1597     J2dTraceLn(J2D_TRACE_INFO, "in X11SurfaceData_XSetClip");
1598 
1599     numrects = RegionToYXBandedRectangles(env,
1600             x1, y1, x2, y2, complexclip,
1601             &pRect, 256);
1602 
1603     XSetClipRectangles(awt_display, (GC) xgc, 0, 0, pRect, numrects, YXBanded);
1604 
1605     if (pRect != rects) {
1606         free(pRect);
1607     }
1608 #endif /* !HEADLESS */
1609 }
1610 
1611 /*
1612  * Class:     sun_java2d_x11_X11SurfaceData
1613  * Method:    XSetCopyMode
1614  * Signature: (J)V
1615  */
1616 JNIEXPORT void JNICALL
1617 Java_sun_java2d_x11_X11SurfaceData_XSetCopyMode
1618     (JNIEnv *env, jclass xsd, jlong xgc)
1619 {
1620 #ifndef HEADLESS
1621     J2dTraceLn(J2D_TRACE_INFO, "in X11SurfaceData_XSetCopyMode");
1622     XSetFunction(awt_display, (GC) xgc, GXcopy);
1623 #endif /* !HEADLESS */
1624 }
1625 
1626 /*
1627  * Class:     sun_java2d_x11_X11SurfaceData
1628  * Method:    XSetXorMode
1629  * Signature: (J)V
1630  */
1631 JNIEXPORT void JNICALL
1632 Java_sun_java2d_x11_X11SurfaceData_XSetXorMode
1633     (JNIEnv *env, jclass xr, jlong xgc)
1634 {
1635 #ifndef HEADLESS
1636     J2dTraceLn(J2D_TRACE_INFO, "in X11SurfaceData_XSetXorMode");
1637     XSetFunction(awt_display, (GC) xgc, GXxor);
1638 #endif /* !HEADLESS */
1639 }
1640 
1641 /*
1642  * Class:     sun_java2d_x11_X11SurfaceData
1643  * Method:    XSetForeground
1644  * Signature: (JI)V
1645  */
1646 JNIEXPORT void JNICALL
1647 Java_sun_java2d_x11_X11SurfaceData_XSetForeground
1648     (JNIEnv *env, jclass xsd, jlong xgc, jint pixel)
1649 {
1650 #ifndef HEADLESS
1651     J2dTraceLn(J2D_TRACE_INFO, "in X11SurfaceData_XSetForeground");
1652     XSetForeground(awt_display, (GC) xgc, pixel);
1653 #endif /* !HEADLESS */
1654 }
1655 
1656 /*
1657  * Class:     sun_java2d_x11_X11SurfaceData
1658  * Method:    XSetGraphicsExposures
1659  * Signature: (JZ)V
1660  */
1661 JNIEXPORT void JNICALL
1662 Java_sun_java2d_x11_XSurfaceData_XSetGraphicsExposures
1663     (JNIEnv *env, jclass xsd, jlong xgc, jboolean needExposures)
1664 {
1665 #ifndef HEADLESS
1666     J2dTraceLn(J2D_TRACE_INFO, "in X11SurfaceData_XSetGraphicsExposures");
1667     XSetGraphicsExposures(awt_display, (GC) xgc, needExposures ? True : False);
1668 #endif /* !HEADLESS */
1669 }
   1 /*
   2  * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


1532 }
1533 
1534 #endif /* !HEADLESS */
1535 
1536 /*
1537  * Class:     sun_java2d_x11_X11SurfaceData
1538  * Method:    XCreateGC
1539  * Signature: (I)J
1540  */
1541 JNIEXPORT jlong JNICALL
1542 Java_sun_java2d_x11_XSurfaceData_XCreateGC
1543     (JNIEnv *env, jclass xsd, jlong pXSData)
1544 {
1545     jlong ret;
1546 
1547 #ifndef HEADLESS
1548     X11SDOps *xsdo;
1549 
1550     J2dTraceLn(J2D_TRACE_INFO, "in X11SurfaceData_XCreateGC");
1551 
1552     xsdo = (X11SDOps *) jlong_to_ptr(pXSData);
1553     if (xsdo == NULL) {
1554         return 0L;
1555     }
1556 
1557     xsdo->javaGC = XCreateGC(awt_display, xsdo->drawable, 0, NULL);
1558     ret = ptr_to_jlong(xsdo->javaGC);
1559 #else /* !HEADLESS */
1560     ret = 0L;
1561 #endif /* !HEADLESS */
1562 
1563     return ret;
1564 }
1565 
1566 /*
1567  * Class:     sun_java2d_x11_X11SurfaceData
1568  * Method:    XResetClip
1569  * Signature: (JIIIILsun/java2d/pipe/Region;)V
1570  */
1571 JNIEXPORT void JNICALL
1572 Java_sun_java2d_x11_XSurfaceData_XResetClip
1573     (JNIEnv *env, jclass xsd, jlong xgc)
1574 {
1575 #ifndef HEADLESS
1576     J2dTraceLn(J2D_TRACE_INFO, "in X11SurfaceData_XResetClip");
1577     XSetClipMask(awt_display, (GC) jlong_to_ptr(xgc), None);
1578 #endif /* !HEADLESS */
1579 }
1580 
1581 /*
1582  * Class:     sun_java2d_x11_X11SurfaceData
1583  * Method:    XSetClip
1584  * Signature: (JIIIILsun/java2d/pipe/Region;)V
1585  */
1586 JNIEXPORT void JNICALL
1587 Java_sun_java2d_x11_XSurfaceData_XSetClip
1588     (JNIEnv *env, jclass xsd, jlong xgc,
1589      jint x1, jint y1, jint x2, jint y2,
1590      jobject complexclip)
1591 {
1592 #ifndef HEADLESS
1593     int numrects;
1594     XRectangle rects[256];
1595     XRectangle *pRect = rects;
1596 
1597     J2dTraceLn(J2D_TRACE_INFO, "in X11SurfaceData_XSetClip");
1598 
1599     numrects = RegionToYXBandedRectangles(env,
1600             x1, y1, x2, y2, complexclip,
1601             &pRect, 256);
1602 
1603     XSetClipRectangles(awt_display, (GC) jlong_to_ptr(xgc), 0, 0, pRect, numrects, YXBanded);
1604 
1605     if (pRect != rects) {
1606         free(pRect);
1607     }
1608 #endif /* !HEADLESS */
1609 }
1610 
1611 /*
1612  * Class:     sun_java2d_x11_X11SurfaceData
1613  * Method:    XSetCopyMode
1614  * Signature: (J)V
1615  */
1616 JNIEXPORT void JNICALL
1617 Java_sun_java2d_x11_X11SurfaceData_XSetCopyMode
1618     (JNIEnv *env, jclass xsd, jlong xgc)
1619 {
1620 #ifndef HEADLESS
1621     J2dTraceLn(J2D_TRACE_INFO, "in X11SurfaceData_XSetCopyMode");
1622     XSetFunction(awt_display, (GC) jlong_to_ptr(xgc), GXcopy);
1623 #endif /* !HEADLESS */
1624 }
1625 
1626 /*
1627  * Class:     sun_java2d_x11_X11SurfaceData
1628  * Method:    XSetXorMode
1629  * Signature: (J)V
1630  */
1631 JNIEXPORT void JNICALL
1632 Java_sun_java2d_x11_X11SurfaceData_XSetXorMode
1633     (JNIEnv *env, jclass xr, jlong xgc)
1634 {
1635 #ifndef HEADLESS
1636     J2dTraceLn(J2D_TRACE_INFO, "in X11SurfaceData_XSetXorMode");
1637     XSetFunction(awt_display, (GC) jlong_to_ptr(xgc), GXxor);
1638 #endif /* !HEADLESS */
1639 }
1640 
1641 /*
1642  * Class:     sun_java2d_x11_X11SurfaceData
1643  * Method:    XSetForeground
1644  * Signature: (JI)V
1645  */
1646 JNIEXPORT void JNICALL
1647 Java_sun_java2d_x11_X11SurfaceData_XSetForeground
1648     (JNIEnv *env, jclass xsd, jlong xgc, jint pixel)
1649 {
1650 #ifndef HEADLESS
1651     J2dTraceLn(J2D_TRACE_INFO, "in X11SurfaceData_XSetForeground");
1652     XSetForeground(awt_display, (GC) jlong_to_ptr(xgc), pixel);
1653 #endif /* !HEADLESS */
1654 }
1655 
1656 /*
1657  * Class:     sun_java2d_x11_X11SurfaceData
1658  * Method:    XSetGraphicsExposures
1659  * Signature: (JZ)V
1660  */
1661 JNIEXPORT void JNICALL
1662 Java_sun_java2d_x11_XSurfaceData_XSetGraphicsExposures
1663     (JNIEnv *env, jclass xsd, jlong xgc, jboolean needExposures)
1664 {
1665 #ifndef HEADLESS
1666     J2dTraceLn(J2D_TRACE_INFO, "in X11SurfaceData_XSetGraphicsExposures");
1667     XSetGraphicsExposures(awt_display, (GC) jlong_to_ptr(xgc), needExposures ? True : False);
1668 #endif /* !HEADLESS */
1669 }
< prev index next >