# OHOS::Surface - [Overview](#section83217545165632) - [Summary](#section1990804920165632) - [Public Member Functions](#pub-methods) - [Static Public Member Functions](#pub-static-methods) ## **Overview** **Related Modules:** [Surface](Surface.md) **Description:** Defines the consumer listener used to notify consumers when the surface status is updated. **Since:** 1.0 **Version:** 1.0 ## **Summary** ## Public Member Functions

Function

Description

~Surface ()

virtual

A destructor used to delete the Surface instance.

SetQueueSize (uint8_t queueSize)=0

virtual void

Sets the number of buffers that can be allocated to the surface. The default value is 1. The value range is [1, 10].

GetQueueSize ()=0

virtual uint8_t

Obtains the number of surface buffers that can be allocated to the surface. The default value is 1. The value range is [1, 10].

SetWidthAndHeight (uint32_t width, uint32_t height)=0

virtual void

Sets the width and height of the surface for calculating its stride and size. The default value range of width and height is (0,7680].

GetWidth ()=0

virtual uint32_t

Obtains the width of the surface.

GetHeight ()=0

virtual uint32_t

Obtains the height of the surface.

SetFormat (uint32_t format)=0

virtual void

Sets the pixel format of the surface. For details, see ImageFormat. The default pixel format is IMAGE_PIXEL_FORMAT_RGB565.

GetFormat ()=0

virtual uint32_t

Obtains the pixel format of the surface. For details, see ImageFormat. The default pixel format is IMAGE_PIXEL_FORMAT_RGB565.

SetStrideAlignment (uint32_t strideAlignment)=0

virtual void

Sets the number of bytes for stride alignment.

GetStrideAlignment ()=0

virtual uint32_t

Obtains the number of bytes for stride alignment. By default, 4-byte aligned is used.

GetStride ()=0

virtual uint32_t

Obtains the stride of the surface.

SetSize (uint32_t size)=0

virtual void

Sets the size of the shared memory to allocate.

GetSize ()=0

virtual uint32_t

Obtains the size of the shared memory to allocate.

SetUsage (uint32_t usage)=0

virtual void

Sets the usage scenario of the buffer. Physically contiguous memory and virtual memory (by default) are supported. By default, virtual memory is allocated.

GetUsage ()=0

virtual uint32_t

Obtains the usage scenario of the buffer. Physically contiguous memory and virtual memory are supported.

SetUserData (const std::string &key, const std::string &value)=0

virtual void

Sets surface user data, which is stored in the format of <key, value>.

GetUserData (const std::string &key)=0

virtual std::string

Obtains surface user data.

RequestBuffer (uint8_t wait=0)=0

virtual SurfaceBuffer *

Obtains a buffer to write data.

FlushBuffer (SurfaceBuffer *buffer)=0

virtual int32_t

Flushes a buffer to the dirty queue for consumers to use.

AcquireBuffer ()=0

virtual SurfaceBuffer *

Obtains a buffer.

ReleaseBuffer (SurfaceBuffer *buffer)=0

virtual bool

Releases the consumed buffer.

CancelBuffer (SurfaceBuffer *buffer)=0

virtual void

Releases a buffer to the free queue.

RegisterConsumerListener (IBufferConsumerListener &listener)=0

virtual void

Registers a consumer listener.

UnregisterConsumerListener ()=0

virtual void

Unregisters the consumer listener.

## Static Public Member Functions

Function

Description

CreateSurface ()

static Surface *

A constructor used to create a Surface object for consumers to use.