当前位置: 首页>>代码示例>>Java>>正文


Java Surface.unlockCanvasAndPost方法代码示例

本文整理汇总了Java中android.view.Surface.unlockCanvasAndPost方法的典型用法代码示例。如果您正苦于以下问题:Java Surface.unlockCanvasAndPost方法的具体用法?Java Surface.unlockCanvasAndPost怎么用?Java Surface.unlockCanvasAndPost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.Surface的用法示例。


在下文中一共展示了Surface.unlockCanvasAndPost方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawCircleSurface

import android.view.Surface; //导入方法依赖的package包/类
/**
 * Clears the surface, then draws a filled circle with a shadow.
 * <p>
 * The Canvas drawing we're doing may not be fully implemented for hardware-accelerated
 * renderers (shadow layers only supported for text).  However, Surface#lockCanvas()
 * currently only returns an unaccelerated Canvas, so it all comes out looking fine.
 */
private void drawCircleSurface(Surface surface, int x, int y, int radius) {
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(Color.WHITE);
    paint.setStyle(Paint.Style.FILL);
    paint.setShadowLayer(radius / 4 + 1, 0, 0, Color.RED);

    Canvas canvas = surface.lockCanvas(null);
    try {
        Log.v(TAG, "drawCircleSurface: isHwAcc=" + canvas.isHardwareAccelerated());
        canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
        canvas.drawCircle(x, y, radius, paint);
    } finally {
        surface.unlockCanvasAndPost(canvas);
    }
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:23,代码来源:MultiSurfaceActivity.java

示例2: initGLComponents

import android.view.Surface; //导入方法依赖的package包/类
@Override
protected synchronized void initGLComponents()
{
    if (mEffect != null) {
    mEffect.initGLComponents();
    int videoTexture = mEffect.getVideoTexture();
    mVideoSurfaceTexture = new SurfaceTexture(videoTexture);
    mVideoSurfaceTexture.setOnFrameAvailableListener(this);
    
    int uiTexture = mEffect.getUIOverlayTexture();
    mUISurfaceTexture = new SurfaceTexture(uiTexture);
    mUISurfaceTexture.setDefaultBufferSize(mViewWidth, mViewHeight);
    mUISurface = new Surface(mUISurfaceTexture);
    try {
        Canvas c = mUISurface.lockCanvas(null);
        c.drawColor(0x0);
        mUISurface.unlockCanvasAndPost(c);
    } catch (Exception e) { }
    }
    notifyInit();
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:22,代码来源:VideoEffectRenderer.java

示例3: drawBouncingCircle

import android.view.Surface; //导入方法依赖的package包/类
/**
 * Clears the surface, then draws a filled circle with a shadow.
 * <p>
 * Similar to drawCircleSurface(), but the position changes based on the value of "i".
 */
private void drawBouncingCircle(Surface surface, int i) {
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(Color.WHITE);
    paint.setStyle(Paint.Style.FILL);

    Canvas canvas = surface.lockCanvas(null);
    try {
        Trace.beginSection("drawBouncingCircle");
        Trace.beginSection("drawColor");
        canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
        Trace.endSection(); // drawColor

        int width = canvas.getWidth();
        int height = canvas.getHeight();
        int radius, x, y;
        if (width < height) {
            // portrait
            radius = width / 4;
            x = width / 4 + ((width / 2 * i) / BOUNCE_STEPS);
            y = height * 3 / 4;
        } else {
            // landscape
            radius = height / 4;
            x = width * 3 / 4;
            y = height / 4 + ((height / 2 * i) / BOUNCE_STEPS);
        }

        paint.setShadowLayer(radius / 4 + 1, 0, 0, Color.RED);

        canvas.drawCircle(x, y, radius, paint);
        Trace.endSection(); // drawBouncingCircle
    } finally {
        surface.unlockCanvasAndPost(canvas);
    }
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:41,代码来源:MultiSurfaceActivity.java

示例4: drawColorBars

import android.view.Surface; //导入方法依赖的package包/类
/**
 * Draw color bars with text labels.
 */
private void drawColorBars(Surface surface) {
    Canvas canvas = surface.lockCanvas(null);
    try {
        // TODO: if the device is in portrait, draw the color bars horizontally.  Right
        // now this only looks good in landscape.
        int width = canvas.getWidth();
        int height = canvas.getHeight();
        int least = Math.min(width, height);

        Log.d(TAG, "Drawing color bars at " + width + "x" + height);

        Paint textPaint = new Paint();
        Typeface typeface = Typeface.defaultFromStyle(Typeface.NORMAL);
        textPaint.setTypeface(typeface);
        textPaint.setTextSize(least / 20);
        textPaint.setAntiAlias(true);

        Paint rectPaint = new Paint();
        for (int i = 0; i < 8; i++) {
            int color = 0xff000000;
            if ((i & 0x01) != 0) {
                color |= 0x00ff0000;
            }
            if ((i & 0x02) != 0) {
                color |= 0x0000ff00;
            }
            if ((i & 0x04) != 0) {
                color |= 0x000000ff;
            }
            rectPaint.setColor(color);

            float sliceWidth = width / 8;
            canvas.drawRect(sliceWidth * i, 0, sliceWidth * (i+1), height, rectPaint);
        }
        rectPaint.setColor(0x80808080);     // ARGB 50/50 grey (non-premul)
        float sliceHeight = height / 8;
        int posn = 6;
        canvas.drawRect(0, sliceHeight * posn, width, sliceHeight * (posn+1), rectPaint);

        // Draw the labels last so they're on top of everything.
        for (int i = 0; i < 8; i++) {
            drawOutlineText(canvas, textPaint, COLOR_NAMES[i],
                    (width / 8) * i + 4, (height / 8) * ((i & 1) + 1));
        }
    } finally {
        surface.unlockCanvasAndPost(canvas);
    }
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:52,代码来源:ColorBarActivity.java


注:本文中的android.view.Surface.unlockCanvasAndPost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。