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