Class ImageViewProxy
- All Implemented Interfaces:
RefCounted
ImageViewProxy implements the proxy pattern for Image,
it targets an Image with three instantiation methods: deferred,
lazy-callback and wrapped.
Deferred version takes an ImageDesc, and will be instantiated
as needed automatically.
Lazy-callback version takes an ImageDesc, but will be instantiated
via a user-defined callback. There is a special case where the extent of the
image is uncertain before the callback is invoked. This is known as lazy-most,
and the extent of ImageDesc can be arbitrary (1x1x1 by convention).
Wrapped version takes an existing Image without further instantiation.
Target: The backing GPU Image that referenced by this proxy.
Instantiate: Find or create GPU Image via ResourceProvider
when they are actually required on flush.
BackingFit: Indicates whether a backing store needs to be an exact match or
can be larger than is strictly necessary. True: Exact; False: Approx. See
ISurface.FLAG_APPROX_FIT, the default is exact.
UseAllocator:
- False: This surface will be instantiated outside the allocator (e.g. for surfaces that are instantiated in on-flush callbacks).
- True:
SurfaceAllocatorshould instantiate this surface.
Threading: Proxies may be created on the owner thread of a Context,
and change the reference count through RefCnt.ref() and RefCnt.unref().
The proxy may be disposed on either the owner thread of its creating context,
or the owner thread of its immediate context.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interfaceLazy-callback function. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()De-instantiate.voidconcatSwizzle(short swizzle) protected voidOverride this method to invoke de-allocation of the underlying resource.booleandoLazyInstantiation(ResourceProvider resourceProvider) @NonNull ImageDescgetDesc()intReturns the logical height of this surface.getImage()getLabel()longRetrieves the amount of GPU memory that will be or currently is used by this resource in bytes.intintReturns the number of samples per pixel in color buffers (one if non-MSAA).shortintgetWidth()Returns the logical width of this surface.booleaninstantiate(ResourceProvider resourceProvider) Instantiates the backing store, if necessary.booleaninstantiateIfNonLazy(ResourceProvider resourceProvider) booleanReturns whether the backing store references the wrapped object.booleanDoes the resource count against the resource budget?booleanReturns true if the backing store is instantiated.booleanisLazy()Returns true if the image proxy has a lazy callback.booleanReturns true if the image proxy has a lazy callback, loose fit and dimension is not known.booleanIf we are instantiated and have a target, return the mip state of that target.booleanbooleanFor Promise Images - should the Promise Image be fulfilled every time a Recording that references it is inserted into the Context.static @Nullable @SharedPtr ImageViewProxymake(@NonNull Context context, int imageType, int colorType, int width, int height, int depthOrArraySize, int imageFlags, int origin, short swizzle) static @Nullable @SharedPtr ImageViewProxymake(@NonNull Context context, @Nullable ImageDesc desc, int origin, short swizzle, boolean budgeted, @Nullable String label) static @SharedPtr ImageViewProxymakeLazy(@NonNull ImageDesc desc, int origin, short swizzle, boolean budgeted, boolean isVolatile, boolean lazyDimensions, @NonNull ImageViewProxy.LazyInstantiateCallback callback) refImage()voidsetSwizzle(short swizzle) Replace the view's swizzle.toString()static @SharedPtr ImageViewProxywrap(@SharedPtr Image image, int origin, short swizzle)
-
Method Details
-
make
@SharedPtr public static @Nullable @SharedPtr ImageViewProxy make(@NonNull Context context, @Nullable ImageDesc desc, int origin, short swizzle, boolean budgeted, @Nullable String label) -
make
@SharedPtr public static @Nullable @SharedPtr ImageViewProxy make(@NonNull Context context, int imageType, int colorType, int width, int height, int depthOrArraySize, int imageFlags, int origin, short swizzle) -
makeLazy
@SharedPtr public static @SharedPtr ImageViewProxy makeLazy(@NonNull ImageDesc desc, int origin, short swizzle, boolean budgeted, boolean isVolatile, boolean lazyDimensions, @NonNull ImageViewProxy.LazyInstantiateCallback callback) -
wrap
@SharedPtr public static @SharedPtr ImageViewProxy wrap(@SharedPtr @SharedPtr Image image, int origin, short swizzle) -
deallocate
protected void deallocate()Description copied from class:RefCntOverride this method to invoke de-allocation of the underlying resource.- Specified by:
deallocatein classRefCnt
-
isLazy
public boolean isLazy()Returns true if the image proxy has a lazy callback. -
isLazyMost
public boolean isLazyMost()Returns true if the image proxy has a lazy callback, loose fit and dimension is not known. -
getWidth
public int getWidth()Returns the logical width of this surface. The result is undefined ifisLazyMost()returns true.- Returns:
- the desired width of the surface
-
getHeight
public int getHeight()Returns the logical height of this surface. The result is undefined ifisLazyMost()returns true.- Returns:
- the desired height of the surface
-
getOrigin
public int getOrigin()- See Also:
-
getSwizzle
public short getSwizzle()- See Also:
-
concatSwizzle
public void concatSwizzle(short swizzle) -
setSwizzle
public void setSwizzle(short swizzle) Replace the view's swizzle. -
isVolatile
public boolean isVolatile()For Promise Images - should the Promise Image be fulfilled every time a Recording that references it is inserted into the Context. True: fulfilled on every insertion call, otherwise only fulfilled once. -
getSampleCount
public int getSampleCount()Returns the number of samples per pixel in color buffers (one if non-MSAA). If this surface it non-renderable, this method always returns one.- Returns:
- the number of samples, greater than (multisample) or equal to one
-
getDesc
-
isInstantiated
public boolean isInstantiated()Returns true if the backing store is instantiated. -
instantiate
Instantiates the backing store, if necessary.- Parameters:
resourceProvider- the resource provider to create textures- Returns:
- success or not
-
instantiateIfNonLazy
-
doLazyInstantiation
-
clear
public void clear()De-instantiate. Called after instantiated. -
isBudgeted
public boolean isBudgeted()Does the resource count against the resource budget?Always true for lazy-callback resources; set from the backing resource for wrapped resources; only meaningful if 'mLazyInstantiateCallback' is non-null.
-
isProtected
public boolean isProtected() -
getMemorySize
public long getMemorySize()Retrieves the amount of GPU memory that will be or currently is used by this resource in bytes. It is approximate since we aren't aware of additional padding or copies made by the driver.- Returns:
- the amount of GPU memory used in bytes
-
isBackingWrapped
public boolean isBackingWrapped()Returns whether the backing store references the wrapped object. Always false if not instantiated. -
getImage
-
refImage
-
isMipmapped
public boolean isMipmapped()If we are instantiated and have a target, return the mip state of that target. Otherwise, returns the proxy's mip state from creation time. This is useful for lazy proxies which may claim to not need mips at creation time, but the instantiation happens to give us a mipmapped target. In that case we should use that for our benefit to avoid possible copies/mip generation later. -
getLabel
-
toString
-