Android的suiface類原始碼深度剖析

2021-08-26 10:37:02 字數 2957 閱讀 6287

su***ce用來處理一段單獨的緩衝區,這段緩衝區是由螢幕合成器來管理的。

su***ce 包含安全的內容,使用一些特殊的措施來阻止在其他的程序中複製su***ce內容。尤其是截圖和vnc服務。su***ce不能被硬體加速。它建立的緩衝區有幾種:buffers,normal,blur,dim。

當su***ce不能被建立或更改大小時候,系統會丟擲異常。su***ce建立過程中,建立了乙個畫布,並且在之後的程式設計中我們可以使用。我們可以鎖定或解鎖乙個su***ce,但解鎖時,只有呼叫post()或postall() 是才會更新螢幕。

原始碼:package android.view;

import android.graphics.*;

import android.os.parcelable;

import android.os.parcel;

import android.util.log;

public class su***ce implements parcelable

public outofresource***ception(string name) }

native private static void nativeclassinit();

static

public su***ce(su***cesession s,

int pid, int display, int w, int h, int format, int flags)

throws outofresource***ception

public su***ce()

public native void copyfrom(su***ce o);

public native boolean isvalid();

public native void clear();

public canvas lockcanvas(rect dirty) throws outofresource***ception

private native canvas lockcanvasnative(rect dirty);

public native void unlockcanvasandpost(canvas canvas);

public native void unlockcanvas(canvas canvas);

public static native void opentransaction();

public static native void closetransaction();

public static native void freezedisplay(int display);

public static native void unfreezedisplay(int display);

public static native void setorientation(int display, int orientation, int flags);

public static void setorientation(int display, int orientation)

public native void setlayer(int zorder);

public native void setposition(int x, int y);

public native void setsize(int w, int h);

public native void hide();

public native void show();

public native void settransparentregionhint(region region);

public native void setalpha(float alpha);

public native void setmatrix(float dsdx, float dtdx,

float dsdy, float dtdy);

public native void freeze();

public native void unfreeze();

public native void setfreezetint(int tint);

public native void setflags(int flags, int mask);

@override

public string tostring()

private su***ce(parcel source) throws outofresource***ception

public int describecontents()

public native void readfromparcel(parcel source);

public native void writetoparcel(parcel dest, int flags);

public static final parcelable.creatorcreator

= new parcelable.creator()

catch (exception e)

return null;}

public su***ce newarray(int size) };

/* no user serviceable parts here ... */

@override

protected void finalize() throws throwable

private native void init(su***cesession s,

int pid, int display, int w, int h, int format, int flags)

throws outofresource***ception;

private native void init(parcel source);}

Android之推薦看的Android原始碼

handler message looper handler被稱為 非同步提交器 是android開發入門教程必定談及的東西,這也是activity等元件的工作機制需要用到的東西,是 資料驅動 框架的重要組成,作為閱讀原始碼的入門最適合不過。activity和service 作為經常使用到的元件,閱...

Android的MediaRecorder錄影模糊

原來的寫法 next codes is right for 2.3 and 4.0 mmediarecorder new mediarecorder mmediarecorder.setvideosource mediarecorder.videosource.default 設定音訊源 mmedi...

Android的PagerAdapter類簡介

pageradapter簡介 pageradapter是android.support.v4包中的類,它的子類有fragmentpageradapter,fragmentstatepageradapter,這兩個adapter都是fragment的介面卡,用於實現fragment的滑動效果,page...