Methods Summary |
---|
public void | addCallback(Callback callback)
synchronized (mCallbacks) {
// This is a linear search, but in practice we'll
// have only a couple callbacks, so it doesn't matter.
if (mCallbacks.contains(callback) == false) {
mCallbacks.add(callback);
}
}
|
public SurfaceHolder.Callback[] | getCallbacks()
if (mHaveGottenCallbacks) {
return mGottenCallbacks;
}
synchronized (mCallbacks) {
final int N = mCallbacks.size();
if (N > 0) {
if (mGottenCallbacks == null || mGottenCallbacks.length != N) {
mGottenCallbacks = new SurfaceHolder.Callback[N];
}
mCallbacks.toArray(mGottenCallbacks);
} else {
mGottenCallbacks = null;
}
mHaveGottenCallbacks = true;
}
return mGottenCallbacks;
|
public int | getRequestedFormat()
return mRequestedFormat;
|
public int | getRequestedHeight()
return mRequestedHeight;
|
public int | getRequestedType()
return mRequestedType;
|
public int | getRequestedWidth()
return mRequestedWidth;
|
public android.view.Surface | getSurface()
return mSurface;
|
public android.graphics.Rect | getSurfaceFrame()
return mSurfaceFrame;
|
private final android.graphics.Canvas | internalLockCanvas(android.graphics.Rect dirty)
if (mType == SURFACE_TYPE_PUSH_BUFFERS) {
throw new BadSurfaceTypeException(
"Surface type is SURFACE_TYPE_PUSH_BUFFERS");
}
mSurfaceLock.lock();
if (DEBUG) Log.i(TAG, "Locking canvas..,");
Canvas c = null;
if (onAllowLockCanvas()) {
if (dirty == null) {
if (mTmpDirty == null) {
mTmpDirty = new Rect();
}
mTmpDirty.set(mSurfaceFrame);
dirty = mTmpDirty;
}
try {
c = mSurface.lockCanvas(dirty);
} catch (Exception e) {
Log.e(TAG, "Exception locking surface", e);
}
}
if (DEBUG) Log.i(TAG, "Returned canvas: " + c);
if (c != null) {
mLastLockTime = SystemClock.uptimeMillis();
return c;
}
// If the Surface is not ready to be drawn, then return null,
// but throttle calls to this function so it isn't called more
// than every 100ms.
long now = SystemClock.uptimeMillis();
long nextTime = mLastLockTime + 100;
if (nextTime > now) {
try {
Thread.sleep(nextTime-now);
} catch (InterruptedException e) {
}
now = SystemClock.uptimeMillis();
}
mLastLockTime = now;
mSurfaceLock.unlock();
return null;
|
public android.graphics.Canvas | lockCanvas()
return internalLockCanvas(null);
|
public android.graphics.Canvas | lockCanvas(android.graphics.Rect dirty)
return internalLockCanvas(dirty);
|
public abstract boolean | onAllowLockCanvas()
|
public abstract void | onRelayoutContainer()
|
public abstract void | onUpdateSurface()
|
public void | removeCallback(Callback callback)
synchronized (mCallbacks) {
mCallbacks.remove(callback);
}
|
public void | setFixedSize(int width, int height)
if (mRequestedWidth != width || mRequestedHeight != height) {
mRequestedWidth = width;
mRequestedHeight = height;
onRelayoutContainer();
}
|
public void | setFormat(int format)
if (mRequestedFormat != format) {
mRequestedFormat = format;
onUpdateSurface();
}
|
public void | setSizeFromLayout()
if (mRequestedWidth != -1 || mRequestedHeight != -1) {
mRequestedWidth = mRequestedHeight = -1;
onRelayoutContainer();
}
|
public void | setSurfaceFrameSize(int width, int height)
mSurfaceFrame.top = 0;
mSurfaceFrame.left = 0;
mSurfaceFrame.right = width;
mSurfaceFrame.bottom = height;
|
public void | setType(int type)
switch (type) {
case SURFACE_TYPE_HARDWARE:
case SURFACE_TYPE_GPU:
// these are deprecated, treat as "NORMAL"
type = SURFACE_TYPE_NORMAL;
break;
}
switch (type) {
case SURFACE_TYPE_NORMAL:
case SURFACE_TYPE_PUSH_BUFFERS:
if (mRequestedType != type) {
mRequestedType = type;
onUpdateSurface();
}
break;
}
|
public void | ungetCallbacks()
mHaveGottenCallbacks = false;
|
public void | unlockCanvasAndPost(android.graphics.Canvas canvas)
mSurface.unlockCanvasAndPost(canvas);
mSurfaceLock.unlock();
|