src/share/classes/sun/swing/LightweightContent.java
Print this page
@@ -83,35 +83,57 @@
/**
* {@code JLightweightFrame} calls this method to notify the client
* application that a new data buffer has been set as a content pixel
* buffer. Typically this occurs when a buffer of a larger size is
- * created in response to a content resize event. The method reports
- * a reference to the pixel data buffer, the content image bounds
- * within the buffer and the line stride of the buffer. These values
- * have the following correlation.
+ * created in response to a content resize event.
* <p>
- * The {@code width} and {@code height} matches the size of the content
+ * The method reports a reference to the pixel data buffer, the content
+ * image bounds within the buffer and the line stride of the buffer.
+ * These values have the following correlation.
+ * The {@code width} and {@code height} matches the layout size of the content
* (the component returned from the {@link #getComponent} method). The
* {@code x} and {@code y} is the origin of the content, {@code (0, 0)}
- * in the coordinate space of the content, appearing at
- * {@code data[y * linestride + x]} in the buffer. All indices
- * {@code data[(y + j) * linestride + (x + i)]} where
- * {@code (0 <= i < width)} and {@code (0 <= j < height)} will represent
- * valid pixel data, {@code (i, j)} in the coordinate space of the content.
+ * in the layout coordinate space of the content, appearing at
+ * {@code data[y * scale * linestride + x * scale]} in the buffer.
+ * A pixel with indices {@code (i, j)}, where {@code (0 <= i < width)} and
+ * {@code (0 <= j < height)}, in the layout coordinate space of the content
+ * is represented by a {@code scale^2} square of pixels in the physical
+ * coordinate space of the buffer. The top-left corner of the square has the
+ * following physical coordinate in the buffer:
+ * {@code data[(y + j) * scale * linestride + (x + i) * scale]}.
*
* @param data the content pixel data buffer of INT_ARGB_PRE type
- * @param x the x coordinate of the image
- * @param y the y coordinate of the image
- * @param width the width of the image
- * @param height the height of the image
+ * @param x the logical x coordinate of the image
+ * @param y the logical y coordinate of the image
+ * @param width the logical width of the image
+ * @param height the logical height of the image
* @param linestride the line stride of the pixel buffer
+ * @param scale the scale factor of the pixel buffer
+ */
+ default public void imageBufferReset(int[] data,
+ int x, int y,
+ int width, int height,
+ int linestride,
+ int scale)
+ {
+ imageBufferReset(data, x, y, width, height, linestride);
+ }
+
+ /**
+ * The default implementation for #imageBufferReset uses a hard-coded value
+ * of 1 for the scale factor. Both the old and the new methods provide
+ * default implementations in order to allow a client application to run
+ * with any JDK version without breaking backward compatibility.
*/
- public void imageBufferReset(int[] data,
+ default public void imageBufferReset(int[] data,
int x, int y,
int width, int height,
- int linestride);
+ int linestride)
+ {
+ imageBufferReset(data, x, y, width, height, linestride, 1);
+ }
/**
* {@code JLightweightFrame} calls this method to notify the client
* application that the content image bounds have been changed within the
* image's pixel buffer.