robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 8 | #ifndef GrRenderTargetContext_DEFINED |
| 9 | #define GrRenderTargetContext_DEFINED |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 10 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/core/SkCanvas.h" |
| 12 | #include "include/core/SkDrawable.h" |
| 13 | #include "include/core/SkRefCnt.h" |
| 14 | #include "include/core/SkSurface.h" |
| 15 | #include "include/core/SkSurfaceProps.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 16 | #include "include/private/GrTypesPriv.h" |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 17 | #include "src/gpu/GrOpsTask.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 18 | #include "src/gpu/GrPaint.h" |
Greg Daniel | f91aeb2 | 2019-06-18 09:58:02 -0400 | [diff] [blame] | 19 | #include "src/gpu/GrRenderTargetProxy.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 20 | #include "src/gpu/GrSurfaceContext.h" |
Greg Daniel | a83de58 | 2019-10-22 09:33:25 -0400 | [diff] [blame] | 21 | #include "src/gpu/GrSurfaceProxyView.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 22 | #include "src/gpu/GrXferProcessor.h" |
Michael Ludwig | 6132820 | 2019-06-19 14:48:58 +0000 | [diff] [blame] | 23 | #include "src/gpu/geometry/GrQuad.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 24 | #include "src/gpu/text/GrTextTarget.h" |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 25 | |
Greg Daniel | a5cb781 | 2017-06-16 09:45:32 -0400 | [diff] [blame] | 26 | class GrBackendSemaphore; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 27 | class GrClip; |
Brian Osman | 2240be9 | 2017-10-18 13:15:13 -0400 | [diff] [blame] | 28 | class GrColorSpaceXform; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 29 | class GrCoverageCountingPathRenderer; |
Brian Salomon | 9afd371 | 2016-12-01 10:59:09 -0500 | [diff] [blame] | 30 | class GrDrawOp; |
csmartdalton | 29df760 | 2016-08-31 11:55:52 -0700 | [diff] [blame] | 31 | class GrFixedClip; |
Robert Phillips | 0d075de | 2019-03-04 11:08:13 -0500 | [diff] [blame] | 32 | class GrOp; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 33 | class GrRenderTarget; |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 34 | class GrRenderTargetContextPriv; |
Michael Ludwig | 2686d69 | 2020-04-17 20:21:37 +0000 | [diff] [blame] | 35 | class GrStyledShape; |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 36 | class GrStyle; |
Robert Phillips | eaa8625 | 2016-11-08 13:49:39 +0000 | [diff] [blame] | 37 | class GrTextureProxy; |
robertphillips | 4430239 | 2016-07-08 14:43:03 -0700 | [diff] [blame] | 38 | struct GrUserStencilSettings; |
Jim Van Verth | 3af1af9 | 2017-05-18 15:06:54 -0400 | [diff] [blame] | 39 | struct SkDrawShadowRec; |
Herb Derby | cddab25 | 2018-07-16 11:19:04 -0400 | [diff] [blame] | 40 | class SkGlyphRunList; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 41 | struct SkIPoint; |
| 42 | struct SkIRect; |
msarett | 10e3d9b | 2016-08-18 15:46:03 -0700 | [diff] [blame] | 43 | class SkLatticeIter; |
Brian Osman | 449b115 | 2020-04-15 16:43:00 -0400 | [diff] [blame] | 44 | class SkMatrixProvider; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 45 | class SkMatrix; |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 46 | class SkPaint; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 47 | class SkPath; |
| 48 | struct SkPoint; |
| 49 | struct SkRect; |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 50 | class SkRegion; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 51 | class SkRRect; |
jvanverth | 31ff762 | 2015-08-07 10:09:28 -0700 | [diff] [blame] | 52 | struct SkRSXform; |
Brian Osman | 3c35842 | 2020-03-23 10:44:12 -0400 | [diff] [blame] | 53 | class SkRuntimeEffect; |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 54 | class SkTextBlob; |
Brian Salomon | 199fb87 | 2017-02-06 09:41:10 -0500 | [diff] [blame] | 55 | class SkVertices; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 56 | |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 57 | /** |
| 58 | * A helper object to orchestrate commands (draws, etc...) for GrSurfaces that are GrRenderTargets. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 59 | */ |
Brian Salomon | 3b8486a | 2020-04-21 12:43:26 -0400 | [diff] [blame] | 60 | class GrRenderTargetContext : public GrSurfaceContext, public GrOpsTaskClosedObserver { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 61 | public: |
Greg Daniel | e20fcad | 2020-01-08 11:52:34 -0500 | [diff] [blame] | 62 | static std::unique_ptr<GrRenderTargetContext> Make( |
Greg Daniel | ba0ff78 | 2020-01-07 15:42:57 -0500 | [diff] [blame] | 63 | GrRecordingContext*, GrColorType, sk_sp<SkColorSpace>, sk_sp<GrSurfaceProxy>, |
| 64 | GrSurfaceOrigin, const SkSurfaceProps*, bool managedOps = true); |
| 65 | |
Brian Salomon | a56a746 | 2020-02-07 14:17:25 -0500 | [diff] [blame] | 66 | static std::unique_ptr<GrRenderTargetContext> Make(GrRecordingContext*, |
| 67 | GrColorType, |
| 68 | sk_sp<SkColorSpace>, |
| 69 | SkBackingFit, |
| 70 | SkISize dimensions, |
| 71 | const GrBackendFormat&, |
| 72 | int sampleCnt, |
| 73 | GrMipMapped, |
| 74 | GrProtected, |
| 75 | GrSurfaceOrigin, |
| 76 | SkBudgeted, |
| 77 | const SkSurfaceProps*); |
Greg Daniel | e20fcad | 2020-01-08 11:52:34 -0500 | [diff] [blame] | 78 | |
| 79 | // Same as above but will use the default GrBackendFormat for the given GrColorType |
| 80 | static std::unique_ptr<GrRenderTargetContext> Make( |
Brian Salomon | a56a746 | 2020-02-07 14:17:25 -0500 | [diff] [blame] | 81 | GrRecordingContext*, |
| 82 | GrColorType, |
| 83 | sk_sp<SkColorSpace>, |
| 84 | SkBackingFit, |
| 85 | SkISize dimensions, |
| 86 | int sampleCnt = 1, |
| 87 | GrMipMapped = GrMipMapped::kNo, |
| 88 | GrProtected = GrProtected::kNo, |
| 89 | GrSurfaceOrigin = kBottomLeft_GrSurfaceOrigin, |
| 90 | SkBudgeted = SkBudgeted::kYes, |
| 91 | const SkSurfaceProps* = nullptr); |
Greg Daniel | e20fcad | 2020-01-08 11:52:34 -0500 | [diff] [blame] | 92 | |
Brian Salomon | d005b69 | 2020-04-01 15:47:05 -0400 | [diff] [blame] | 93 | static std::tuple<GrColorType, GrBackendFormat> GetFallbackColorTypeAndFormat(GrImageContext*, |
Brian Salomon | 0029db0 | 2020-04-03 10:41:24 -0400 | [diff] [blame] | 94 | GrColorType, |
| 95 | int sampleCnt); |
Brian Salomon | d005b69 | 2020-04-01 15:47:05 -0400 | [diff] [blame] | 96 | |
Greg Daniel | e20fcad | 2020-01-08 11:52:34 -0500 | [diff] [blame] | 97 | // Same as previous factory but will try to use fallback GrColorTypes if the one passed in |
| 98 | // fails. The fallback GrColorType will have at least the number of channels and precision per |
| 99 | // channel as the passed in GrColorType. It may also swizzle the changes (e.g., BGRA -> RGBA). |
| 100 | // SRGB-ness will be preserved. |
| 101 | static std::unique_ptr<GrRenderTargetContext> MakeWithFallback( |
Brian Salomon | a56a746 | 2020-02-07 14:17:25 -0500 | [diff] [blame] | 102 | GrRecordingContext*, |
| 103 | GrColorType, |
| 104 | sk_sp<SkColorSpace>, |
| 105 | SkBackingFit, |
| 106 | SkISize dimensions, |
| 107 | int sampleCnt = 1, |
| 108 | GrMipMapped = GrMipMapped::kNo, |
| 109 | GrProtected = GrProtected::kNo, |
| 110 | GrSurfaceOrigin = kBottomLeft_GrSurfaceOrigin, |
| 111 | SkBudgeted = SkBudgeted::kYes, |
| 112 | const SkSurfaceProps* = nullptr); |
Greg Daniel | e20fcad | 2020-01-08 11:52:34 -0500 | [diff] [blame] | 113 | |
Greg Daniel | ba0ff78 | 2020-01-07 15:42:57 -0500 | [diff] [blame] | 114 | // These match the definitions in SkSurface & GrSurface.h, for whence they came |
| 115 | typedef void* ReleaseContext; |
| 116 | typedef void (*ReleaseProc)(ReleaseContext); |
| 117 | |
| 118 | // Creates a GrRenderTargetContext that wraps the passed in GrBackendTexture. |
| 119 | static std::unique_ptr<GrRenderTargetContext> MakeFromBackendTexture( |
| 120 | GrRecordingContext*, GrColorType, sk_sp<SkColorSpace>, const GrBackendTexture&, |
| 121 | int sampleCnt, GrSurfaceOrigin, const SkSurfaceProps*, ReleaseProc releaseProc, |
| 122 | ReleaseContext releaseCtx); |
| 123 | |
| 124 | static std::unique_ptr<GrRenderTargetContext> MakeFromBackendTextureAsRenderTarget( |
| 125 | GrRecordingContext*, GrColorType, sk_sp<SkColorSpace>, const GrBackendTexture&, |
| 126 | int sampleCnt, GrSurfaceOrigin, const SkSurfaceProps*); |
| 127 | |
| 128 | static std::unique_ptr<GrRenderTargetContext> MakeFromBackendRenderTarget( |
| 129 | GrRecordingContext*, GrColorType, sk_sp<SkColorSpace>, const GrBackendRenderTarget&, |
| 130 | GrSurfaceOrigin, const SkSurfaceProps*, ReleaseProc releaseProc, |
| 131 | ReleaseContext releaseCtx); |
| 132 | |
| 133 | static std::unique_ptr<GrRenderTargetContext> MakeFromVulkanSecondaryCB( |
| 134 | GrRecordingContext*, const SkImageInfo&, const GrVkDrawableInfo&, |
| 135 | const SkSurfaceProps*); |
| 136 | |
Greg Daniel | 3912a4b | 2020-01-14 09:56:04 -0500 | [diff] [blame] | 137 | GrRenderTargetContext(GrRecordingContext*, GrSurfaceProxyView readView, |
Brian Salomon | 8afde5f | 2020-04-01 16:22:00 -0400 | [diff] [blame] | 138 | GrSurfaceProxyView writeView, GrColorType, sk_sp<SkColorSpace>, |
Greg Daniel | 3912a4b | 2020-01-14 09:56:04 -0500 | [diff] [blame] | 139 | const SkSurfaceProps*, bool managedOpsTask = true); |
Greg Daniel | bfa19c4 | 2019-12-19 16:41:40 -0500 | [diff] [blame] | 140 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 141 | ~GrRenderTargetContext() override; |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 142 | |
Brian Osman | 449b115 | 2020-04-15 16:43:00 -0400 | [diff] [blame] | 143 | virtual void drawGlyphRunList(const GrClip&, const SkMatrixProvider&, const SkGlyphRunList&); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 144 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 145 | /** |
| 146 | * Provides a perfomance hint that the render target's contents are allowed |
| 147 | * to become undefined. |
| 148 | */ |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 149 | void discard(); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 150 | |
Chris Dalton | 344e903 | 2017-12-11 15:42:09 -0700 | [diff] [blame] | 151 | enum class CanClearFullscreen : bool { |
| 152 | kNo = false, |
| 153 | kYes = true |
| 154 | }; |
| 155 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 156 | /** |
| 157 | * Clear the entire or rect of the render target, ignoring any clips. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 158 | * @param rect the rect to clear or the whole thing if rect is NULL. |
| 159 | * @param color the color to clear to. |
Chris Dalton | 344e903 | 2017-12-11 15:42:09 -0700 | [diff] [blame] | 160 | * @param CanClearFullscreen allows partial clears to be converted to fullscreen clears on |
| 161 | * tiling platforms where that is an optimization. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 162 | */ |
Brian Osman | 9a9baae | 2018-11-05 15:06:26 -0500 | [diff] [blame] | 163 | void clear(const SkIRect* rect, const SkPMColor4f& color, CanClearFullscreen); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 164 | |
Chris Dalton | 0493fbd | 2019-09-18 15:49:46 -0600 | [diff] [blame] | 165 | void clear(const SkPMColor4f& color) { |
| 166 | return this->clear(nullptr, color, CanClearFullscreen::kYes); |
| 167 | } |
| 168 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 169 | /** |
| 170 | * Draw everywhere (respecting the clip) with the paint. |
| 171 | */ |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 172 | void drawPaint(const GrClip&, GrPaint&&, const SkMatrix& viewMatrix); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 173 | |
| 174 | /** |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 175 | * Draw the rect using a paint. |
| 176 | * @param paint describes how to color pixels. |
| 177 | * @param GrAA Controls whether rect is antialiased |
| 178 | * @param viewMatrix transformation matrix |
| 179 | * @param style The style to apply. Null means fill. Currently path effects are not |
| 180 | * allowed. |
| 181 | * The rects coords are used to access the paint (through texture matrix) |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 182 | */ |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 183 | void drawRect(const GrClip&, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 184 | GrPaint&& paint, |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 185 | GrAA, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 186 | const SkMatrix& viewMatrix, |
| 187 | const SkRect&, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 188 | const GrStyle* style = nullptr); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 189 | |
| 190 | /** |
bsalomon | a2e69fc | 2015-11-05 10:41:43 -0800 | [diff] [blame] | 191 | * Maps a rectangle of shader coordinates to a rectangle and fills that rectangle. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 192 | * |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 193 | * @param paint describes how to color pixels. |
| 194 | * @param GrAA Controls whether rect is antialiased |
| 195 | * @param viewMatrix transformation matrix which applies to rectToDraw |
| 196 | * @param rectToDraw the rectangle to draw |
| 197 | * @param localRect the rectangle of shader coordinates applied to rectToDraw |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 198 | */ |
Michael Ludwig | 136f45a | 2019-02-19 11:44:41 -0500 | [diff] [blame] | 199 | void fillRectToRect(const GrClip& clip, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 200 | GrPaint&& paint, |
Michael Ludwig | 136f45a | 2019-02-19 11:44:41 -0500 | [diff] [blame] | 201 | GrAA aa, |
bsalomon | a2e69fc | 2015-11-05 10:41:43 -0800 | [diff] [blame] | 202 | const SkMatrix& viewMatrix, |
| 203 | const SkRect& rectToDraw, |
Michael Ludwig | 136f45a | 2019-02-19 11:44:41 -0500 | [diff] [blame] | 204 | const SkRect& localRect) { |
Michael Ludwig | 6b45c5d | 2020-02-07 09:56:38 -0500 | [diff] [blame] | 205 | DrawQuad quad{GrQuad::MakeFromRect(rectToDraw, viewMatrix), GrQuad(localRect), |
| 206 | aa == GrAA::kYes ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone}; |
| 207 | this->drawFilledQuad(clip, std::move(paint), aa, &quad); |
Michael Ludwig | 136f45a | 2019-02-19 11:44:41 -0500 | [diff] [blame] | 208 | } |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 209 | |
| 210 | /** |
bsalomon | a2e69fc | 2015-11-05 10:41:43 -0800 | [diff] [blame] | 211 | * Fills a rect with a paint and a localMatrix. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 212 | */ |
bsalomon | a2e69fc | 2015-11-05 10:41:43 -0800 | [diff] [blame] | 213 | void fillRectWithLocalMatrix(const GrClip& clip, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 214 | GrPaint&& paint, |
Michael Ludwig | 6132820 | 2019-06-19 14:48:58 +0000 | [diff] [blame] | 215 | GrAA aa, |
bsalomon | a2e69fc | 2015-11-05 10:41:43 -0800 | [diff] [blame] | 216 | const SkMatrix& viewMatrix, |
| 217 | const SkRect& rect, |
Michael Ludwig | 6132820 | 2019-06-19 14:48:58 +0000 | [diff] [blame] | 218 | const SkMatrix& localMatrix) { |
Michael Ludwig | 6b45c5d | 2020-02-07 09:56:38 -0500 | [diff] [blame] | 219 | DrawQuad quad{GrQuad::MakeFromRect(rect, viewMatrix), |
| 220 | GrQuad::MakeFromRect(rect, localMatrix), |
| 221 | aa == GrAA::kYes ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone}; |
| 222 | this->drawFilledQuad(clip, std::move(paint), aa, &quad); |
Michael Ludwig | 6132820 | 2019-06-19 14:48:58 +0000 | [diff] [blame] | 223 | } |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 224 | |
Michael Ludwig | 7545190 | 2019-01-23 11:14:29 -0500 | [diff] [blame] | 225 | /** |
| 226 | * Creates an op that draws a fill rect with per-edge control over anti-aliasing. |
Michael Ludwig | ce62dec | 2019-02-19 11:48:46 -0500 | [diff] [blame] | 227 | * |
| 228 | * This is a specialized version of fillQuadWithEdgeAA, but is kept separate since knowing |
| 229 | * the geometry is a rectangle affords more optimizations. |
Michael Ludwig | 7545190 | 2019-01-23 11:14:29 -0500 | [diff] [blame] | 230 | */ |
Michael Ludwig | 136f45a | 2019-02-19 11:44:41 -0500 | [diff] [blame] | 231 | void fillRectWithEdgeAA(const GrClip& clip, GrPaint&& paint, GrAA aa, GrQuadAAFlags edgeAA, |
| 232 | const SkMatrix& viewMatrix, const SkRect& rect, |
Michael Ludwig | 6132820 | 2019-06-19 14:48:58 +0000 | [diff] [blame] | 233 | const SkRect* optionalLocalRect = nullptr) { |
| 234 | const SkRect& localRect = optionalLocalRect ? *optionalLocalRect : rect; |
Michael Ludwig | 6b45c5d | 2020-02-07 09:56:38 -0500 | [diff] [blame] | 235 | DrawQuad quad{GrQuad::MakeFromRect(rect, viewMatrix), GrQuad(localRect), edgeAA}; |
| 236 | this->drawFilledQuad(clip, std::move(paint), aa, &quad); |
Michael Ludwig | 6132820 | 2019-06-19 14:48:58 +0000 | [diff] [blame] | 237 | } |
Michael Ludwig | 7545190 | 2019-01-23 11:14:29 -0500 | [diff] [blame] | 238 | |
Michael Ludwig | ce62dec | 2019-02-19 11:48:46 -0500 | [diff] [blame] | 239 | /** |
| 240 | * Similar to fillRectWithEdgeAA but draws an arbitrary 2D convex quadrilateral transformed |
| 241 | * by 'viewMatrix', with per-edge control over anti-aliasing. The quad should follow the |
| 242 | * ordering used by SkRect::toQuad(), which determines how the edge AA is applied: |
| 243 | * - "top" = points [0] and [1] |
| 244 | * - "right" = points[1] and [2] |
| 245 | * - "bottom" = points[2] and [3] |
| 246 | * - "left" = points[3] and [0] |
| 247 | * |
| 248 | * The last argument, 'optionalLocalQuad', can be null if no separate local coordinates are |
| 249 | * necessary. |
| 250 | */ |
| 251 | void fillQuadWithEdgeAA(const GrClip& clip, GrPaint&& paint, GrAA aa, GrQuadAAFlags edgeAA, |
Michael Ludwig | 6b45c5d | 2020-02-07 09:56:38 -0500 | [diff] [blame] | 252 | const SkMatrix& viewMatrix, const SkPoint points[4], |
| 253 | const SkPoint optionalLocalPoints[4]) { |
| 254 | const SkPoint* localPoints = optionalLocalPoints ? optionalLocalPoints : points; |
| 255 | DrawQuad quad{GrQuad::MakeFromSkQuad(points, viewMatrix), |
| 256 | GrQuad::MakeFromSkQuad(localPoints, SkMatrix::I()), edgeAA}; |
| 257 | this->drawFilledQuad(clip, std::move(paint), aa, &quad); |
Michael Ludwig | 6132820 | 2019-06-19 14:48:58 +0000 | [diff] [blame] | 258 | } |
Michael Ludwig | ce62dec | 2019-02-19 11:48:46 -0500 | [diff] [blame] | 259 | |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 260 | /** Used with drawQuadSet */ |
| 261 | struct QuadSetEntry { |
| 262 | SkRect fRect; |
| 263 | SkPMColor4f fColor; // Overrides any color on the GrPaint |
| 264 | SkMatrix fLocalMatrix; |
| 265 | GrQuadAAFlags fAAFlags; |
| 266 | }; |
| 267 | |
Michael Ludwig | 7545190 | 2019-01-23 11:14:29 -0500 | [diff] [blame] | 268 | // TODO(michaelludwig) - remove if the bulk API is not useful for SkiaRenderer |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 269 | void drawQuadSet(const GrClip& clip, GrPaint&& paint, GrAA aa, const SkMatrix& viewMatrix, |
| 270 | const QuadSetEntry[], int cnt); |
| 271 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 272 | /** |
Brian Salomon | 3416969 | 2017-08-28 15:32:01 -0400 | [diff] [blame] | 273 | * Creates an op that draws a subrectangle of a texture. The passed color is modulated by the |
| 274 | * texture's color. 'srcRect' specifies the rectangle of the texture to draw. 'dstRect' |
| 275 | * specifies the rectangle to draw in local coords which will be transformed by 'viewMatrix' to |
Brian Salomon | be3c1d2 | 2018-05-21 12:54:39 -0400 | [diff] [blame] | 276 | * device space. |
Brian Salomon | 3416969 | 2017-08-28 15:32:01 -0400 | [diff] [blame] | 277 | */ |
Greg Daniel | 40903af | 2020-01-30 14:55:05 -0500 | [diff] [blame] | 278 | void drawTexture(const GrClip& clip, GrSurfaceProxyView view, SkAlphaType srcAlphaType, |
| 279 | GrSamplerState::Filter filter, SkBlendMode mode, const SkPMColor4f& color, |
| 280 | const SkRect& srcRect, const SkRect& dstRect, GrAA aa, GrQuadAAFlags edgeAA, |
| 281 | SkCanvas::SrcRectConstraint constraint, const SkMatrix& viewMatrix, |
| 282 | sk_sp<GrColorSpaceXform> texXform) { |
Brian Salomon | 2432d06 | 2020-04-16 20:48:09 -0400 | [diff] [blame] | 283 | const SkRect* subset = constraint == SkCanvas::kStrict_SrcRectConstraint ? |
Michael Ludwig | aee26ea | 2019-07-08 16:22:48 +0000 | [diff] [blame] | 284 | &srcRect : nullptr; |
Michael Ludwig | 6b45c5d | 2020-02-07 09:56:38 -0500 | [diff] [blame] | 285 | DrawQuad quad{GrQuad::MakeFromRect(dstRect, viewMatrix), GrQuad(srcRect), edgeAA}; |
| 286 | |
Greg Daniel | 40903af | 2020-01-30 14:55:05 -0500 | [diff] [blame] | 287 | this->drawTexturedQuad(clip, std::move(view), srcAlphaType, std::move(texXform), |
Brian Salomon | 2432d06 | 2020-04-16 20:48:09 -0400 | [diff] [blame] | 288 | filter, color, mode, aa, &quad, subset); |
Michael Ludwig | aee26ea | 2019-07-08 16:22:48 +0000 | [diff] [blame] | 289 | } |
Brian Salomon | 3416969 | 2017-08-28 15:32:01 -0400 | [diff] [blame] | 290 | |
Michael Ludwig | ce62dec | 2019-02-19 11:48:46 -0500 | [diff] [blame] | 291 | /** |
| 292 | * Variant of drawTexture that instead draws the texture applied to 'dstQuad' transformed by |
Brian Salomon | 2432d06 | 2020-04-16 20:48:09 -0400 | [diff] [blame] | 293 | * 'viewMatrix', using the 'srcQuad' texture coordinates clamped to the optional 'subset'. If |
| 294 | * 'subset' is null, it's equivalent to using the fast src rect constraint. If 'subset' is |
| 295 | * provided, the strict src rect constraint is applied using 'subset'. |
Michael Ludwig | ce62dec | 2019-02-19 11:48:46 -0500 | [diff] [blame] | 296 | */ |
Greg Daniel | 2f3cd4f | 2020-02-07 11:07:25 -0500 | [diff] [blame] | 297 | void drawTextureQuad(const GrClip& clip, GrSurfaceProxyView view, GrColorType srcColorType, |
Brian Salomon | fc11844 | 2019-11-22 19:09:27 -0500 | [diff] [blame] | 298 | SkAlphaType srcAlphaType, GrSamplerState::Filter filter, SkBlendMode mode, |
| 299 | const SkPMColor4f& color, const SkPoint srcQuad[4], |
| 300 | const SkPoint dstQuad[4], GrAA aa, GrQuadAAFlags edgeAA, |
Brian Salomon | 2432d06 | 2020-04-16 20:48:09 -0400 | [diff] [blame] | 301 | const SkRect* subset, const SkMatrix& viewMatrix, |
Michael Ludwig | aee26ea | 2019-07-08 16:22:48 +0000 | [diff] [blame] | 302 | sk_sp<GrColorSpaceXform> texXform) { |
Michael Ludwig | 6b45c5d | 2020-02-07 09:56:38 -0500 | [diff] [blame] | 303 | DrawQuad quad{GrQuad::MakeFromSkQuad(dstQuad, viewMatrix), |
| 304 | GrQuad::MakeFromSkQuad(srcQuad, SkMatrix::I()), edgeAA}; |
Greg Daniel | 2f3cd4f | 2020-02-07 11:07:25 -0500 | [diff] [blame] | 305 | this->drawTexturedQuad(clip, std::move(view), srcAlphaType, std::move(texXform), |
Brian Salomon | 2432d06 | 2020-04-16 20:48:09 -0400 | [diff] [blame] | 306 | filter, color, mode, aa, &quad, subset); |
Michael Ludwig | aee26ea | 2019-07-08 16:22:48 +0000 | [diff] [blame] | 307 | } |
Michael Ludwig | ce62dec | 2019-02-19 11:48:46 -0500 | [diff] [blame] | 308 | |
Brian Salomon | d7065e7 | 2018-10-12 11:42:02 -0400 | [diff] [blame] | 309 | /** Used with drawTextureSet */ |
| 310 | struct TextureSetEntry { |
Greg Daniel | 549325c | 2019-10-30 16:19:20 -0400 | [diff] [blame] | 311 | GrSurfaceProxyView fProxyView; |
Brian Salomon | fc11844 | 2019-11-22 19:09:27 -0500 | [diff] [blame] | 312 | SkAlphaType fSrcAlphaType; |
Brian Salomon | d7065e7 | 2018-10-12 11:42:02 -0400 | [diff] [blame] | 313 | SkRect fSrcRect; |
| 314 | SkRect fDstRect; |
Michael Ludwig | 1433cfd | 2019-02-27 17:12:30 -0500 | [diff] [blame] | 315 | const SkPoint* fDstClipQuad; // Must be null, or point to an array of 4 points |
Michael Ludwig | 7ae2ab5 | 2019-03-05 16:00:20 -0500 | [diff] [blame] | 316 | const SkMatrix* fPreViewMatrix; // If not null, entry's CTM is 'viewMatrix' * fPreViewMatrix |
Brian Salomon | 1da5cad | 2018-11-21 09:21:18 -0500 | [diff] [blame] | 317 | float fAlpha; |
Brian Salomon | d7065e7 | 2018-10-12 11:42:02 -0400 | [diff] [blame] | 318 | GrQuadAAFlags fAAFlags; |
| 319 | }; |
| 320 | /** |
| 321 | * Draws a set of textures with a shared filter, color, view matrix, color xform, and |
| 322 | * texture color xform. The textures must all have the same GrTextureType and GrConfig. |
Michael Ludwig | ce62dec | 2019-02-19 11:48:46 -0500 | [diff] [blame] | 323 | * |
| 324 | * If any entries provide a non-null fDstClip array, it will be read from immediately based on |
| 325 | * fDstClipCount, so the pointer can become invalid after this returns. |
Michael Ludwig | 379e496 | 2019-12-06 13:21:26 -0500 | [diff] [blame] | 326 | * |
Hal Canary | 425929c | 2019-12-09 11:55:40 -0500 | [diff] [blame] | 327 | * 'proxRunCnt' is the number of proxy changes encountered in the entry array. Technically this |
Michael Ludwig | 379e496 | 2019-12-06 13:21:26 -0500 | [diff] [blame] | 328 | * can be inferred from the array within this function, but the information is already known |
| 329 | * by SkGpuDevice, so no need to incur another iteration over the array. |
Brian Salomon | d7065e7 | 2018-10-12 11:42:02 -0400 | [diff] [blame] | 330 | */ |
Hal Canary | 425929c | 2019-12-09 11:55:40 -0500 | [diff] [blame] | 331 | void drawTextureSet(const GrClip&, TextureSetEntry[], int cnt, int proxyRunCnt, |
Michael Ludwig | 379e496 | 2019-12-06 13:21:26 -0500 | [diff] [blame] | 332 | GrSamplerState::Filter, SkBlendMode mode, GrAA aa, |
| 333 | SkCanvas::SrcRectConstraint, const SkMatrix& viewMatrix, |
| 334 | sk_sp<GrColorSpaceXform> texXform); |
Brian Salomon | d7065e7 | 2018-10-12 11:42:02 -0400 | [diff] [blame] | 335 | |
Brian Salomon | 3416969 | 2017-08-28 15:32:01 -0400 | [diff] [blame] | 336 | /** |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 337 | * Draw a roundrect using a paint. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 338 | * |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 339 | * @param paint describes how to color pixels. |
| 340 | * @param GrAA Controls whether rrect is antialiased. |
| 341 | * @param viewMatrix transformation matrix |
| 342 | * @param rrect the roundrect to draw |
| 343 | * @param style style to apply to the rrect. Currently path effects are not allowed. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 344 | */ |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 345 | void drawRRect(const GrClip&, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 346 | GrPaint&&, |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 347 | GrAA, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 348 | const SkMatrix& viewMatrix, |
| 349 | const SkRRect& rrect, |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 350 | const GrStyle& style); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 351 | |
| 352 | /** |
Jim Van Verth | 3af1af9 | 2017-05-18 15:06:54 -0400 | [diff] [blame] | 353 | * Use a fast method to render the ambient and spot shadows for a path. |
| 354 | * Will return false if not possible for the given path. |
Jim Van Verth | c590341 | 2016-11-17 15:27:09 -0500 | [diff] [blame] | 355 | * |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 356 | * @param viewMatrix transformation matrix |
Jim Van Verth | 3af1af9 | 2017-05-18 15:06:54 -0400 | [diff] [blame] | 357 | * @param path the path to shadow |
| 358 | * @param rec parameters for shadow rendering |
Jim Van Verth | c590341 | 2016-11-17 15:27:09 -0500 | [diff] [blame] | 359 | */ |
Jim Van Verth | 3af1af9 | 2017-05-18 15:06:54 -0400 | [diff] [blame] | 360 | bool drawFastShadow(const GrClip&, |
Jim Van Verth | 3af1af9 | 2017-05-18 15:06:54 -0400 | [diff] [blame] | 361 | const SkMatrix& viewMatrix, |
| 362 | const SkPath& path, |
| 363 | const SkDrawShadowRec& rec); |
Jim Van Verth | c590341 | 2016-11-17 15:27:09 -0500 | [diff] [blame] | 364 | |
| 365 | /** |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 366 | * Shortcut for filling a SkPath consisting of nested rrects using a paint. The result is |
| 367 | * undefined if outer does not contain inner. |
robertphillips | 0009589 | 2016-02-29 13:50:40 -0800 | [diff] [blame] | 368 | * |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 369 | * @param paint describes how to color pixels. |
| 370 | * @param GrAA Controls whether rrects edges are antialiased |
| 371 | * @param viewMatrix transformation matrix |
| 372 | * @param outer the outer roundrect |
| 373 | * @param inner the inner roundrect |
robertphillips | 0009589 | 2016-02-29 13:50:40 -0800 | [diff] [blame] | 374 | */ |
| 375 | void drawDRRect(const GrClip&, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 376 | GrPaint&&, |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 377 | GrAA, |
robertphillips | 0009589 | 2016-02-29 13:50:40 -0800 | [diff] [blame] | 378 | const SkMatrix& viewMatrix, |
| 379 | const SkRRect& outer, |
| 380 | const SkRRect& inner); |
| 381 | |
| 382 | /** |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 383 | * Draws a path. |
| 384 | * |
| 385 | * @param paint describes how to color pixels. |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 386 | * @param GrAA Controls whether the path is antialiased. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 387 | * @param viewMatrix transformation matrix |
| 388 | * @param path the path to draw |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 389 | * @param style style to apply to the path. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 390 | */ |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 391 | void drawPath(const GrClip&, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 392 | GrPaint&&, |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 393 | GrAA, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 394 | const SkMatrix& viewMatrix, |
| 395 | const SkPath&, |
Robert Phillips | 20390c3 | 2018-08-17 11:01:03 -0400 | [diff] [blame] | 396 | const GrStyle&); |
| 397 | |
| 398 | /** |
| 399 | * Draws a shape. |
| 400 | * |
| 401 | * @param paint describes how to color pixels. |
| 402 | * @param GrAA Controls whether the path is antialiased. |
| 403 | * @param viewMatrix transformation matrix |
| 404 | * @param shape the shape to draw |
| 405 | */ |
| 406 | void drawShape(const GrClip&, |
| 407 | GrPaint&&, |
| 408 | GrAA, |
| 409 | const SkMatrix& viewMatrix, |
Michael Ludwig | 2686d69 | 2020-04-17 20:21:37 +0000 | [diff] [blame] | 410 | const GrStyledShape&); |
Robert Phillips | 20390c3 | 2018-08-17 11:01:03 -0400 | [diff] [blame] | 411 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 412 | |
| 413 | /** |
| 414 | * Draws vertices with a paint. |
| 415 | * |
Brian Osman | ae0c50c | 2017-05-25 16:56:34 -0400 | [diff] [blame] | 416 | * @param paint describes how to color pixels. |
| 417 | * @param viewMatrix transformation matrix |
| 418 | * @param vertices specifies the mesh to draw. |
| 419 | * @param overridePrimType primitive type to draw. If NULL, derive prim type from vertices. |
Brian Osman | 3c35842 | 2020-03-23 10:44:12 -0400 | [diff] [blame] | 420 | * @param effect runtime effect that will handle custom vertex attributes. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 421 | */ |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 422 | void drawVertices(const GrClip&, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 423 | GrPaint&& paint, |
Brian Osman | 449b115 | 2020-04-15 16:43:00 -0400 | [diff] [blame] | 424 | const SkMatrixProvider& matrixProvider, |
Brian Osman | ae0c50c | 2017-05-25 16:56:34 -0400 | [diff] [blame] | 425 | sk_sp<SkVertices> vertices, |
Brian Osman | 3c35842 | 2020-03-23 10:44:12 -0400 | [diff] [blame] | 426 | GrPrimitiveType* overridePrimType = nullptr, |
Brian Osman | 449b115 | 2020-04-15 16:43:00 -0400 | [diff] [blame] | 427 | const SkRuntimeEffect* effect = nullptr); |
Brian Salomon | 199fb87 | 2017-02-06 09:41:10 -0500 | [diff] [blame] | 428 | |
| 429 | /** |
Brian Osman | 4d92b89 | 2019-03-24 00:53:23 +0000 | [diff] [blame] | 430 | * Draws textured sprites from an atlas with a paint. This currently does not support AA for the |
| 431 | * sprite rectangle edges. |
| 432 | * |
| 433 | * @param paint describes how to color pixels. |
| 434 | * @param viewMatrix transformation matrix |
| 435 | * @param spriteCount number of sprites. |
| 436 | * @param xform array of compressed transformation data, required. |
| 437 | * @param texRect array of texture rectangles used to access the paint. |
| 438 | * @param colors optional array of per-sprite colors, supercedes |
| 439 | * the paint's color field. |
| 440 | */ |
| 441 | void drawAtlas(const GrClip&, |
| 442 | GrPaint&& paint, |
| 443 | const SkMatrix& viewMatrix, |
| 444 | int spriteCount, |
| 445 | const SkRSXform xform[], |
| 446 | const SkRect texRect[], |
| 447 | const SkColor colors[]); |
| 448 | |
| 449 | /** |
msarett | cc319b9 | 2016-08-25 18:07:18 -0700 | [diff] [blame] | 450 | * Draws a region. |
| 451 | * |
| 452 | * @param paint describes how to color pixels |
| 453 | * @param viewMatrix transformation matrix |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 454 | * @param aa should the rects of the region be antialiased. |
msarett | cc319b9 | 2016-08-25 18:07:18 -0700 | [diff] [blame] | 455 | * @param region the region to be drawn |
| 456 | * @param style style to apply to the region |
| 457 | */ |
| 458 | void drawRegion(const GrClip&, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 459 | GrPaint&& paint, |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 460 | GrAA aa, |
msarett | cc319b9 | 2016-08-25 18:07:18 -0700 | [diff] [blame] | 461 | const SkMatrix& viewMatrix, |
| 462 | const SkRegion& region, |
Stan Iliev | 73d8fd9 | 2017-08-02 15:36:24 -0400 | [diff] [blame] | 463 | const GrStyle& style, |
| 464 | const GrUserStencilSettings* ss = nullptr); |
msarett | cc319b9 | 2016-08-25 18:07:18 -0700 | [diff] [blame] | 465 | |
jvanverth | 31ff762 | 2015-08-07 10:09:28 -0700 | [diff] [blame] | 466 | /** |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 467 | * Draws an oval. |
| 468 | * |
| 469 | * @param paint describes how to color pixels. |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 470 | * @param GrAA Controls whether the oval is antialiased. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 471 | * @param viewMatrix transformation matrix |
| 472 | * @param oval the bounding rect of the oval. |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 473 | * @param style style to apply to the oval. Currently path effects are not allowed. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 474 | */ |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 475 | void drawOval(const GrClip&, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 476 | GrPaint&& paint, |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 477 | GrAA, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 478 | const SkMatrix& viewMatrix, |
| 479 | const SkRect& oval, |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 480 | const GrStyle& style); |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 481 | /** |
| 482 | * Draws a partial arc of an oval. |
| 483 | * |
| 484 | * @param paint describes how to color pixels. |
Brian Salomon | 9950408 | 2016-12-09 15:51:31 -0500 | [diff] [blame] | 485 | * @param GrGrAA Controls whether the arc is antialiased. |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 486 | * @param viewMatrix transformation matrix. |
| 487 | * @param oval the bounding rect of the oval. |
| 488 | * @param startAngle starting angle in degrees. |
| 489 | * @param sweepAngle angle to sweep in degrees. Must be in (-360, 360) |
| 490 | * @param useCenter true means that the implied path begins at the oval center, connects as |
| 491 | * a line to the point indicated by the start contains the arc indicated by |
| 492 | * the sweep angle. If false the line beginning at the center point is |
| 493 | * omitted. |
| 494 | * @param style style to apply to the oval. |
| 495 | */ |
bsalomon | 4f3a0ca | 2016-08-22 13:14:26 -0700 | [diff] [blame] | 496 | void drawArc(const GrClip&, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 497 | GrPaint&& paint, |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 498 | GrAA, |
bsalomon | 4f3a0ca | 2016-08-22 13:14:26 -0700 | [diff] [blame] | 499 | const SkMatrix& viewMatrix, |
| 500 | const SkRect& oval, |
| 501 | SkScalar startAngle, |
| 502 | SkScalar sweepAngle, |
| 503 | bool useCenter, |
| 504 | const GrStyle& style); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 505 | |
joshualitt | 33a5fce | 2015-11-18 13:28:51 -0800 | [diff] [blame] | 506 | /** |
bsalomon | 4f3a0ca | 2016-08-22 13:14:26 -0700 | [diff] [blame] | 507 | * Draw the image as a set of rects, specified by |iter|. |
joshualitt | 33a5fce | 2015-11-18 13:28:51 -0800 | [diff] [blame] | 508 | */ |
msarett | 10e3d9b | 2016-08-18 15:46:03 -0700 | [diff] [blame] | 509 | void drawImageLattice(const GrClip&, |
Brian Salomon | 2a943df | 2018-05-04 13:43:19 -0400 | [diff] [blame] | 510 | GrPaint&&, |
msarett | 10e3d9b | 2016-08-18 15:46:03 -0700 | [diff] [blame] | 511 | const SkMatrix& viewMatrix, |
Greg Daniel | ed96bca | 2019-12-05 15:05:54 -0500 | [diff] [blame] | 512 | GrSurfaceProxyView, |
Greg Daniel | 82c6b10 | 2020-01-21 10:33:22 -0500 | [diff] [blame] | 513 | SkAlphaType alphaType, |
Brian Salomon | 2a943df | 2018-05-04 13:43:19 -0400 | [diff] [blame] | 514 | sk_sp<GrColorSpaceXform>, |
| 515 | GrSamplerState::Filter, |
| 516 | std::unique_ptr<SkLatticeIter>, |
msarett | 10e3d9b | 2016-08-18 15:46:03 -0700 | [diff] [blame] | 517 | const SkRect& dst); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 518 | |
robertphillips | 8c523e0 | 2016-07-26 07:41:00 -0700 | [diff] [blame] | 519 | /** |
Greg Daniel | 46cfbc6 | 2019-06-07 11:43:30 -0400 | [diff] [blame] | 520 | * Draws the src texture with no matrix. The dstRect is the dstPoint with the width and height |
| 521 | * of the srcRect. The srcRect and dstRect are clipped to the bounds of the src and dst surfaces |
| 522 | * respectively. |
| 523 | */ |
Greg Daniel | 573312e | 2020-02-07 17:22:35 -0500 | [diff] [blame] | 524 | bool blitTexture(GrSurfaceProxyView view, const SkIRect& srcRect, const SkIPoint& dstPoint); |
Greg Daniel | 46cfbc6 | 2019-06-07 11:43:30 -0400 | [diff] [blame] | 525 | |
| 526 | /** |
Greg Daniel | 64cc9aa | 2018-10-19 13:54:56 -0400 | [diff] [blame] | 527 | * Adds the necessary signal and wait semaphores and adds the passed in SkDrawable to the |
| 528 | * command stream. |
| 529 | */ |
| 530 | void drawDrawable(std::unique_ptr<SkDrawable::GpuDrawHandler>, const SkRect& bounds); |
| 531 | |
Brian Salomon | ab32f65 | 2019-05-10 14:24:50 -0400 | [diff] [blame] | 532 | using ReadPixelsCallback = SkSurface::ReadPixelsCallback; |
| 533 | using ReadPixelsContext = SkSurface::ReadPixelsContext; |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 534 | using RescaleGamma = SkSurface::RescaleGamma; |
| 535 | |
| 536 | // GPU implementation for SkSurface::asyncRescaleAndReadPixels. |
Brian Salomon | 031b0ba | 2019-05-23 11:05:26 -0400 | [diff] [blame] | 537 | void asyncRescaleAndReadPixels(const SkImageInfo& info, const SkIRect& srcRect, |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 538 | RescaleGamma rescaleGamma, SkFilterQuality rescaleQuality, |
| 539 | ReadPixelsCallback callback, ReadPixelsContext context); |
| 540 | // GPU implementation for SkSurface::asyncRescaleAndReadPixelsYUV420. |
| 541 | void asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace, |
Brian Salomon | 9241a6d | 2019-10-03 13:26:54 -0400 | [diff] [blame] | 542 | sk_sp<SkColorSpace> dstColorSpace, |
| 543 | const SkIRect& srcRect, |
Brian Salomon | a56a746 | 2020-02-07 14:17:25 -0500 | [diff] [blame] | 544 | SkISize dstSize, |
Brian Salomon | 9241a6d | 2019-10-03 13:26:54 -0400 | [diff] [blame] | 545 | RescaleGamma rescaleGamma, |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 546 | SkFilterQuality rescaleQuality, |
Brian Salomon | 9241a6d | 2019-10-03 13:26:54 -0400 | [diff] [blame] | 547 | ReadPixelsCallback callback, |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 548 | ReadPixelsContext context); |
Brian Salomon | ab32f65 | 2019-05-10 14:24:50 -0400 | [diff] [blame] | 549 | |
Greg Daniel | 64cc9aa | 2018-10-19 13:54:56 -0400 | [diff] [blame] | 550 | /** |
robertphillips | 8c523e0 | 2016-07-26 07:41:00 -0700 | [diff] [blame] | 551 | * After this returns any pending surface IO will be issued to the backend 3D API and |
| 552 | * if the surface has MSAA it will be resolved. |
| 553 | */ |
Greg Daniel | e6bfb7d | 2019-04-17 15:26:11 -0400 | [diff] [blame] | 554 | GrSemaphoresSubmitted flush(SkSurface::BackendSurfaceAccess access, const GrFlushInfo&); |
Greg Daniel | a5cb781 | 2017-06-16 09:45:32 -0400 | [diff] [blame] | 555 | |
| 556 | /** |
| 557 | * The next time this GrRenderTargetContext is flushed, the gpu will wait on the passed in |
| 558 | * semaphores before executing any commands. |
| 559 | */ |
Robert Phillips | bc4994a | 2019-02-14 08:36:56 -0500 | [diff] [blame] | 560 | bool waitOnSemaphores(int numSemaphores, const GrBackendSemaphore waitSemaphores[]); |
robertphillips | 8c523e0 | 2016-07-26 07:41:00 -0700 | [diff] [blame] | 561 | |
Greg Daniel | 46e366a | 2019-12-16 14:38:36 -0500 | [diff] [blame] | 562 | int numSamples() const { return this->asRenderTargetProxy()->numSamples(); } |
robertphillips | ca6eafc | 2016-05-17 09:57:46 -0700 | [diff] [blame] | 563 | const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; } |
Greg Daniel | 46e366a | 2019-12-16 14:38:36 -0500 | [diff] [blame] | 564 | bool wrapsVkSecondaryCB() const { return this->asRenderTargetProxy()->wrapsVkSecondaryCB(); } |
Greg Daniel | e252f08 | 2017-10-23 16:05:23 -0400 | [diff] [blame] | 565 | GrMipMapped mipMapped() const; |
robertphillips | 7bceedc | 2015-12-01 12:51:26 -0800 | [diff] [blame] | 566 | |
Greg Daniel | 3912a4b | 2020-01-14 09:56:04 -0500 | [diff] [blame] | 567 | // TODO: See if it makes sense for this to return a const& instead and require the callers to |
| 568 | // make a copy (which refs the proxy) if needed. |
Brian Salomon | 8afde5f | 2020-04-01 16:22:00 -0400 | [diff] [blame] | 569 | GrSurfaceProxyView writeSurfaceView() { return fWriteView; } |
Greg Daniel | a83de58 | 2019-10-22 09:33:25 -0400 | [diff] [blame] | 570 | |
Robert Phillips | be9aff2 | 2019-02-15 11:33:22 -0500 | [diff] [blame] | 571 | // This entry point should only be called if the backing GPU object is known to be |
| 572 | // instantiated. |
Greg Daniel | 3912a4b | 2020-01-14 09:56:04 -0500 | [diff] [blame] | 573 | GrRenderTarget* accessRenderTarget() { return this->asSurfaceProxy()->peekRenderTarget(); } |
Robert Phillips | eaa8625 | 2016-11-08 13:49:39 +0000 | [diff] [blame] | 574 | |
Robert Phillips | d46697a | 2017-01-25 12:10:37 -0500 | [diff] [blame] | 575 | GrRenderTargetContext* asRenderTargetContext() override { return this; } |
| 576 | |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 577 | // Provides access to functions that aren't part of the public API. |
Brian Osman | 693a540 | 2016-10-27 15:13:22 -0400 | [diff] [blame] | 578 | GrRenderTargetContextPriv priv(); |
| 579 | const GrRenderTargetContextPriv priv() const; |
joshualitt | f5883a6 | 2016-01-13 07:47:38 -0800 | [diff] [blame] | 580 | |
Herb Derby | c1b482c | 2018-08-09 15:02:27 -0400 | [diff] [blame] | 581 | GrTextTarget* textTarget() { return fTextTarget.get(); } |
Brian Salomon | f18b1d8 | 2017-10-27 11:30:49 -0400 | [diff] [blame] | 582 | |
Brian Salomon | 3b8486a | 2020-04-21 12:43:26 -0400 | [diff] [blame] | 583 | void wasClosed(const GrOpsTask& task) override; |
| 584 | |
Robert Phillips | b520476 | 2019-06-19 14:12:13 -0400 | [diff] [blame] | 585 | #if GR_TEST_UTILS |
Greg Daniel | 3912a4b | 2020-01-14 09:56:04 -0500 | [diff] [blame] | 586 | bool testingOnly_IsInstantiated() const { return this->asSurfaceProxy()->isInstantiated(); } |
Chris Dalton | 6b98280 | 2019-06-27 13:53:46 -0600 | [diff] [blame] | 587 | void testingOnly_SetPreserveOpsOnFullClear() { fPreserveOpsOnFullClear_TestingOnly = true; } |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 588 | GrOpsTask* testingOnly_PeekLastOpsTask() { return fOpsTask.get(); } |
Robert Phillips | b520476 | 2019-06-19 14:12:13 -0400 | [diff] [blame] | 589 | #endif |
Robert Phillips | eaa8625 | 2016-11-08 13:49:39 +0000 | [diff] [blame] | 590 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 591 | private: |
Brian Salomon | f18b1d8 | 2017-10-27 11:30:49 -0400 | [diff] [blame] | 592 | class TextTarget; |
Michael Ludwig | 6132820 | 2019-06-19 14:48:58 +0000 | [diff] [blame] | 593 | enum class QuadOptimization; |
Brian Salomon | f18b1d8 | 2017-10-27 11:30:49 -0400 | [diff] [blame] | 594 | |
Chris Dalton | 7d6748e | 2019-03-13 00:34:52 -0600 | [diff] [blame] | 595 | GrAAType chooseAAType(GrAA); |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 596 | |
Brian Salomon | 649a341 | 2017-03-09 13:50:43 -0500 | [diff] [blame] | 597 | friend class GrAtlasTextBlob; // for access to add[Mesh]DrawOp |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 598 | friend class GrClipStackClip; // for access to getOpsTask |
Chris Dalton | c4b4735 | 2019-08-23 10:10:36 -0600 | [diff] [blame] | 599 | friend class GrOnFlushResourceProvider; // for access to getOpsTask (http://skbug.com/9357) |
robertphillips | 55fdccc | 2016-06-06 06:16:20 -0700 | [diff] [blame] | 600 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 601 | friend class GrRenderTargetContextPriv; |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 602 | |
Brian Salomon | 42521e8 | 2016-12-07 16:44:58 -0500 | [diff] [blame] | 603 | // All the path renderers currently make their own ops |
Brian Salomon | 649a341 | 2017-03-09 13:50:43 -0500 | [diff] [blame] | 604 | friend class GrSoftwarePathRenderer; // for access to add[Mesh]DrawOp |
| 605 | friend class GrAAConvexPathRenderer; // for access to add[Mesh]DrawOp |
| 606 | friend class GrDashLinePathRenderer; // for access to add[Mesh]DrawOp |
| 607 | friend class GrAAHairLinePathRenderer; // for access to add[Mesh]DrawOp |
| 608 | friend class GrAALinearizingConvexPathRenderer; // for access to add[Mesh]DrawOp |
Jim Van Verth | 8301046 | 2017-03-16 08:45:39 -0400 | [diff] [blame] | 609 | friend class GrSmallPathRenderer; // for access to add[Mesh]DrawOp |
Brian Salomon | 649a341 | 2017-03-09 13:50:43 -0500 | [diff] [blame] | 610 | friend class GrDefaultPathRenderer; // for access to add[Mesh]DrawOp |
Brian Salomon | 649a341 | 2017-03-09 13:50:43 -0500 | [diff] [blame] | 611 | friend class GrStencilAndCoverPathRenderer; // for access to add[Mesh]DrawOp |
Chris Dalton | 17dc418 | 2020-03-25 16:18:16 -0600 | [diff] [blame] | 612 | friend class GrTriangulatingPathRenderer; // for access to add[Mesh]DrawOp |
Chris Dalton | 9414c96 | 2018-06-14 10:14:50 -0600 | [diff] [blame] | 613 | friend class GrCCPerFlushResources; // for access to addDrawOp |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 614 | friend class GrCoverageCountingPathRenderer; // for access to addDrawOp |
Robert Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 615 | friend class GrFillRectOp; // for access to addDrawOp |
Chris Dalton | 0a22b1e | 2020-03-26 11:52:15 -0600 | [diff] [blame] | 616 | friend class GrTessellationPathRenderer; // for access to addDrawOp |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 617 | friend class GrTextureOp; // for access to addDrawOp |
Robert Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 618 | |
Greg Daniel | 46e366a | 2019-12-16 14:38:36 -0500 | [diff] [blame] | 619 | SkDEBUGCODE(void onValidate() const override;) |
Greg Daniel | a83de58 | 2019-10-22 09:33:25 -0400 | [diff] [blame] | 620 | |
| 621 | |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 622 | GrOpsTask::CanDiscardPreviousOps canDiscardPreviousOpsOnFullClear() const; |
Chris Dalton | 858cf23 | 2019-10-14 16:20:00 -0600 | [diff] [blame] | 623 | void setNeedsStencil(bool useMixedSamplesIfNotMSAA); |
Chris Dalton | 6b98280 | 2019-06-27 13:53:46 -0600 | [diff] [blame] | 624 | |
Brian Osman | 9a9baae | 2018-11-05 15:06:26 -0500 | [diff] [blame] | 625 | void internalClear(const GrFixedClip&, const SkPMColor4f&, CanClearFullscreen); |
Michael Ludwig | c39d0c8 | 2019-01-15 10:03:43 -0500 | [diff] [blame] | 626 | void internalStencilClear(const GrFixedClip&, bool insideStencilMask); |
csmartdalton | 29df760 | 2016-08-31 11:55:52 -0700 | [diff] [blame] | 627 | |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 628 | // Only consumes the GrPaint if successful. |
robertphillips | 0009589 | 2016-02-29 13:50:40 -0800 | [diff] [blame] | 629 | bool drawFilledDRRect(const GrClip& clip, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 630 | GrPaint&& paint, |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 631 | GrAA, |
robertphillips | 0009589 | 2016-02-29 13:50:40 -0800 | [diff] [blame] | 632 | const SkMatrix& viewMatrix, |
| 633 | const SkRRect& origOuter, |
| 634 | const SkRRect& origInner); |
| 635 | |
Michael Ludwig | 6132820 | 2019-06-19 14:48:58 +0000 | [diff] [blame] | 636 | // If the drawn quad's paint is a const blended color, provide it as a non-null pointer to |
| 637 | // 'constColor', which enables the draw-as-clear optimization. Otherwise it is assumed the paint |
| 638 | // requires some form of shading that invalidates using a clear op. |
| 639 | // |
| 640 | // The non-const pointers should be the original draw request on input, and will be updated as |
| 641 | // appropriate depending on the returned optimization level. |
| 642 | // |
Michael Ludwig | e08b443 | 2019-06-19 18:00:48 -0400 | [diff] [blame] | 643 | // 'stencilSettings' are provided merely for decision making purposes; When non-null, |
| 644 | // optimization strategies that submit special ops are avoided. |
Michael Ludwig | 6132820 | 2019-06-19 14:48:58 +0000 | [diff] [blame] | 645 | QuadOptimization attemptQuadOptimization(const GrClip& clip, |
| 646 | const SkPMColor4f* constColor, |
Michael Ludwig | e08b443 | 2019-06-19 18:00:48 -0400 | [diff] [blame] | 647 | const GrUserStencilSettings* stencilSettings, |
Michael Ludwig | 6132820 | 2019-06-19 14:48:58 +0000 | [diff] [blame] | 648 | GrAA* aa, |
Michael Ludwig | 6b45c5d | 2020-02-07 09:56:38 -0500 | [diff] [blame] | 649 | DrawQuad* quad); |
robertphillips | 4430239 | 2016-07-08 14:43:03 -0700 | [diff] [blame] | 650 | |
Michael Ludwig | 6132820 | 2019-06-19 14:48:58 +0000 | [diff] [blame] | 651 | // If stencil settings, 'ss', are non-null, AA controls MSAA or no AA. If they are null, then AA |
| 652 | // can choose between coverage, MSAA as per chooseAAType(). This will always attempt to apply |
| 653 | // quad optimizations, so all quad/rect public APIs should rely on this function for consistent |
Michael Ludwig | 6b45c5d | 2020-02-07 09:56:38 -0500 | [diff] [blame] | 654 | // clipping behavior. 'quad' will be modified in place to reflect final rendered geometry. |
Michael Ludwig | 6132820 | 2019-06-19 14:48:58 +0000 | [diff] [blame] | 655 | void drawFilledQuad(const GrClip& clip, |
| 656 | GrPaint&& paint, |
| 657 | GrAA aa, |
Michael Ludwig | 6b45c5d | 2020-02-07 09:56:38 -0500 | [diff] [blame] | 658 | DrawQuad* quad, |
Michael Ludwig | 6132820 | 2019-06-19 14:48:58 +0000 | [diff] [blame] | 659 | const GrUserStencilSettings* ss = nullptr); |
Brian Salomon | 7694b90 | 2019-06-18 21:00:21 +0000 | [diff] [blame] | 660 | |
Michael Ludwig | 6b45c5d | 2020-02-07 09:56:38 -0500 | [diff] [blame] | 661 | // Like drawFilledQuad but does not require using a GrPaint or FP for texturing. |
| 662 | // 'quad' may be modified in place to reflect final geometry. |
Michael Ludwig | aee26ea | 2019-07-08 16:22:48 +0000 | [diff] [blame] | 663 | void drawTexturedQuad(const GrClip& clip, |
Greg Daniel | 549325c | 2019-10-30 16:19:20 -0400 | [diff] [blame] | 664 | GrSurfaceProxyView proxyView, |
Brian Salomon | fc11844 | 2019-11-22 19:09:27 -0500 | [diff] [blame] | 665 | SkAlphaType alphaType, |
Michael Ludwig | aee26ea | 2019-07-08 16:22:48 +0000 | [diff] [blame] | 666 | sk_sp<GrColorSpaceXform> textureXform, |
| 667 | GrSamplerState::Filter filter, |
| 668 | const SkPMColor4f& color, |
| 669 | SkBlendMode blendMode, |
| 670 | GrAA aa, |
Michael Ludwig | 6b45c5d | 2020-02-07 09:56:38 -0500 | [diff] [blame] | 671 | DrawQuad* quad, |
Brian Salomon | 2432d06 | 2020-04-16 20:48:09 -0400 | [diff] [blame] | 672 | const SkRect* subset = nullptr); |
Michael Ludwig | aee26ea | 2019-07-08 16:22:48 +0000 | [diff] [blame] | 673 | |
Michael Ludwig | 6a6de65 | 2020-04-30 20:16:36 -0400 | [diff] [blame^] | 674 | // If 'attemptShapeFallback' is true, and the original shape had been simplfied, this |
| 675 | // will re-route through drawShape() to see if we can avoid path rendering one more time. |
Brian Salomon | 2fad74a | 2017-12-20 13:28:55 -0500 | [diff] [blame] | 676 | void drawShapeUsingPathRenderer(const GrClip&, GrPaint&&, GrAA, const SkMatrix&, |
Michael Ludwig | 6a6de65 | 2020-04-30 20:16:36 -0400 | [diff] [blame^] | 677 | const GrStyledShape&, bool attemptShapeFallback = true); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 678 | |
Chris Dalton | 0875512 | 2019-08-05 16:13:47 -0600 | [diff] [blame] | 679 | void addOp(std::unique_ptr<GrOp>); |
| 680 | |
Brian Salomon | 348a037 | 2018-10-31 10:42:18 -0400 | [diff] [blame] | 681 | // Allows caller of addDrawOp to know which op list an op will be added to. |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 682 | using WillAddOpFn = void(GrOp*, uint32_t opsTaskID); |
Brian Salomon | 348a037 | 2018-10-31 10:42:18 -0400 | [diff] [blame] | 683 | // These perform processing specific to GrDrawOp-derived ops before recording them into an |
| 684 | // op list. Before adding the op to an op list the WillAddOpFn is called. Note that it |
| 685 | // will not be called in the event that the op is discarded. Moreover, the op may merge into |
| 686 | // another op after the function is called (either before addDrawOp returns or some time later). |
| 687 | void addDrawOp(const GrClip&, std::unique_ptr<GrDrawOp>, |
| 688 | const std::function<WillAddOpFn>& = std::function<WillAddOpFn>()); |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 689 | |
Robert Phillips | bf25d43 | 2017-04-07 10:08:53 -0400 | [diff] [blame] | 690 | // Makes a copy of the proxy if it is necessary for the draw and places the texture that should |
| 691 | // be used by GrXferProcessor to access the destination color in 'result'. If the return |
| 692 | // value is false then a texture copy could not be made. |
Greg Daniel | 524e28b | 2019-11-01 11:48:53 -0400 | [diff] [blame] | 693 | bool SK_WARN_UNUSED_RESULT setupDstProxyView(const GrClip&, const GrOp& op, |
| 694 | GrXferProcessor::DstProxyView* result); |
Brian Salomon | 467921e | 2017-03-06 16:17:12 -0500 | [diff] [blame] | 695 | |
Brian Salomon | 9241a6d | 2019-10-03 13:26:54 -0400 | [diff] [blame] | 696 | class AsyncReadResult; |
| 697 | |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 698 | // The async read step of asyncRescaleAndReadPixels() |
| 699 | void asyncReadPixels(const SkIRect& rect, SkColorType colorType, ReadPixelsCallback callback, |
| 700 | ReadPixelsContext context); |
| 701 | |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 702 | GrOpsTask* getOpsTask(); |
robertphillips | a106c62 | 2015-10-16 09:07:06 -0700 | [diff] [blame] | 703 | |
Herb Derby | c1b482c | 2018-08-09 15:02:27 -0400 | [diff] [blame] | 704 | std::unique_ptr<GrTextTarget> fTextTarget; |
Greg Daniel | a83de58 | 2019-10-22 09:33:25 -0400 | [diff] [blame] | 705 | |
Brian Salomon | 8afde5f | 2020-04-01 16:22:00 -0400 | [diff] [blame] | 706 | GrSurfaceProxyView fWriteView; |
robertphillips | a106c62 | 2015-10-16 09:07:06 -0700 | [diff] [blame] | 707 | |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 708 | // In MDB-mode the GrOpsTask can be closed by some other renderTargetContext that has picked |
| 709 | // it up. For this reason, the GrOpsTask should only ever be accessed via 'getOpsTask'. |
| 710 | sk_sp<GrOpsTask> fOpsTask; |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 711 | |
Brian Salomon | f18b1d8 | 2017-10-27 11:30:49 -0400 | [diff] [blame] | 712 | SkSurfaceProps fSurfaceProps; |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 713 | bool fManagedOpsTask; |
Robert Phillips | e305cc1f | 2016-12-14 12:19:05 -0500 | [diff] [blame] | 714 | |
Chris Dalton | effee20 | 2019-07-01 22:28:03 -0600 | [diff] [blame] | 715 | int fNumStencilSamples = 0; |
Chris Dalton | 6b98280 | 2019-06-27 13:53:46 -0600 | [diff] [blame] | 716 | #if GR_TEST_UTILS |
| 717 | bool fPreserveOpsOnFullClear_TestingOnly = false; |
| 718 | #endif |
| 719 | |
Robert Phillips | e305cc1f | 2016-12-14 12:19:05 -0500 | [diff] [blame] | 720 | typedef GrSurfaceContext INHERITED; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 721 | }; |
| 722 | |
| 723 | #endif |