Skia
2D Graphics Library
SkDeferredDisplayListRecorder.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkDeferredDisplayListRecorder_DEFINED
9 #define SkDeferredDisplayListRecorder_DEFINED
10 
13 #include "include/core/SkRefCnt.h"
15 #include "include/core/SkTypes.h"
16 
17 class GrBackendFormat;
18 class GrBackendTexture;
19 class GrRecordingContext;
21 class SkCanvas;
22 class SkImage;
23 class SkPromiseImageTexture;
24 class SkSurface;
25 
26 /*
27  * This class is intended to be used as:
28  * Get an SkSurfaceCharacterization representing the intended gpu-backed destination SkSurface
29  * Create one of these (an SkDeferredDisplayListRecorder) on the stack
30  * Get the canvas and render into it
31  * Snap off and hold on to an SkDeferredDisplayList
32  * Once your app actually needs the pixels, call SkSurface::draw(SkDeferredDisplayList*)
33  *
34  * This class never accesses the GPU but performs all the cpu work it can. It
35  * is thread-safe (i.e., one can break a scene into tiles and perform their cpu-side
36  * work in parallel ahead of time).
37  */
39 public:
42 
44  return fCharacterization;
45  }
46 
47  // The backing canvas will become invalid (and this entry point will return
48  // null) once 'detach' is called.
49  // Note: ownership of the SkCanvas is not transferred via this call.
51 
53 
57 
58 #ifndef SK_MAKE_PROMISE_TEXTURE_DISABLE_LEGACY_API
59 
61  int width,
62  int height,
63  GrMipmapped mipMapped,
64  GrSurfaceOrigin origin,
65  SkColorType colorType,
66  SkAlphaType alphaType,
67  sk_sp<SkColorSpace> colorSpace,
68  PromiseImageTextureFulfillProc textureFulfillProc,
69  PromiseImageTextureReleaseProc textureReleaseProc,
70  PromiseImageTextureContext textureContext);
71 
74  sk_sp<SkColorSpace> imageColorSpace,
75  PromiseImageTextureFulfillProc textureFulfillProc,
76  PromiseImageTextureReleaseProc textureReleaseProc,
77  PromiseImageTextureContext textureContexts[]);
78 #endif
79 
80 private:
83 
84  bool init();
85 
86  const SkSurfaceCharacterization fCharacterization;
87 
88 #if SK_SUPPORT_GPU
90  sk_sp<GrRenderTargetProxy> fTargetProxy;
92  sk_sp<SkSurface> fSurface;
93 #endif
94 };
95 
96 #endif
GrRecordingContext
Definition: GrRecordingContext.h:35
SkImage
Definition: SkImage.h:61
SkSurface
Definition: SkSurface.h:46
SkTypes.h
GrSurfaceOrigin
GrSurfaceOrigin
GPU SkImage and SkSurfaces can be stored such that (0, 0) in texture space may correspond to either t...
Definition: GrTypes.h:198
SkDeferredDisplayListRecorder
Definition: SkDeferredDisplayListRecorder.h:38
SkSurfaceCharacterization.h
GrYUVABackendTextureInfo
A description of a set GrBackendTextures that hold the planar data described by a SkYUVAInfo.
Definition: GrYUVABackendTextures.h:19
SkDeferredDisplayListRecorder::makeYUVAPromiseTexture
sk_sp< SkImage > makeYUVAPromiseTexture(const GrYUVABackendTextureInfo &yuvaBackendTextureInfo, sk_sp< SkColorSpace > imageColorSpace, PromiseImageTextureFulfillProc textureFulfillProc, PromiseImageTextureReleaseProc textureReleaseProc, PromiseImageTextureContext textureContexts[])
Deprecated: Use SkImage::MakePromiseYUVATexture instead.
SkImage::PromiseImageTextureFulfillProc
sk_sp< SkPromiseImageTexture >(*)(PromiseImageTextureContext) PromiseImageTextureFulfillProc
Definition: SkImage.h:482
SkDeferredDisplayListRecorder::SkDeferredDisplayListRecorder
SkDeferredDisplayListRecorder(const SkSurfaceCharacterization &)
SkRefCnt.h
SkDeferredDisplayListRecorder::PromiseImageTextureContext
SkImage::PromiseImageTextureContext PromiseImageTextureContext
Definition: SkDeferredDisplayListRecorder.h:54
GrMipmapped
GrMipmapped
Used to say whether a texture has mip levels allocated or not.
Definition: GrTypes.h:169
sk_sp
Shared pointer class to wrap classes that support a ref()/unref() interface.
Definition: SkRefCnt.h:215
GrBackendFormat
Definition: GrBackendSurface.h:48
SK_API
#define SK_API
Definition: SkTypes.h:181
SkDeferredDisplayListRecorder::detach
sk_sp< SkDeferredDisplayList > detach()
SkDeferredDisplayListRecorder::characterization
const SkSurfaceCharacterization & characterization() const
Definition: SkDeferredDisplayListRecorder.h:43
SkImage::PromiseImageTextureReleaseProc
void(*)(PromiseImageTextureContext) PromiseImageTextureReleaseProc
Definition: SkImage.h:483
SkDeferredDisplayListRecorder::makePromiseTexture
sk_sp< SkImage > makePromiseTexture(const GrBackendFormat &backendFormat, int width, int height, GrMipmapped mipMapped, GrSurfaceOrigin origin, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace, PromiseImageTextureFulfillProc textureFulfillProc, PromiseImageTextureReleaseProc textureReleaseProc, PromiseImageTextureContext textureContext)
Deprecated: Use SkImage::MakePromiseTexture instead.
SkCanvas
Definition: SkCanvas.h:87
SkDeferredDisplayListRecorder::~SkDeferredDisplayListRecorder
~SkDeferredDisplayListRecorder()
SkDeferredDisplayListRecorder::PromiseImageTextureReleaseProc
SkImage::PromiseImageTextureReleaseProc PromiseImageTextureReleaseProc
Definition: SkDeferredDisplayListRecorder.h:56
SkDeferredDisplayList.h
SkSurfaceCharacterization
Definition: SkSurfaceCharacterization.h:207
GrBackendTexture
Definition: GrBackendSurface.h:54
SkDeferredDisplayListRecorder::getCanvas
SkCanvas * getCanvas()
SkColorType
SkColorType
Definition: SkImageInfo.h:64
SkImage::PromiseImageTextureContext
void * PromiseImageTextureContext
Definition: SkImage.h:480
SkAlphaType
SkAlphaType
Definition: SkImageInfo.h:37
SkImageInfo.h