`

surfaceview

 
阅读更多
/**
* Provides a dedicated drawing surface embedded inside of a view hierarchy.
* You can control the format of this surface and, if you like, its size; the
* SurfaceView takes care of placing the surface at the correct location on the
* screen
*
* <p>The surface is Z ordered so that it is behind the window holding its
* SurfaceView; the SurfaceView punches a hole in its window to allow its
* surface to be displayed. The view hierarchy will take care of correctly
* compositing with the Surface any siblings of the SurfaceView that would
* normally appear on top of it. This can be used to place overlays such as
* buttons on top of the Surface, though note however that it can have an
* impact on performance since a full alpha-blended composite will be performed
* each time the Surface changes.
*
* <p> The transparent region that makes the surface visible is based on the
* layout positions in the view hierarchy. If the post-layout transform
* properties are used to draw a sibling view on top of the SurfaceView, the
* view may not be properly composited with the surface.
*
* <p>Access to the underlying surface is provided via the SurfaceHolder interface,
* which can be retrieved by calling {@link #getHolder}.
*
* <p>The Surface will be created for you while the SurfaceView's window is
* visible; you should implement {@link SurfaceHolder.Callback#surfaceCreated}
* and {@link SurfaceHolder.Callback#surfaceDestroyed} to discover when the
* Surface is created and destroyed as the window is shown and hidden.
*
* <p>One of the purposes of this class is to provide a surface in which a
* secondary thread can render into the screen. If you are going to use it
* this way, you need to be aware of some threading semantics:
*
* <ul>
* <li> All SurfaceView and
* {@link SurfaceHolder.Callback SurfaceHolder.Callback} methods will be called
* from the thread running the SurfaceView's window (typically the main thread
* of the application). They thus need to correctly synchronize with any
* state that is also touched by the drawing thread.
* <li> You must ensure that the drawing thread only touches the underlying
* Surface while it is valid -- between
* {@link SurfaceHolder.Callback#surfaceCreated SurfaceHolder.Callback.surfaceCreated()}
* and
* {@link SurfaceHolder.Callback#surfaceDestroyed SurfaceHolder.Callback.surfaceDestroyed()}.
* </ul>
*/


   @Override
    public void draw(Canvas canvas) {
        if (mWindowType != WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) {
            // draw() is not called when SKIP_DRAW is set
            if ((mPrivateFlags & PFLAG_SKIP_DRAW) == 0) {
                // punch a whole in the view-hierarchy below us
                canvas.drawColor(0, PorterDuff.Mode.CLEAR);
            }
        }
        super.draw(canvas);
    }
分享到:
评论

相关推荐

    SurfaceView

    在Android平台上进行游戏开发时,SurfaceView是一个至关重要的组件,它是专门为高性能图形设计的,比如游戏、视频播放等需要连续刷新显示的应用。SurfaceView提供了一种优化的绘图机制,可以将绘制操作与应用程序的...

    Android中SurfaceView截屏

    在Android开发中,`SurfaceView`是一个非常重要的视图组件,尤其在处理视频播放、游戏渲染等高性能图形操作时,它的优势在于拥有独立于主线程的渲染机制,能避免阻塞UI更新。然而,由于其特殊的性质,直接通过常规...

    android surfaceview 悬浮窗圆角 windowmanager

    在Android开发中,`SurfaceView`是一个特殊类型的`View`,它允许开发者在应用程序中创建一个独立于应用程序主线程的渲染表面。`SurfaceView`通常用于处理高性能的图形或者视频播放,因为它可以在单独的线程中进行...

    最简单的surfaceview画图和截图

    SurfaceView是Android系统提供的一种特殊的View,主要用于处理高性能、低延迟的图形绘制,例如游戏画面或者视频播放等场景。它的核心特性在于拥有自己的独立线程(SurfaceThread)来管理Surface的绘制,这使得...

    Android下使用SurfaceView播放视频文件

    在Android平台上,SurfaceView是一种特殊的视图,常用于处理高性能的图形渲染,比如播放视频或者游戏画面。在视频播放场景中,SurfaceView提供了一个高效且低延迟的显示机制,能够将视频帧直接绘制到Surface上,减少...

    在surfaceview上放置控件

    在Android开发中,SurfaceView是一种特殊的视图,主要用于处理高性能的图形绘制,比如视频播放、游戏画面等。SurfaceView创建了一个独立的Surface,其后台线程可以无阻塞地进行绘图操作,提高了渲染效率。然而,由于...

    Android SurfaceView 实现图片缩放 滑动

    在Android开发中,SurfaceView是一种特殊的视图,它允许开发者创建高性能的图形界面,尤其适合处理视频播放或游戏等需要连续刷新的场景。本话题主要探讨如何利用SurfaceView实现图片的缩放和滑动功能。 首先,理解...

    SurfaceView播放视频放大缩小功能.zip

    在Android开发中,SurfaceView是一种特殊的视图,用于处理高性能的图形和视频渲染。这个压缩包文件"SurfaceView播放视频放大缩小功能.zip"显然包含了实现SurfaceView在播放视频时进行放大和缩小功能的相关代码和资源...

    surfaceview 多点触控移动放大缩小

    SurfaceView是Android系统中一种特殊的View,它在处理多媒体或者高性能图形渲染时有着独特的优势。在移动设备上,用户交互通常涉及到触摸事件,包括单点触摸和多点触控。多点触控允许用户通过两个或更多的手指进行...

    SurfaceView增加放大缩小视频功能

    在Android开发中,`SurfaceView` 是一个非常重要的视图组件,主要用于处理视频播放、游戏图形等高性能的图像渲染任务。`SurfaceView` 提供了一个独立的绘图表面,可以与应用程序主线程分离,从而避免UI阻塞,提高...

    Android圆形相机预览窗口,圆形SurfaceView

    这个场景就涉及到了Android的SurfaceView以及如何定制它的显示效果。本文将深入探讨如何实现一个圆形的相机预览窗口。 首先,让我们理解SurfaceView的基本概念。SurfaceView是Android系统提供的一种用于显示多媒体...

    Android SurfaceView 实现实时显示摄像头视频

    `SurfaceView`是Android提供的一种用于高效显示多媒体数据的视图组件,尤其适合处理像视频流这样的实时数据。本篇文章将深入探讨如何利用`SurfaceView`实现实时显示摄像头视频。 首先,我们需要了解`SurfaceView`的...

    Android_surfaceView与layout屏幕适配总结

    本篇文章将深入探讨`SurfaceView`与`layout`在屏幕适配中的应用及其策略。 首先,`SurfaceView`是Android提供的一种特殊视图,它允许开发者在应用程序中直接进行硬件加速的图形绘制,如视频播放、游戏画面等高性能...

    SurfaceView放大和缩小

    在Android开发中,SurfaceView是一种特殊的视图,用于高效地显示动态图像,比如播放视频或者进行游戏渲染。标题“SurfaceView放大和缩小”涉及到的是如何在Android应用中实现对SurfaceView内的视频画面进行局部放大...

    SurfaceView视频播放功能

    SurfaceView是Android系统中一种特殊的View,主要用于处理高性能、低延迟的图形绘制和视频播放等任务。在Android应用开发中,尤其是涉及到视频播放时,SurfaceView是一个非常关键的组件。这个例子是基于SurfaceView...

    Android中TextureView与SurfaceView用法区别总结

    SurfaceView和TextureView均继承于android.view.View 与其它View不同的是,两者都能在独立的线程中绘制和渲染,在专用的GPU线程中大大提高渲染的性能。 一、SurfaceView专门提供了嵌入视图层级的绘制界面,开发者...

    DrawImage SurfaceView 多层绘制透明图

    在Android开发中,`SurfaceView`是一个特殊类型的视图,常用于处理高性能的图形和视频渲染,例如游戏或相机预览。它拥有自己的独立于主线程的渲染表面,可以提供流畅的动画效果,且对CPU和GPU资源的利用更为高效。`...

Global site tag (gtag.js) - Google Analytics