| 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.system.MultiMediaMemoryResource; |
| 24 |
import org.jnode.annotation.MagicPermission; |
| 25 |
import org.vmmagic.unboxed.Address; |
| 26 |
|
| 27 |
/** |
| 28 |
* Implementation class for {@link org.jnode.system.MultiMediaMemoryResource}. |
| 29 |
* |
| 30 |
* @author Ewout Prangsma (epr@users.sourceforge.net) |
| 31 |
*/ |
| 32 |
@MagicPermission |
| 33 |
final class MultiMediaMemoryResourceImpl extends MemoryResourceImpl implements |
| 34 |
MultiMediaMemoryResource { |
| 35 |
|
| 36 |
/** |
| 37 |
* The multi media support class |
| 38 |
*/ |
| 39 |
private final VmMultiMediaSupport multiMediaSupport; |
| 40 |
|
| 41 |
/** |
| 42 |
* @param parent |
| 43 |
* @param owner |
| 44 |
* @param start |
| 45 |
* @param size |
| 46 |
*/ |
| 47 |
public MultiMediaMemoryResourceImpl(MemoryResourceImpl parent, |
| 48 |
VmMultiMediaSupport mmSupport) { |
| 49 |
super(parent, parent.getOwner(), parent.getAddress(), parent.getSize()); |
| 50 |
this.multiMediaSupport = mmSupport; |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* @see org.jnode.system.MultiMediaMemoryResource#setARGB32bpp(int[], int, int, int) |
| 55 |
*/ |
| 56 |
public final void setARGB32bpp(int[] src, int srcOfs, int dstPtr, int length) { |
| 57 |
if (srcOfs < 0) { |
| 58 |
throw new IndexOutOfBoundsException("srcOfs < 0"); |
| 59 |
} |
| 60 |
if (length < 0) { |
| 61 |
throw new IndexOutOfBoundsException("length < 0"); |
| 62 |
} |
| 63 |
if (srcOfs + length > src.length) { |
| 64 |
throw new IndexOutOfBoundsException("dstOfs + length > dst.length"); |
| 65 |
} |
| 66 |
testMemPtr(dstPtr, length * 4); |
| 67 |
final Address srcPtr = VmMagic.getArrayData(src).add(srcOfs * 4); |
| 68 |
multiMediaSupport.setARGB32bpp(srcPtr, start.add(dstPtr), length); |
| 69 |
} |
| 70 |
} |