當前位置: 首頁>>代碼示例>>Java>>正文


Java SurfaceHolder.getSurfaceFrame方法代碼示例

本文整理匯總了Java中android.view.SurfaceHolder.getSurfaceFrame方法的典型用法代碼示例。如果您正苦於以下問題:Java SurfaceHolder.getSurfaceFrame方法的具體用法?Java SurfaceHolder.getSurfaceFrame怎麽用?Java SurfaceHolder.getSurfaceFrame使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.SurfaceHolder的用法示例。


在下文中一共展示了SurfaceHolder.getSurfaceFrame方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: drawFrame

import android.view.SurfaceHolder; //導入方法依賴的package包/類
void drawFrame() {
    final SurfaceHolder holder = getSurfaceHolder();
    final Rect frame = holder.getSurfaceFrame();
    final int width = frame.width();
    final int height = frame.height();

    Canvas c = null;
    try {
        c = holder.lockCanvas();
        if (c != null) {
            // draw something
            drawCube(c);
            drawTouchPoint(c);
        }
    } finally {
        if (c != null) holder.unlockCanvasAndPost(c);
    }

    mHandler.removeCallbacks(mDrawCube);
    if (mVisible) {
        mHandler.postDelayed(mDrawCube, 1000 / 25);
    }
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:24,代碼來源:CubeWallpaper2.java

示例2: surfaceCreated

import android.view.SurfaceHolder; //導入方法依賴的package包/類
@Override
public void surfaceCreated(SurfaceHolder holder) {
    Log.d(TAG, "surfaceCreated holder=" + holder);

    // Grab the view's width.  It's not available before now.
    Rect size = holder.getSurfaceFrame();
    mFullViewWidth = size.width();
    mFullViewHeight = size.height();

    // Configure our fixed-size values.  We want to configure it so that the narrowest
    // dimension (e.g. width when device is in portrait orientation) is equal to the
    // value in SURFACE_DIM, and the other dimension is sized to maintain the same
    // aspect ratio.
    float windowAspect = (float) mFullViewHeight / (float) mFullViewWidth;
    for (int i = 0; i < SURFACE_DIM.length; i++) {
        if (i == SURFACE_SIZE_FULL) {
            // special-case for full size
            mWindowWidthHeight[i][0] = mFullViewWidth;
            mWindowWidthHeight[i][1] = mFullViewHeight;
        } else if (mFullViewWidth < mFullViewHeight) {
            // portrait
            mWindowWidthHeight[i][0] = SURFACE_DIM[i];
            mWindowWidthHeight[i][1] = (int) (SURFACE_DIM[i] * windowAspect);
        } else {
            // landscape
            mWindowWidthHeight[i][0] = (int) (SURFACE_DIM[i] / windowAspect);
            mWindowWidthHeight[i][1] = SURFACE_DIM[i];
        }
    }

    // Some controls include text based on the view dimensions, so update now.
    updateControls();

    SurfaceView sv = (SurfaceView) findViewById(R.id.hardwareScaler_surfaceView);
    mRenderThread = new RenderThread(sv.getHolder());
    mRenderThread.setName("HardwareScaler GL render");
    mRenderThread.start();
    mRenderThread.waitUntilReady();

    RenderHandler rh = mRenderThread.getHandler();
    if (rh != null) {
        rh.sendSetFlatShading(mFlatShadingChecked);
        rh.sendSurfaceCreated();
    }

    // start the draw events
    Choreographer.getInstance().postFrameCallback(this);
}
 
開發者ID:AndyZhu1991,項目名稱:grafika,代碼行數:49,代碼來源:HardwareScalerActivity.java


注:本文中的android.view.SurfaceHolder.getSurfaceFrame方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。