package com.xixun.lededitor;

import com.xixun.communicate.Define;

import java.io.FileDescriptor;

/**
 * Created by Administrator on 2018/07/04.
 */

public class FrameBuffer {
    static String DeviceName="/dev/graphics/fb0";
    FileDescriptor fileDescriptor=null;
    String deviceName=DeviceName;


    static {
        System.loadLibrary("FrameBuffer");// 在java代码中引入libs目录下的库函数，文件名为【libhello.so】。注意，引入时的文件名要去掉前面的lib和后面的.so
    }

    public FrameBuffer() {
        DeveiceOpen();
    }


    void DeveiceOpen()
    {
        //Define.SetFileAuthority(true,deviceName);
        fileDescriptor=Open(deviceName);
        if (fileDescriptor==null)
            System.out.println("Open Device Fail:"+deviceName);
        else System.out.println("Open Device Success:"+deviceName);
    }

    public int DeveiceWrite(int [] Databuffer,int iOffset,int iLength)
    {
        return Write(Databuffer,iOffset,iLength);
    }


    public native FileDescriptor Open(String deviceName);
    public native int Write(int [] Databuffer,int iOffset,int iLength);
    public native int Close();
}
