[libbluray-devel] BDGraphics: implement copyArea()
Ian Curtis
git at videolan.org
Wed Mar 19 15:55:07 CET 2014
libbluray | branch: master | Ian Curtis <i.curtis at gmail.com> | Wed Mar 19 16:19:05 2014 +0200| [b56992a204de1605c2a7b986845dd0142dc43a16] | committer: hpi1
BDGraphics: implement copyArea()
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=b56992a204de1605c2a7b986845dd0142dc43a16
---
.../bdj/java-j2me/java/awt/BDGraphics.java | 32 +++++++++++++++++---
.../bdj/java-j2se/java/awt/BDGraphics.java | 32 +++++++++++++++++---
2 files changed, 56 insertions(+), 8 deletions(-)
diff --git a/src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java b/src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java
index c29a6f0..a3e47a0 100644
--- a/src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java
+++ b/src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java
@@ -519,10 +519,34 @@ class BDGraphics extends Graphics2D implements ConstrainableGraphics {
* @param dx the horizontal distance to copy the pixels.
* @param dy the vertical distance to copy the pixels.
*/
- public void copyArea(int X, int Y, int W, int H, int dx, int dy) {
- X += originX;
- Y += originY;
- logger.unimplemented("copyArea");
+ public void copyArea(int x, int y, int w, int h, int dx, int dy) {
+
+ x += originX;
+ y += originY;
+
+ Rectangle rect = new Rectangle(x, y, w, h);
+ rect = actualClip.intersection(rect);
+
+ if (rect.width <= 0 || rect.height <= 0) {
+ return;
+ }
+
+ x = rect.x;
+ y = rect.y;
+ w = rect.width;
+ h = rect.height;
+
+ int subImage[] = new int[w * h];
+
+ // copy back buffer
+ for (int i = 0; i < h; i++) {
+ System.arraycopy(backBuffer, ((y + i) * width) + x, subImage, w * i, w);
+ }
+
+ // draw sub image
+ for (int i = 0; i < h; i++) {
+ drawSpanN(x + dx, y + i + dy, w, subImage, w * i);
+ }
}
/** Draws lines defined by an array of x points and y points */
diff --git a/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java b/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java
index 6a841f2..1d7d747 100644
--- a/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java
+++ b/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java
@@ -601,10 +601,34 @@ class BDGraphics extends Graphics2D implements ConstrainableGraphics {
* @param dx the horizontal distance to copy the pixels.
* @param dy the vertical distance to copy the pixels.
*/
- public void copyArea(int X, int Y, int W, int H, int dx, int dy) {
- X += originX;
- Y += originY;
- logger.unimplemented("copyArea");
+ public void copyArea(int x, int y, int w, int h, int dx, int dy) {
+
+ x += originX;
+ y += originY;
+
+ Rectangle rect = new Rectangle(x, y, w, h);
+ rect = actualClip.intersection(rect);
+
+ if (rect.width <= 0 || rect.height <= 0) {
+ return;
+ }
+
+ x = rect.x;
+ y = rect.y;
+ w = rect.width;
+ h = rect.height;
+
+ int subImage[] = new int[w * h];
+
+ // copy back buffer
+ for (int i = 0; i < h; i++) {
+ System.arraycopy(backBuffer, ((y + i) * width) + x, subImage, w * i, w);
+ }
+
+ // draw sub image
+ for (int i = 0; i < h; i++) {
+ drawSpanN(x + dx, y + i + dy, w, subImage, w * i);
+ }
}
/** Draws lines defined by an array of x points and y points */
More information about the libbluray-devel
mailing list