码迷,mamicode.com
首页 > 其他好文 > 详细

surface 译

时间:2014-06-13 18:33:45      阅读:399      评论:0      收藏:0      [点我收藏+]

标签:des   android   style   class   code   java   

public                   class 公共类

Surface

    extends Object
     
          implements               Parcelable       
                            
                                                
java.lang.Object
   ? android.view.Surface

Class Overview类的概述


Handle onto a raw buffer that is being managed by the screen compositor.被屏幕合成器所管理的 原生缓冲区 的句柄。

Summary


                                 
Nested Classes内嵌的类
                                          class

Surface.OutOfResourcesException

surface没有资源异常

Exception thrown when a Canvas couldn‘t be locked with lockCanvas(Rect), or when a SurfaceTexture could not successfully be allocated. 

当一个canvas不能通过lockCanvas(Rect)被锁定时,或者一个SurfaceTexture不能成功的被分配。

                                                                                                                                                                   
Constants常量
int ROTATION_0 Rotation constant: 0 degree rotation (natural orientation)
int ROTATION_180 Rotation constant: 180 degree rotation.
int ROTATION_270 Rotation constant: 270 degree rotation.
int ROTATION_90 Rotation constant: 90 degree rotation.
[Expand]
Inherited Constants
bubuko.com,布布扣From interface android.os.Parcelable
 
                                                       
Fields
          public           static           final           Creator<Surface> CREATOR  
                   
Public Constructors公共构造方法
                                                                               

        Surface(SurfaceTexture surfaceTexture)               

  从一个SurfaceTexture中创建surface  

Create Surface from a SurfaceTexture.

 
                                                                                                                                                                                   
Public Methods公共方法
                                                                        int        

        describeContents()             

描述在这个Parcelables 马歇尔陈述中包含的各种对象

Describe the kinds of special objects contained in this Parcelable‘s marshalled representation.
                                                                        boolean        

        isValid()              

  如果这个对象持有一个有效的surface,则返回true。

Returns true if this object holds a valid surface.
 
                                                                        Canvas        

        lockCanvas(Rect inOutDirty)                

获取一张画布用来向这个surface中画画。

Gets a Canvas for drawing into this surface.
                                                                        void        

        readFromParcel(Parcel source)        

从打包中读取数据(打包数据源)

                                                                        void        

        release()                

释放指向服务端surface的本地连接。

Release the local reference to the server-side surface.
                                                                        String        

        toString()

返回一个包含了精确,人类可读懂的这个对象的描述。                

Returns a string containing a concise, human-readable description of this object.
                                                                        void        

        unlockCanvas(Canvas canvas)              

在API7中这个方法被弃用了。

      This method was deprecated       in API level 17.     This API has been removed and is not supported.  Do not use.
                                                                        void        

        unlockCanvasAndPost(Canvas canvas)          

提交这个canvas中新的内容到surface,并释放这个canvas。

Posts the new contents of the Canvas to the surface and releases the Canvas.
                                                                        void        

        writeToParcel(Parcel dest, int flags)             

写到打包(目标导报对象,标记)。扁平化这个对象到一个包中。

Flatten this object in to a Parcel.
                   
Protected Methods受保护的方法
                                                                        void        

        finalize()                

当垃圾回收器侦测到这个实例不再可读时,被调用。

Invoked when the garbage collector has detected that this instance is no longer reachable.
[Expand]
Inherited Methods
bubuko.com,布布扣 From class
  java.lang.Object
 
bubuko.com,布布扣 From interface
  android.os.Parcelable
 

Constants


   

              public         static         final         int               ROTATION_0    

     
          Added in API level 1          
     
   
     

Rotation constant: 0 degree rotation (natural orientation)

           
        Constant Value:                                     0                 (0x00000000)                            
       
   

              public         static         final         int               ROTATION_180    

     
          Added in API level 1          
     
   
     

Rotation constant: 180 degree rotation.

           
        Constant Value:                                     2                 (0x00000002)                            
       
   

              public         static         final         int               ROTATION_270    

     
          Added in API level 1          
     
   
     

Rotation constant: 270 degree rotation.

           
        Constant Value:                                     3                 (0x00000003)                            
       
   

              public         static         final         int               ROTATION_90    

     
          Added in API level 1          
     
   
     

Rotation constant: 90 degree rotation.

           
        Constant Value:                                     1                 (0x00000001)                            
       

Fields


   

              public         static         final         Creator<Surface>               CREATOR    

     
          Added in API level 1          
     
   
     
 
       

Public Constructors共有构造方法


   

              public                                                         Surface       (SurfaceTexture surfaceTexture)    

     
       
Added in API level 14
           
 从一个SurfaceTexture中创建surface。被画到surface的图像将会被SurfaceTexture可得到。SurfaceTexture可以通过updateTextImage()方法附加他们到一个开放的图形ES texture。
Create Surface from a SurfaceTexture.
Images drawn to the Surface will be made available to the SurfaceTexture, which can attach them to an OpenGL ES texture via updateTexImage().
     
Parameters
                                     
surfaceTexture          

The SurfaceTexture that is updated by this Surface.

通过这个Surface更新的surfaceTexture

     
Throws
                                         

Surface.OutOfResourcesException    

抛出surface资源不可获得异常        

if the surface could not be created.

如果这个surface不能创建

   

Public Methods


   

              public                                             int             describeContents       ()    

     
       
Added in API level 1
         
     
   
 用这个包的 marshalled 描述方法来描述这个包内的 不同的对象。    

Describe the kinds of special objects contained in this Parcelable‘s marshalled representation.

     
Returns
     返回一个bitmask指示了这个包的marshalled的集合对象的类型
  • a bitmask indicating the set of special object types marshalled by the Parcelable.
   
   

              public                                             boolean             isValid       ()    

     
       
Added in API level 1
           
 如果这个对象持有一个有效的surface,则返回true   
  Returns true if this object holds a valid surface.
     
Returns
     如果它持有一个物理的surface,则返回true,因此lockCanvas()将会成功。否则返回false。
  • True if it holds a physical surface, so lockCanvas() will succeed. Otherwise returns false.
   
   

              public                                             Canvas             lockCanvas       (Rect inOutDirty)    

     
       
Added in API level 1
   获取一个canvas,用来画东西到这个surface中。当画到一个提供的Canvas中时,这个caller必需调用unlockCanvasAndPost(Canvas)来提交新的内容到surface。       
     
   Gets a Canvas for drawing into this surface.
After drawing into the provided Canvas, the caller must invoke unlockCanvasAndPost(Canvas) to post the new contents to the surface.
     
Parameters
                                     
inOutDirty           参数

A rectangle that represents the dirty region that the caller wants to redraw.  This function may choose to expand the dirty rectangle if for example the surface has been resized or if the previous contents of the surface were not available.  The caller must redraw the entire dirty region as represented by the contents of the inOutDirty rectangle upon return from this function. The caller may also pass null instead, in the case where the entire surface should be redrawn.

一个矩形代表dirty区域,调用者想在这个区域重画。这个功能可以选择去扩展这个dirty区域,如果例如这个surface大小被改变或者如果说surface先前的内容不再可以得到了。这个调用者必需重新绘制整个dirty区域 根据return这个函数返回的inOutDirty矩形区域。这个调用者或许也传递null,在这种情况下,整个surface应该被重画。

     
Returns
     返回一个canvas用来画到surface上
  • A canvas for drawing into the surface.
     
Throws
                                                                       
IllegalArgumentException       非法参数异常      If the inOutDirty rectangle is not valid.矩形无效的
Surface.OutOfResourcesException      surface资源不可得异常       If the canvas cannot be locked.如果这个画布不能被锁定
   
   

              public                                             void             readFromParcel       (Parcel source)    

     
       
Added in API level 1
           
    从这个包中读取资源
   

              public                                             void             release       ()    

     
       
Added in API level 14
         
     
   
     释放本地对服务端surface的连接指引。总是调用release()当你完成一个surface相关工作时。这会让surface无效。

Release the local reference to the server-side surface. Always call release() when you‘re done with a Surface. This will make the surface invalid.

   
   

              public                                             String             toString       ()    

     
       
Added in API level 1
         
    返回一个字符串,包含一个精确的,人类可读懂的对于这个对象的描述。子类被鼓励去重写这个方法并且提供一个实现。这个实现需要考虑这个对象的类型和数据。默认的实现与下面的表达相等 getClass().getName()+‘@‘+Integer,toHexString(hashCode())
   请看一个有效的写的方法 toString()。如果你打算实现你自己的同String方法时。
 
   Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object‘s type and data. The default implementation is equivalent to the following expression: 
   getClass().getName()+‘@‘+Integer.toHexString(hashCode())

See Writing a useful toString method if you intend implementing your own toString method.

     
Returns
     
  • a printable representation of this object.返回一个打印的这个对象的描述。
   
   

              public                                             void             unlockCanvas       (Canvas canvas)    

     
       
Added in API level 1
         
     
   
     

 

      This method was deprecated       in API level 17.
    This API has been removed and is not supported.  Do not use.

 
   
   

              public                                             void             unlockCanvasAndPost       (Canvas canvas)    

     
       
Added in API level 1
         
     
   
     

Posts the new contents of the Canvas to the surface and releases the Canvas.

     
Parameters
                                     
canvas           The canvas previously obtained from lockCanvas(Rect).
   
   

              public                                             void             writeToParcel       (Parcel dest, int flags)    

Added in API level 1
 扁平化这个对象到一个打包中。
Flatten this object in to a Parcel.
     
Parameters
                                                               
dest           The Parcel in which the object should be written.这个对象被写入的包
flags          

Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.

附加的标记关于这个对象被怎么写入。或许为0或许为PARCELABLE_WRITE_RETURN_VALUE

   

Protected Methods


   

              protected                                             void             finalize       ()    

     
       
Added in API level 1
         
     
   调用当垃圾回收期侦测到这个实例不再可读时。虽然这个默认的实现没有做任何事情,但是这个方法可以重写到自由的资源。     

Invoked when the garbage collector has detected that this instance is no longer reachable. The default implementation does nothing, but this method can be overridden to free resources.
 注意对象重写finalize 值得注意的它比不重写的对象是更昂贵。当这个对象不再可读时,Finalizers或许运行很长一段时间,这依赖于内存的压力,因此依赖这个方法来实现cleanup是很不好的一个注意。另外也要注意finalizers运行在一个单独的VM wide finalizer线程,因此在一个finalizer中进行一个堵塞性的工作是非常不好的。一个finalizer通常仅仅在一个类有一个本地的peer而且需要调用一个本地方法去销毁那个同龄的peer。即使如此,最好提供一个明确的close方法(并实现Closeable),并且坚持这个callers人为的处理这个instance。这个有时工作的很好,例如对于files,但是对于一些像BigInteger这些典型的调用代码则会处理很多临时性的问题。不幸的是,创建很多临时性的代码是最烂的代码之一,就view的 单finalizer线程而言。

Note that objects that override finalize are significantly more expensive than objects that don‘t. Finalizers may be run a long time after the object is no longer reachable, depending on memory pressure, so it‘s a bad idea to rely on them for cleanup. Note also that finalizers are run on a single VM-wide finalizer thread, so doing blocking work in a finalizer is a bad idea. A finalizer is usually only necessary for a class that has a native peer and needs to call a native method to destroy that peer. Even then, it‘s better to provide an explicit close method (and implement Closeable), and insist that callers manually dispose of instances. This works well for something like files, but less well for something like a BigInteger where typical calling code would have to deal with lots of temporaries. Unfortunately, code that creates lots of temporaries is the worst kind of code from the point of view of the single finalizer thread.
如果你必须finalizers,考虑一下至少提供你自己的ReferenceQueue并且有你自己的队列线程。

If you must use finalizers, consider at least providing your own ReferenceQueue and having your own thread process that queue.
不像构造方法,finalizers不是自动的链接上的。你要自己负责调用super.finalize()方法。

Unlike constructors, finalizers are not automatically chained. You are responsible for calling super.finalize() yourself.
由finalizers抛出的未捕捉的异常,被忽略。并且不决定这个finalizer线程。看 Effective Java Item7的“Avoid finalizers”获得更多的内容。

Uncaught exceptions thrown by finalizers are ignored and do not terminate the finalizer thread.
See Effective Java Item 7, "Avoid finalizers" for more.

     
Throws
                           
Throwable              

surface 译,布布扣,bubuko.com

surface 译

标签:des   android   style   class   code   java   

原文地址:http://www.cnblogs.com/muyable/p/3783497.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!