1 /*
2 * Copyright (c) 2011, 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
427 throw new UnsupportedOperationException("Alpha image is not supported as an image pattern.");
428 } else {
429 final Transform6 piscesTx = swPaint.computeSetTexturePaintTransform(this.paint, this.tx, this.nodeBounds, x, y, width, height);
430 final SWArgbPreTexture tex = context.validateImagePaintTexture(ip.getImage().getWidth(), ip.getImage().getHeight());
431 tex.update(ip.getImage());
432
433 final float compositeAlpha = swPaint.getCompositeAlpha();
434 final int imageMode;
435 if (compositeAlpha == 1f) {
436 imageMode = RendererBase.IMAGE_MODE_NORMAL;
437 } else {
438 imageMode = RendererBase.IMAGE_MODE_MULTIPLY;
439 this.pr.setColor(255, 255, 255, (int)(255 * compositeAlpha));
440 }
441
442 this.pr.drawImage(RendererBase.TYPE_INT_ARGB_PRE, imageMode,
443 tex.getDataNoClone(), tex.getContentWidth(), tex.getContentHeight(),
444 tex.getOffset(), tex.getPhysicalWidth(),
445 piscesTx,
446 tex.getWrapMode() == Texture.WrapMode.REPEAT,
447 (int)(Math.min(p1.x, p2.x) * SWUtils.TO_PISCES), (int)(Math.min(p1.y, p2.y) * SWUtils.TO_PISCES),
448 (int)(Math.abs(p2.x - p1.x) * SWUtils.TO_PISCES), (int)(Math.abs(p2.y - p1.y) * SWUtils.TO_PISCES),
449 RendererBase.IMAGE_FRAC_EDGE_KEEP, RendererBase.IMAGE_FRAC_EDGE_KEEP,
450 RendererBase.IMAGE_FRAC_EDGE_KEEP, RendererBase.IMAGE_FRAC_EDGE_KEEP,
451 0, 0, tex.getContentWidth()-1, tex.getContentHeight()-1,
452 tex.hasAlpha());
453 }
454 } else {
455 swPaint.setPaintFromShape(this.paint, this.tx, null, this.nodeBounds, x, y, width, height);
456 this.pr.fillRect((int)(Math.min(p1.x, p2.x) * SWUtils.TO_PISCES), (int)(Math.min(p1.y, p2.y) * SWUtils.TO_PISCES),
457 (int)(Math.abs(p2.x - p1.x) * SWUtils.TO_PISCES), (int)(Math.abs(p2.y - p1.y) * SWUtils.TO_PISCES));
458 }
459 } else {
460 this.fillRoundRect(x, y, width, height, 0, 0);
461 }
462 }
463
464 public void fillRoundRect(float x, float y, float width, float height,
465 float arcw, float arch) {
466 if (PrismSettings.debug) {
722
723 if (PrismSettings.debug) {
724 System.out.println("tx: " + tx);
725 System.out.println("piscesTx: " + piscesTx);
726
727 System.out.println("srcBBox: " + srcBBox);
728 System.out.println("dstBBox: " + dstBBox);
729 }
730
731 // texture coordinates range
732 final int txMin = Math.max(0, SWUtils.fastFloor(Math.min(sx1, sx2)));
733 final int tyMin = Math.max(0, SWUtils.fastFloor(Math.min(sy1, sy2)));
734 final int txMax = Math.min(tex.getContentWidth() - 1, SWUtils.fastCeil(Math.max(sx1, sx2)) - 1);
735 final int tyMax = Math.min(tex.getContentHeight() - 1, SWUtils.fastCeil(Math.max(sy1, sy2)) - 1);
736
737 this.pr.drawImage(RendererBase.TYPE_INT_ARGB_PRE, imageMode,
738 data, tex.getContentWidth(), tex.getContentHeight(),
739 swTex.getOffset(), tex.getPhysicalWidth(),
740 piscesTx,
741 tex.getWrapMode() == Texture.WrapMode.REPEAT,
742 (int)(SWUtils.TO_PISCES * dstBBox.getMinX()), (int)(SWUtils.TO_PISCES * dstBBox.getMinY()),
743 (int)(SWUtils.TO_PISCES * dstBBox.getWidth()), (int)(SWUtils.TO_PISCES * dstBBox.getHeight()),
744 lEdge, rEdge, tEdge, bEdge,
745 txMin, tyMin, txMax, tyMax,
746 swTex.hasAlpha());
747
748 if (PrismSettings.debug) {
749 System.out.println("* drawTexture, DONE");
750 }
751 }
752
753 @Override
754 public void drawTexture3SliceH(Texture tex,
755 float dx1, float dy1, float dx2, float dy2,
756 float sx1, float sy1, float sx2, float sy2,
757 float dh1, float dh2, float sh1, float sh2)
758 {
759 drawTexture(tex, dx1, dy1, dh1, dy2, sx1, sy1, sh1, sy2,
760 RendererBase.IMAGE_FRAC_EDGE_KEEP, RendererBase.IMAGE_FRAC_EDGE_PAD,
761 RendererBase.IMAGE_FRAC_EDGE_KEEP, RendererBase.IMAGE_FRAC_EDGE_KEEP);
|
1 /*
2 * Copyright (c) 2011, 2018, 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
427 throw new UnsupportedOperationException("Alpha image is not supported as an image pattern.");
428 } else {
429 final Transform6 piscesTx = swPaint.computeSetTexturePaintTransform(this.paint, this.tx, this.nodeBounds, x, y, width, height);
430 final SWArgbPreTexture tex = context.validateImagePaintTexture(ip.getImage().getWidth(), ip.getImage().getHeight());
431 tex.update(ip.getImage());
432
433 final float compositeAlpha = swPaint.getCompositeAlpha();
434 final int imageMode;
435 if (compositeAlpha == 1f) {
436 imageMode = RendererBase.IMAGE_MODE_NORMAL;
437 } else {
438 imageMode = RendererBase.IMAGE_MODE_MULTIPLY;
439 this.pr.setColor(255, 255, 255, (int)(255 * compositeAlpha));
440 }
441
442 this.pr.drawImage(RendererBase.TYPE_INT_ARGB_PRE, imageMode,
443 tex.getDataNoClone(), tex.getContentWidth(), tex.getContentHeight(),
444 tex.getOffset(), tex.getPhysicalWidth(),
445 piscesTx,
446 tex.getWrapMode() == Texture.WrapMode.REPEAT,
447 tex.getLinearFiltering(),
448 (int)(Math.min(p1.x, p2.x) * SWUtils.TO_PISCES), (int)(Math.min(p1.y, p2.y) * SWUtils.TO_PISCES),
449 (int)(Math.abs(p2.x - p1.x) * SWUtils.TO_PISCES), (int)(Math.abs(p2.y - p1.y) * SWUtils.TO_PISCES),
450 RendererBase.IMAGE_FRAC_EDGE_KEEP, RendererBase.IMAGE_FRAC_EDGE_KEEP,
451 RendererBase.IMAGE_FRAC_EDGE_KEEP, RendererBase.IMAGE_FRAC_EDGE_KEEP,
452 0, 0, tex.getContentWidth()-1, tex.getContentHeight()-1,
453 tex.hasAlpha());
454 }
455 } else {
456 swPaint.setPaintFromShape(this.paint, this.tx, null, this.nodeBounds, x, y, width, height);
457 this.pr.fillRect((int)(Math.min(p1.x, p2.x) * SWUtils.TO_PISCES), (int)(Math.min(p1.y, p2.y) * SWUtils.TO_PISCES),
458 (int)(Math.abs(p2.x - p1.x) * SWUtils.TO_PISCES), (int)(Math.abs(p2.y - p1.y) * SWUtils.TO_PISCES));
459 }
460 } else {
461 this.fillRoundRect(x, y, width, height, 0, 0);
462 }
463 }
464
465 public void fillRoundRect(float x, float y, float width, float height,
466 float arcw, float arch) {
467 if (PrismSettings.debug) {
723
724 if (PrismSettings.debug) {
725 System.out.println("tx: " + tx);
726 System.out.println("piscesTx: " + piscesTx);
727
728 System.out.println("srcBBox: " + srcBBox);
729 System.out.println("dstBBox: " + dstBBox);
730 }
731
732 // texture coordinates range
733 final int txMin = Math.max(0, SWUtils.fastFloor(Math.min(sx1, sx2)));
734 final int tyMin = Math.max(0, SWUtils.fastFloor(Math.min(sy1, sy2)));
735 final int txMax = Math.min(tex.getContentWidth() - 1, SWUtils.fastCeil(Math.max(sx1, sx2)) - 1);
736 final int tyMax = Math.min(tex.getContentHeight() - 1, SWUtils.fastCeil(Math.max(sy1, sy2)) - 1);
737
738 this.pr.drawImage(RendererBase.TYPE_INT_ARGB_PRE, imageMode,
739 data, tex.getContentWidth(), tex.getContentHeight(),
740 swTex.getOffset(), tex.getPhysicalWidth(),
741 piscesTx,
742 tex.getWrapMode() == Texture.WrapMode.REPEAT,
743 tex.getLinearFiltering(),
744 (int)(SWUtils.TO_PISCES * dstBBox.getMinX()), (int)(SWUtils.TO_PISCES * dstBBox.getMinY()),
745 (int)(SWUtils.TO_PISCES * dstBBox.getWidth()), (int)(SWUtils.TO_PISCES * dstBBox.getHeight()),
746 lEdge, rEdge, tEdge, bEdge,
747 txMin, tyMin, txMax, tyMax,
748 swTex.hasAlpha());
749
750 if (PrismSettings.debug) {
751 System.out.println("* drawTexture, DONE");
752 }
753 }
754
755 @Override
756 public void drawTexture3SliceH(Texture tex,
757 float dx1, float dy1, float dx2, float dy2,
758 float sx1, float sy1, float sx2, float sy2,
759 float dh1, float dh2, float sh1, float sh2)
760 {
761 drawTexture(tex, dx1, dy1, dh1, dy2, sx1, sy1, sh1, sy2,
762 RendererBase.IMAGE_FRAC_EDGE_KEEP, RendererBase.IMAGE_FRAC_EDGE_PAD,
763 RendererBase.IMAGE_FRAC_EDGE_KEEP, RendererBase.IMAGE_FRAC_EDGE_KEEP);
|