Brian Salomon | 3416969 | 2017-08-28 15:32:01 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "include/core/SkCanvas.h" |
| 9 | #include "include/core/SkRefCnt.h" |
| 10 | #include "include/gpu/GrSamplerState.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/private/GrTypesPriv.h" |
Greg Daniel | f91aeb2 | 2019-06-18 09:58:02 -0400 | [diff] [blame] | 12 | #include "src/gpu/GrColor.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 13 | #include "src/gpu/GrRenderTargetContext.h" |
Brian Salomon | 3416969 | 2017-08-28 15:32:01 -0400 | [diff] [blame] | 14 | |
Brian Osman | d49e946 | 2017-10-16 13:17:48 -0400 | [diff] [blame] | 15 | class GrColorSpaceXform; |
Brian Salomon | 3416969 | 2017-08-28 15:32:01 -0400 | [diff] [blame] | 16 | class GrDrawOp; |
| 17 | class GrTextureProxy; |
| 18 | struct SkRect; |
| 19 | class SkMatrix; |
| 20 | |
| 21 | namespace GrTextureOp { |
Brian Salomon | b80ffee | 2018-05-23 16:39:39 -0400 | [diff] [blame] | 22 | |
Brian Salomon | 3416969 | 2017-08-28 15:32:01 -0400 | [diff] [blame] | 23 | /** |
Michael Ludwig | 22429f9 | 2019-06-27 10:44:48 -0400 | [diff] [blame^] | 24 | * Creates an op that draws a sub-quadrilateral of a texture. The passed color is modulated by the |
| 25 | * texture's color. 'deviceQuad' specifies the device-space coordinates to draw, using 'localQuad' |
| 26 | * to map into the proxy's texture space. If non-null, 'domain' represents the boundary for the |
| 27 | * strict src rect constraint. If GrAAType is kCoverage then AA is applied to the edges |
Brian Salomon | 2213ee9 | 2018-10-02 10:44:21 -0400 | [diff] [blame] | 28 | * indicated by GrQuadAAFlags. Otherwise, GrQuadAAFlags is ignored. |
Michael Ludwig | 22429f9 | 2019-06-27 10:44:48 -0400 | [diff] [blame^] | 29 | * |
| 30 | * This is functionally very similar to GrFillRectOp::Make, except that the GrPaint has been |
| 31 | * deconstructed into the texture, filter, modulating color, and blend mode. When blend mode is |
| 32 | * src over, this will return a GrFillRectOp with a paint that samples the proxy. |
Brian Salomon | 3416969 | 2017-08-28 15:32:01 -0400 | [diff] [blame] | 33 | */ |
Michael Ludwig | 22429f9 | 2019-06-27 10:44:48 -0400 | [diff] [blame^] | 34 | std::unique_ptr<GrDrawOp> MakeGeneral(GrRecordingContext* context, |
| 35 | sk_sp<GrTextureProxy> proxy, |
| 36 | sk_sp<GrColorSpaceXform> textureXform, |
| 37 | GrSamplerState::Filter filter, |
| 38 | const SkPMColor4f& color, |
| 39 | SkBlendMode blendMode, |
| 40 | GrAAType aaType, |
| 41 | GrQuadAAFlags aaFlags, |
| 42 | const GrQuad& deviceQuad, |
| 43 | const GrQuad& localQuad, |
| 44 | const SkRect* domain = nullptr); |
| 45 | |
| 46 | // FIXME (michaelludwig) - To be removed |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 47 | std::unique_ptr<GrDrawOp> Make(GrRecordingContext*, |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 48 | sk_sp<GrTextureProxy>, |
| 49 | GrSamplerState::Filter, |
Brian Osman | 3d139a4 | 2018-11-19 10:42:10 -0500 | [diff] [blame] | 50 | const SkPMColor4f&, |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 51 | const SkRect& srcRect, |
| 52 | const SkRect& dstRect, |
| 53 | GrAAType, |
Brian Salomon | 2213ee9 | 2018-10-02 10:44:21 -0400 | [diff] [blame] | 54 | GrQuadAAFlags, |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 55 | SkCanvas::SrcRectConstraint, |
| 56 | const SkMatrix& viewMatrix, |
Michael Ludwig | 22429f9 | 2019-06-27 10:44:48 -0400 | [diff] [blame^] | 57 | sk_sp<GrColorSpaceXform> textureXform, |
| 58 | SkBlendMode blendMode = SkBlendMode::kSrcOver); |
Brian Salomon | d7065e7 | 2018-10-12 11:42:02 -0400 | [diff] [blame] | 59 | |
Michael Ludwig | 009b92e | 2019-02-15 16:03:53 -0500 | [diff] [blame] | 60 | // Generalizes the above subrect drawing operation to draw a subquad of an image, where srcQuad |
| 61 | // and dstQuad correspond to srcRect and dstRect. If domain is not null, this behaves as if it |
| 62 | // had a strict constraint relying on the given domain. |
Michael Ludwig | 22429f9 | 2019-06-27 10:44:48 -0400 | [diff] [blame^] | 63 | // FIXME (michaelludwig) - To be removed |
Michael Ludwig | 009b92e | 2019-02-15 16:03:53 -0500 | [diff] [blame] | 64 | std::unique_ptr<GrDrawOp> MakeQuad(GrRecordingContext* context, |
| 65 | sk_sp<GrTextureProxy>, |
| 66 | GrSamplerState::Filter, |
| 67 | const SkPMColor4f&, |
| 68 | const SkPoint srcQuad[4], |
| 69 | const SkPoint dstQuad[4], |
| 70 | GrAAType, |
| 71 | GrQuadAAFlags, |
| 72 | const SkRect* domain, |
| 73 | const SkMatrix& viewMatrix, |
Michael Ludwig | 22429f9 | 2019-06-27 10:44:48 -0400 | [diff] [blame^] | 74 | sk_sp<GrColorSpaceXform> textureXform, |
| 75 | SkBlendMode blendMode = SkBlendMode::kSrcOver); |
Michael Ludwig | 009b92e | 2019-02-15 16:03:53 -0500 | [diff] [blame] | 76 | |
Michael Ludwig | 22429f9 | 2019-06-27 10:44:48 -0400 | [diff] [blame^] | 77 | // Unlike the single-proxy factory, this only supports src-over blending. |
Michael Ludwig | 009b92e | 2019-02-15 16:03:53 -0500 | [diff] [blame] | 78 | std::unique_ptr<GrDrawOp> MakeSet(GrRecordingContext*, |
| 79 | const GrRenderTargetContext::TextureSetEntry[], |
| 80 | int cnt, |
| 81 | GrSamplerState::Filter, |
| 82 | GrAAType, |
Michael Ludwig | 31ba718 | 2019-04-03 10:38:06 -0400 | [diff] [blame] | 83 | SkCanvas::SrcRectConstraint, |
Michael Ludwig | 009b92e | 2019-02-15 16:03:53 -0500 | [diff] [blame] | 84 | const SkMatrix& viewMatrix, |
| 85 | sk_sp<GrColorSpaceXform> textureXform); |
Michael Ludwig | a3c45c7 | 2019-01-17 17:26:48 -0500 | [diff] [blame] | 86 | |
Brian Salomon | 3416969 | 2017-08-28 15:32:01 -0400 | [diff] [blame] | 87 | } |