| 1 |
/* |
| 2 |
* $Id$ |
| 3 |
* |
| 4 |
* Copyright (C) 2003-2009 JNode.org |
| 5 |
* |
| 6 |
* This library is free software; you can redistribute it and/or modify it |
| 7 |
* under the terms of the GNU Lesser General Public License as published |
| 8 |
* by the Free Software Foundation; either version 2.1 of the License, or |
| 9 |
* (at your option) any later version. |
| 10 |
* |
| 11 |
* This library is distributed in the hope that it will be useful, but |
| 12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 13 |
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
| 14 |
* License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU Lesser General Public License |
| 17 |
* along with this library; If not, write to the Free Software Foundation, Inc., |
| 18 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 |
*/ |
| 20 |
|
| 21 |
package org.jnode.vm; |
| 22 |
|
| 23 |
import org.jnode.annotation.MagicPermission; |
| 24 |
import org.vmmagic.unboxed.Address; |
| 25 |
|
| 26 |
/** |
| 27 |
* The java implementation of {@link org.jnode.vm.VmMultiMediaSupport}. |
| 28 |
* |
| 29 |
* @author Ewout Prangsma (epr@users.sourceforge.net) |
| 30 |
*/ |
| 31 |
@MagicPermission |
| 32 |
final class VmJavaMultiMediaSupport extends VmMultiMediaSupport { |
| 33 |
|
| 34 |
/** |
| 35 |
* @see org.jnode.vm.VmMultiMediaSupport#setARGB32bpp(org.vmmagic.unboxed.Address, org.vmmagic.unboxed.Address, int) |
| 36 |
*/ |
| 37 |
public void setARGB32bpp(Address src, Address dst, int length) { |
| 38 |
for (int i = length; i > 0; i--) { |
| 39 |
final int c = src.loadInt(); |
| 40 |
final int alpha = (c >>> 24) & 0xFF; |
| 41 |
|
| 42 |
if (alpha != 0) { |
| 43 |
final int d = dst.loadInt(); |
| 44 |
final int c1 = c & 0xFF; |
| 45 |
final int c2 = (c >> 8) & 0xFF; |
| 46 |
final int c3 = (c >> 16) & 0xFF; |
| 47 |
final int d1 = d & 0xFF; |
| 48 |
final int d2 = (d >> 8) & 0xFF; |
| 49 |
final int d3 = (d >> 16) & 0xFF; |
| 50 |
final int r1 = (((alpha * (c1 - d1)) >> 8) + d1) & 0xFF; |
| 51 |
final int r2 = (((alpha * (c2 - d2)) >> 8) + d2) & 0xFF; |
| 52 |
final int r3 = (((alpha * (c3 - d3)) >> 8) + d3) & 0xFF; |
| 53 |
dst.store(r1 | (r2 << 8) | (r3 << 16)); |
| 54 |
} |
| 55 |
src = src.add(4); |
| 56 |
dst = dst.add(4); |
| 57 |
} |
| 58 |
} |
| 59 |
} |