Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef GrSurfaceContext_DEFINED |
| 9 | #define GrSurfaceContext_DEFINED |
| 10 | |
Brian Salomon | 63a0a75 | 2020-06-26 13:32:09 -0400 | [diff] [blame] | 11 | #include "include/core/SkImage.h" |
Brian Salomon | e9ad998 | 2019-07-22 16:17:41 -0400 | [diff] [blame] | 12 | #include "include/core/SkRect.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 13 | #include "include/core/SkRefCnt.h" |
Mike Reed | 1efa14d | 2021-01-02 21:44:59 -0500 | [diff] [blame] | 14 | #include "include/core/SkSamplingOptions.h" |
Brian Salomon | e9ad998 | 2019-07-22 16:17:41 -0400 | [diff] [blame] | 15 | #include "include/core/SkSurface.h" |
Brian Salomon | 63a0a75 | 2020-06-26 13:32:09 -0400 | [diff] [blame] | 16 | #include "src/gpu/GrClientMappedBufferManager.h" |
Brian Salomon | 4bc0c1f | 2019-09-30 15:12:27 -0400 | [diff] [blame] | 17 | #include "src/gpu/GrColorInfo.h" |
Brian Salomon | 1d43530 | 2019-07-01 13:05:28 -0400 | [diff] [blame] | 18 | #include "src/gpu/GrDataUtils.h" |
Brian Salomon | 6aa6505 | 2020-01-28 12:16:53 -0500 | [diff] [blame] | 19 | #include "src/gpu/GrImageInfo.h" |
Brian Salomon | dd4087d | 2020-12-23 20:36:44 -0500 | [diff] [blame] | 20 | #include "src/gpu/GrPixmap.h" |
Brian Salomon | d63638b | 2021-03-05 14:00:07 -0500 | [diff] [blame^] | 21 | #include "src/gpu/GrRenderTask.h" |
Greg Daniel | f91aeb2 | 2019-06-18 09:58:02 -0400 | [diff] [blame] | 22 | #include "src/gpu/GrSurfaceProxy.h" |
Greg Daniel | 901b98e | 2019-10-22 09:54:02 -0400 | [diff] [blame] | 23 | #include "src/gpu/GrSurfaceProxyView.h" |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 24 | |
| 25 | class GrAuditTrail; |
Robert Phillips | 7215283 | 2017-01-25 17:31:35 -0500 | [diff] [blame] | 26 | class GrDrawingManager; |
Robert Phillips | 6989370 | 2019-02-22 11:16:30 -0500 | [diff] [blame] | 27 | class GrRecordingContext; |
Robert Phillips | 2734136 | 2016-12-14 08:46:47 -0500 | [diff] [blame] | 28 | class GrRenderTargetProxy; |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 29 | class GrSingleOwner; |
| 30 | class GrSurface; |
Brian Salomon | 590f567 | 2020-12-16 11:44:47 -0500 | [diff] [blame] | 31 | class GrSurfaceDrawContext; |
| 32 | class GrSurfaceFillContext; |
Robert Phillips | 2734136 | 2016-12-14 08:46:47 -0500 | [diff] [blame] | 33 | class GrSurfaceProxy; |
| 34 | class GrTextureProxy; |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 35 | struct SkIPoint; |
| 36 | struct SkIRect; |
| 37 | |
| 38 | /** |
| 39 | * A helper object to orchestrate commands for a particular surface |
| 40 | */ |
Brian Salomon | 57f211b | 2019-08-21 15:21:09 -0400 | [diff] [blame] | 41 | class GrSurfaceContext { |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 42 | public: |
Brian Salomon | eebe735 | 2020-12-09 16:37:04 -0500 | [diff] [blame] | 43 | // If the passed in GrSurfaceProxy is renderable this will return a GrSurfaceDrawContext, |
Greg Daniel | bfa19c4 | 2019-12-19 16:41:40 -0500 | [diff] [blame] | 44 | // otherwise it will return a GrSurfaceContext. |
Greg Daniel | 3912a4b | 2020-01-14 09:56:04 -0500 | [diff] [blame] | 45 | static std::unique_ptr<GrSurfaceContext> Make(GrRecordingContext*, |
| 46 | GrSurfaceProxyView readView, |
Brian Salomon | 14f99fc | 2020-12-07 12:19:47 -0500 | [diff] [blame] | 47 | const GrColorInfo&); |
Greg Daniel | bfa19c4 | 2019-12-19 16:41:40 -0500 | [diff] [blame] | 48 | |
Brian Salomon | 590f567 | 2020-12-16 11:44:47 -0500 | [diff] [blame] | 49 | // Makes either a GrSurfaceContext, GrFillDrawContext, or a GrSurfaceDrawContext, depending on |
| 50 | // GrRenderable and the GrImageInfo. |
Brian Salomon | 14f99fc | 2020-12-07 12:19:47 -0500 | [diff] [blame] | 51 | static std::unique_ptr<GrSurfaceContext> Make(GrRecordingContext*, |
| 52 | const GrImageInfo&, |
| 53 | const GrBackendFormat&, |
| 54 | SkBackingFit = SkBackingFit::kExact, |
| 55 | GrSurfaceOrigin = kTopLeft_GrSurfaceOrigin, |
| 56 | GrRenderable = GrRenderable::kNo, |
| 57 | int renderTargetSampleCnt = 1, |
| 58 | GrMipmapped = GrMipmapped::kNo, |
| 59 | GrProtected = GrProtected::kNo, |
| 60 | SkBudgeted = SkBudgeted::kYes); |
| 61 | |
Brian Salomon | 590f567 | 2020-12-16 11:44:47 -0500 | [diff] [blame] | 62 | // Same as the above but chooses the texture format using the default format for the color type. |
Brian Salomon | 14f99fc | 2020-12-07 12:19:47 -0500 | [diff] [blame] | 63 | static std::unique_ptr<GrSurfaceContext> Make(GrRecordingContext*, |
| 64 | const GrImageInfo&, |
| 65 | SkBackingFit = SkBackingFit::kExact, |
| 66 | GrSurfaceOrigin = kTopLeft_GrSurfaceOrigin, |
| 67 | GrRenderable = GrRenderable::kNo, |
| 68 | int renderTargetSampleCnt = 1, |
| 69 | GrMipmapped = GrMipmapped::kNo, |
| 70 | GrProtected = GrProtected::kNo, |
| 71 | SkBudgeted = SkBudgeted::kYes); |
Greg Daniel | bfa19c4 | 2019-12-19 16:41:40 -0500 | [diff] [blame] | 72 | |
| 73 | // If it is known that the GrSurfaceProxy is not renderable, you can directly call the the ctor |
| 74 | // here to make a GrSurfaceContext on the stack. |
Brian Salomon | 14f99fc | 2020-12-07 12:19:47 -0500 | [diff] [blame] | 75 | GrSurfaceContext(GrRecordingContext*, GrSurfaceProxyView readView, const GrColorInfo&); |
Greg Daniel | bfa19c4 | 2019-12-19 16:41:40 -0500 | [diff] [blame] | 76 | |
Brian Salomon | bf6b979 | 2019-08-21 09:38:10 -0400 | [diff] [blame] | 77 | virtual ~GrSurfaceContext() = default; |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 78 | |
Brian Salomon | 70fe17e | 2020-11-30 14:33:58 -0500 | [diff] [blame] | 79 | GrRecordingContext* recordingContext() { return fContext; } |
| 80 | |
Brian Salomon | 4bc0c1f | 2019-09-30 15:12:27 -0400 | [diff] [blame] | 81 | const GrColorInfo& colorInfo() const { return fColorInfo; } |
Brian Salomon | 6aa6505 | 2020-01-28 12:16:53 -0500 | [diff] [blame] | 82 | GrImageInfo imageInfo() const { return {fColorInfo, fReadView.proxy()->dimensions()}; } |
| 83 | |
Greg Daniel | 3912a4b | 2020-01-14 09:56:04 -0500 | [diff] [blame] | 84 | GrSurfaceOrigin origin() const { return fReadView.origin(); } |
| 85 | GrSwizzle readSwizzle() const { return fReadView.swizzle(); } |
| 86 | // TODO: See if it makes sense for this to return a const& instead and require the callers to |
| 87 | // make a copy (which refs the proxy) if needed. |
| 88 | GrSurfaceProxyView readSurfaceView() { return fReadView; } |
Robert Phillips | 2c86249 | 2017-01-18 10:08:39 -0500 | [diff] [blame] | 89 | |
Brian Salomon | c524378 | 2020-04-02 12:50:34 -0400 | [diff] [blame] | 90 | SkISize dimensions() const { return fReadView.dimensions(); } |
Greg Daniel | 3912a4b | 2020-01-14 09:56:04 -0500 | [diff] [blame] | 91 | int width() const { return fReadView.proxy()->width(); } |
| 92 | int height() const { return fReadView.proxy()->height(); } |
Robert Phillips | d46697a | 2017-01-25 12:10:37 -0500 | [diff] [blame] | 93 | |
Brian Salomon | 4d2d6f4 | 2019-07-26 14:15:11 -0400 | [diff] [blame] | 94 | const GrCaps* caps() const; |
| 95 | |
Robert Phillips | 2c86249 | 2017-01-18 10:08:39 -0500 | [diff] [blame] | 96 | /** |
Brian Salomon | dd4087d | 2020-12-23 20:36:44 -0500 | [diff] [blame] | 97 | * Reads a rectangle of pixels from the surface context. |
Adlai Holler | c95b589 | 2020-08-11 12:02:22 -0400 | [diff] [blame] | 98 | * @param dContext The direct context to use |
Brian Salomon | 1d43530 | 2019-07-01 13:05:28 -0400 | [diff] [blame] | 99 | * @param dst destination pixels for the read |
Brian Salomon | 1d43530 | 2019-07-01 13:05:28 -0400 | [diff] [blame] | 100 | * @param srcPt offset w/in the surface context from which to read |
Brian Salomon | 1d43530 | 2019-07-01 13:05:28 -0400 | [diff] [blame] | 101 | * is a GrDirectContext and fail otherwise. |
Robert Phillips | 2c86249 | 2017-01-18 10:08:39 -0500 | [diff] [blame] | 102 | */ |
Brian Salomon | dd4087d | 2020-12-23 20:36:44 -0500 | [diff] [blame] | 103 | bool readPixels(GrDirectContext* dContext, GrPixmap dst, SkIPoint srcPt); |
Robert Phillips | 2c86249 | 2017-01-18 10:08:39 -0500 | [diff] [blame] | 104 | |
Brian Salomon | 63a0a75 | 2020-06-26 13:32:09 -0400 | [diff] [blame] | 105 | using ReadPixelsCallback = SkImage::ReadPixelsCallback; |
| 106 | using ReadPixelsContext = SkImage::ReadPixelsContext; |
| 107 | using RescaleGamma = SkImage::RescaleGamma; |
Mike Reed | 1efa14d | 2021-01-02 21:44:59 -0500 | [diff] [blame] | 108 | using RescaleMode = SkImage::RescaleMode; |
Brian Salomon | 63a0a75 | 2020-06-26 13:32:09 -0400 | [diff] [blame] | 109 | |
| 110 | // GPU implementation for SkImage:: and SkSurface::asyncRescaleAndReadPixels. |
Adlai Holler | c95b589 | 2020-08-11 12:02:22 -0400 | [diff] [blame] | 111 | void asyncRescaleAndReadPixels(GrDirectContext*, |
| 112 | const SkImageInfo& info, |
Brian Salomon | 63a0a75 | 2020-06-26 13:32:09 -0400 | [diff] [blame] | 113 | const SkIRect& srcRect, |
| 114 | RescaleGamma rescaleGamma, |
Mike Reed | 1efa14d | 2021-01-02 21:44:59 -0500 | [diff] [blame] | 115 | RescaleMode, |
Brian Salomon | 63a0a75 | 2020-06-26 13:32:09 -0400 | [diff] [blame] | 116 | ReadPixelsCallback callback, |
Adlai Holler | c95b589 | 2020-08-11 12:02:22 -0400 | [diff] [blame] | 117 | ReadPixelsContext callbackContext); |
Brian Salomon | 63a0a75 | 2020-06-26 13:32:09 -0400 | [diff] [blame] | 118 | |
| 119 | // GPU implementation for SkImage:: and SkSurface::asyncRescaleAndReadPixelsYUV420. |
Adlai Holler | c95b589 | 2020-08-11 12:02:22 -0400 | [diff] [blame] | 120 | void asyncRescaleAndReadPixelsYUV420(GrDirectContext*, |
| 121 | SkYUVColorSpace yuvColorSpace, |
Brian Salomon | 63a0a75 | 2020-06-26 13:32:09 -0400 | [diff] [blame] | 122 | sk_sp<SkColorSpace> dstColorSpace, |
| 123 | const SkIRect& srcRect, |
| 124 | SkISize dstSize, |
| 125 | RescaleGamma rescaleGamma, |
Mike Reed | 1efa14d | 2021-01-02 21:44:59 -0500 | [diff] [blame] | 126 | RescaleMode, |
Brian Salomon | 63a0a75 | 2020-06-26 13:32:09 -0400 | [diff] [blame] | 127 | ReadPixelsCallback callback, |
| 128 | ReadPixelsContext context); |
| 129 | |
Robert Phillips | 2c86249 | 2017-01-18 10:08:39 -0500 | [diff] [blame] | 130 | /** |
Robert Phillips | b726d58 | 2017-03-09 16:36:32 -0500 | [diff] [blame] | 131 | * Writes a rectangle of pixels [srcInfo, srcBuffer, srcRowbytes] into the |
Brian Salomon | 1aa1f5f | 2020-12-11 17:25:17 -0500 | [diff] [blame] | 132 | * surfaceDrawContext at the specified position. |
Adlai Holler | c95b589 | 2020-08-11 12:02:22 -0400 | [diff] [blame] | 133 | * @param dContext The direct context to use |
Brian Salomon | 1d43530 | 2019-07-01 13:05:28 -0400 | [diff] [blame] | 134 | * @param src source for the write |
Brian Salomon | 1d43530 | 2019-07-01 13:05:28 -0400 | [diff] [blame] | 135 | * @param dstPt offset w/in the surface context at which to write |
Robert Phillips | 2c86249 | 2017-01-18 10:08:39 -0500 | [diff] [blame] | 136 | */ |
Brian Salomon | dd4087d | 2020-12-23 20:36:44 -0500 | [diff] [blame] | 137 | bool writePixels(GrDirectContext* dContext, GrPixmap src, SkIPoint dstPt); |
Greg Daniel | 6eb8c24 | 2019-06-05 10:22:24 -0400 | [diff] [blame] | 138 | |
Greg Daniel | 3912a4b | 2020-01-14 09:56:04 -0500 | [diff] [blame] | 139 | GrSurfaceProxy* asSurfaceProxy() { return fReadView.proxy(); } |
| 140 | const GrSurfaceProxy* asSurfaceProxy() const { return fReadView.proxy(); } |
Greg Daniel | c61d7e3 | 2020-02-04 14:27:45 -0500 | [diff] [blame] | 141 | sk_sp<GrSurfaceProxy> asSurfaceProxyRef() { return fReadView.refProxy(); } |
Robert Phillips | f200a90 | 2017-01-30 13:27:37 -0500 | [diff] [blame] | 142 | |
Greg Daniel | 3912a4b | 2020-01-14 09:56:04 -0500 | [diff] [blame] | 143 | GrTextureProxy* asTextureProxy() { return fReadView.asTextureProxy(); } |
| 144 | const GrTextureProxy* asTextureProxy() const { return fReadView.asTextureProxy(); } |
| 145 | sk_sp<GrTextureProxy> asTextureProxyRef() { return fReadView.asTextureProxyRef(); } |
Robert Phillips | f200a90 | 2017-01-30 13:27:37 -0500 | [diff] [blame] | 146 | |
Greg Daniel | 3912a4b | 2020-01-14 09:56:04 -0500 | [diff] [blame] | 147 | GrRenderTargetProxy* asRenderTargetProxy() { return fReadView.asRenderTargetProxy(); } |
Greg Daniel | 46e366a | 2019-12-16 14:38:36 -0500 | [diff] [blame] | 148 | const GrRenderTargetProxy* asRenderTargetProxy() const { |
Greg Daniel | 3912a4b | 2020-01-14 09:56:04 -0500 | [diff] [blame] | 149 | return fReadView.asRenderTargetProxy(); |
Greg Daniel | 46e366a | 2019-12-16 14:38:36 -0500 | [diff] [blame] | 150 | } |
| 151 | sk_sp<GrRenderTargetProxy> asRenderTargetProxyRef() { |
Greg Daniel | 3912a4b | 2020-01-14 09:56:04 -0500 | [diff] [blame] | 152 | return fReadView.asRenderTargetProxyRef(); |
Greg Daniel | 46e366a | 2019-12-16 14:38:36 -0500 | [diff] [blame] | 153 | } |
Robert Phillips | 2734136 | 2016-12-14 08:46:47 -0500 | [diff] [blame] | 154 | |
Brian Salomon | eebe735 | 2020-12-09 16:37:04 -0500 | [diff] [blame] | 155 | virtual GrSurfaceDrawContext* asRenderTargetContext() { return nullptr; } |
Brian Salomon | 590f567 | 2020-12-16 11:44:47 -0500 | [diff] [blame] | 156 | virtual GrSurfaceFillContext* asFillContext() { return nullptr; } |
Robert Phillips | d46697a | 2017-01-25 12:10:37 -0500 | [diff] [blame] | 157 | |
Brian Salomon | 11ad4cc | 2020-05-15 12:07:59 -0400 | [diff] [blame] | 158 | /** |
| 159 | * Rescales the contents of srcRect. The gamma in which the rescaling occurs is controlled by |
| 160 | * RescaleGamma. It is always in the original gamut. The result is converted to the color type |
| 161 | * and color space of info after rescaling. Note: this currently requires that the info have a |
| 162 | * different size than srcRect. Though, it could be relaxed to allow non-scaling color |
| 163 | * conversions. |
| 164 | */ |
Brian Salomon | bacbb92 | 2021-01-21 19:48:00 -0500 | [diff] [blame] | 165 | std::unique_ptr<GrSurfaceFillContext> rescale(const GrImageInfo& info, |
Brian Salomon | eebe735 | 2020-12-09 16:37:04 -0500 | [diff] [blame] | 166 | GrSurfaceOrigin, |
| 167 | SkIRect srcRect, |
| 168 | SkImage::RescaleGamma, |
Mike Reed | 1efa14d | 2021-01-02 21:44:59 -0500 | [diff] [blame] | 169 | SkImage::RescaleMode); |
Brian Salomon | 11ad4cc | 2020-05-15 12:07:59 -0400 | [diff] [blame] | 170 | |
Brian Salomon | 1c86b63 | 2020-12-11 12:36:01 -0500 | [diff] [blame] | 171 | /** |
Brian Salomon | bacbb92 | 2021-01-21 19:48:00 -0500 | [diff] [blame] | 172 | * Like the above but allows the caller ot specify a destination fill context and |
Brian Salomon | 1c86b63 | 2020-12-11 12:36:01 -0500 | [diff] [blame] | 173 | * rect within that context. The dst rect must be contained by the dst or this will fail. |
| 174 | */ |
Brian Salomon | bacbb92 | 2021-01-21 19:48:00 -0500 | [diff] [blame] | 175 | bool rescaleInto(GrSurfaceFillContext* dst, |
Brian Salomon | 1c86b63 | 2020-12-11 12:36:01 -0500 | [diff] [blame] | 176 | SkIRect dstRect, |
| 177 | SkIRect srcRect, |
| 178 | SkImage::RescaleGamma, |
Mike Reed | 1efa14d | 2021-01-02 21:44:59 -0500 | [diff] [blame] | 179 | SkImage::RescaleMode); |
Brian Salomon | 1c86b63 | 2020-12-11 12:36:01 -0500 | [diff] [blame] | 180 | |
Robert Phillips | 0d075de | 2019-03-04 11:08:13 -0500 | [diff] [blame] | 181 | GrAuditTrail* auditTrail(); |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 182 | |
Greg Daniel | 46cfbc6 | 2019-06-07 11:43:30 -0400 | [diff] [blame] | 183 | #if GR_TEST_UTILS |
Brian Salomon | 982127b | 2021-01-21 10:43:35 -0500 | [diff] [blame] | 184 | bool testCopy(sk_sp<GrSurfaceProxy> src, const SkIRect& srcRect, const SkIPoint& dstPoint) { |
Brian Salomon | d63638b | 2021-03-05 14:00:07 -0500 | [diff] [blame^] | 185 | return this->copy(std::move(src), srcRect, dstPoint) != nullptr; |
Greg Daniel | 46cfbc6 | 2019-06-07 11:43:30 -0400 | [diff] [blame] | 186 | } |
| 187 | |
Brian Salomon | 982127b | 2021-01-21 10:43:35 -0500 | [diff] [blame] | 188 | bool testCopy(sk_sp<GrSurfaceProxy> src) { |
| 189 | auto rect = SkIRect::MakeSize(src->dimensions()); |
Brian Salomon | d63638b | 2021-03-05 14:00:07 -0500 | [diff] [blame^] | 190 | return this->copy(std::move(src), rect, {0, 0}) != nullptr; |
Greg Daniel | 46cfbc6 | 2019-06-07 11:43:30 -0400 | [diff] [blame] | 191 | } |
| 192 | #endif |
| 193 | |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 194 | protected: |
Robert Phillips | 0d075de | 2019-03-04 11:08:13 -0500 | [diff] [blame] | 195 | GrDrawingManager* drawingManager(); |
| 196 | const GrDrawingManager* drawingManager() const; |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 197 | |
Greg Daniel | 46e366a | 2019-12-16 14:38:36 -0500 | [diff] [blame] | 198 | SkDEBUGCODE(void validate() const;) |
Robert Phillips | 2de8cfa | 2017-06-28 10:33:41 -0400 | [diff] [blame] | 199 | |
Brian Salomon | 70fe17e | 2020-11-30 14:33:58 -0500 | [diff] [blame] | 200 | SkDEBUGCODE(GrSingleOwner* singleOwner() const;) |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 201 | |
Robert Phillips | 6989370 | 2019-02-22 11:16:30 -0500 | [diff] [blame] | 202 | GrRecordingContext* fContext; |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 203 | |
Greg Daniel | 3912a4b | 2020-01-14 09:56:04 -0500 | [diff] [blame] | 204 | GrSurfaceProxyView fReadView; |
Greg Daniel | 901b98e | 2019-10-22 09:54:02 -0400 | [diff] [blame] | 205 | |
Brian Salomon | 4d2d6f4 | 2019-07-26 14:15:11 -0400 | [diff] [blame] | 206 | // Inserts a transfer, part of the implementation of asyncReadPixels and |
| 207 | // asyncRescaleAndReadPixelsYUV420(). |
| 208 | struct PixelTransferResult { |
| 209 | using ConversionFn = void(void* dst, const void* mappedBuffer); |
| 210 | // If null then the transfer could not be performed. Otherwise this buffer will contain |
| 211 | // the pixel data when the transfer is complete. |
| 212 | sk_sp<GrGpuBuffer> fTransferBuffer; |
| 213 | // If this is null then the transfer buffer will contain the data in the requested |
| 214 | // color type. Otherwise, when the transfer is done this must be called to convert |
| 215 | // from the transfer buffer's color type to the requested color type. |
| 216 | std::function<ConversionFn> fPixelConverter; |
| 217 | }; |
| 218 | PixelTransferResult transferPixels(GrColorType colorType, const SkIRect& rect); |
| 219 | |
Brian Salomon | 63a0a75 | 2020-06-26 13:32:09 -0400 | [diff] [blame] | 220 | // The async read step of asyncRescaleAndReadPixels() |
Adlai Holler | c95b589 | 2020-08-11 12:02:22 -0400 | [diff] [blame] | 221 | void asyncReadPixels(GrDirectContext*, |
| 222 | const SkIRect& srcRect, |
| 223 | SkColorType, |
| 224 | ReadPixelsCallback, |
| 225 | ReadPixelsContext); |
Brian Salomon | 63a0a75 | 2020-06-26 13:32:09 -0400 | [diff] [blame] | 226 | |
Robert Phillips | e305cc1f | 2016-12-14 12:19:05 -0500 | [diff] [blame] | 227 | private: |
Greg Daniel | 46cfbc6 | 2019-06-07 11:43:30 -0400 | [diff] [blame] | 228 | friend class GrSurfaceProxy; // for copy |
| 229 | |
Greg Daniel | 46e366a | 2019-12-16 14:38:36 -0500 | [diff] [blame] | 230 | SkDEBUGCODE(virtual void onValidate() const {}) |
| 231 | |
Greg Daniel | 46cfbc6 | 2019-06-07 11:43:30 -0400 | [diff] [blame] | 232 | /** |
| 233 | * Copy 'src' into the proxy backing this context. This call will not do any draw fallback. |
| 234 | * Currently only writePixels and replaceRenderTarget call this directly. All other copies |
| 235 | * should go through GrSurfaceProxy::Copy. |
| 236 | * @param src src of pixels |
Greg Daniel | 46cfbc6 | 2019-06-07 11:43:30 -0400 | [diff] [blame] | 237 | * @param dstPoint the origin of the 'srcRect' in the destination coordinate space |
Brian Salomon | d63638b | 2021-03-05 14:00:07 -0500 | [diff] [blame^] | 238 | * @return a task (that may be skippable by calling canSkip) if successful and |
| 239 | * null otherwise. |
Greg Daniel | 46cfbc6 | 2019-06-07 11:43:30 -0400 | [diff] [blame] | 240 | * |
| 241 | * Note: Notionally, 'srcRect' is clipped to 'src's extent with 'dstPoint' being adjusted. |
| 242 | * Then the 'srcRect' offset by 'dstPoint' is clipped against the dst's extent. |
| 243 | * The end result is only valid src pixels and dst pixels will be touched but the copied |
| 244 | * regions will not be shifted. The 'src' must have the same origin as the backing proxy |
| 245 | * of fSurfaceContext. |
| 246 | */ |
Brian Salomon | d63638b | 2021-03-05 14:00:07 -0500 | [diff] [blame^] | 247 | sk_sp<GrRenderTask> copy(sk_sp<GrSurfaceProxy> src, SkIRect srcRect, SkIPoint dstPoint); |
Greg Daniel | 46cfbc6 | 2019-06-07 11:43:30 -0400 | [diff] [blame] | 248 | |
Brian Salomon | 63a0a75 | 2020-06-26 13:32:09 -0400 | [diff] [blame] | 249 | class AsyncReadResult; |
| 250 | |
Brian Salomon | 4bc0c1f | 2019-09-30 15:12:27 -0400 | [diff] [blame] | 251 | GrColorInfo fColorInfo; |
Brian Salomon | f3569f0 | 2017-10-24 12:52:33 -0400 | [diff] [blame] | 252 | |
John Stiles | 7571f9e | 2020-09-02 22:42:33 -0400 | [diff] [blame] | 253 | using INHERITED = SkRefCnt; |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 254 | }; |
| 255 | |
| 256 | #endif |