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 | */ |
Hal Canary | 30e4bdf | 2019-07-02 10:31:45 -0400 | [diff] [blame] | 7 | #ifndef GrTextureOp_DEFINED |
| 8 | #define GrTextureOp_DEFINED |
Brian Salomon | 3416969 | 2017-08-28 15:32:01 -0400 | [diff] [blame] | 9 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 10 | #include "include/core/SkCanvas.h" |
| 11 | #include "include/core/SkRefCnt.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 12 | #include "include/private/GrTypesPriv.h" |
Greg Daniel | f91aeb2 | 2019-06-18 09:58:02 -0400 | [diff] [blame] | 13 | #include "src/gpu/GrColor.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 14 | #include "src/gpu/GrRenderTargetContext.h" |
Brian Salomon | 201cdbb | 2019-08-14 17:00:30 -0400 | [diff] [blame] | 15 | #include "src/gpu/GrSamplerState.h" |
Brian Salomon | 3416969 | 2017-08-28 15:32:01 -0400 | [diff] [blame] | 16 | |
Brian Osman | d49e946 | 2017-10-16 13:17:48 -0400 | [diff] [blame] | 17 | class GrColorSpaceXform; |
Brian Salomon | 3416969 | 2017-08-28 15:32:01 -0400 | [diff] [blame] | 18 | class GrDrawOp; |
| 19 | class GrTextureProxy; |
| 20 | struct SkRect; |
| 21 | class SkMatrix; |
| 22 | |
| 23 | namespace GrTextureOp { |
Brian Salomon | b80ffee | 2018-05-23 16:39:39 -0400 | [diff] [blame] | 24 | |
Brian Salomon | 3416969 | 2017-08-28 15:32:01 -0400 | [diff] [blame] | 25 | /** |
Brian Salomon | f19f9ca | 2019-09-18 15:54:26 -0400 | [diff] [blame] | 26 | * Controls whether saturate() is called after the texture is color-converted to ensure all |
| 27 | * color values are in 0..1 range. |
| 28 | */ |
| 29 | enum class Saturate : bool { kNo = false, kYes = true }; |
| 30 | |
| 31 | /** |
Michael Ludwig | 22429f9 | 2019-06-27 10:44:48 -0400 | [diff] [blame] | 32 | * Creates an op that draws a sub-quadrilateral of a texture. The passed color is modulated by the |
| 33 | * texture's color. 'deviceQuad' specifies the device-space coordinates to draw, using 'localQuad' |
| 34 | * to map into the proxy's texture space. If non-null, 'domain' represents the boundary for the |
| 35 | * 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] | 36 | * indicated by GrQuadAAFlags. Otherwise, GrQuadAAFlags is ignored. |
Michael Ludwig | 22429f9 | 2019-06-27 10:44:48 -0400 | [diff] [blame] | 37 | * |
| 38 | * This is functionally very similar to GrFillRectOp::Make, except that the GrPaint has been |
| 39 | * deconstructed into the texture, filter, modulating color, and blend mode. When blend mode is |
| 40 | * 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] | 41 | */ |
Brian Salomon | f19f9ca | 2019-09-18 15:54:26 -0400 | [diff] [blame] | 42 | std::unique_ptr<GrDrawOp> Make(GrRecordingContext*, |
| 43 | sk_sp<GrTextureProxy>, |
| 44 | sk_sp<GrColorSpaceXform>, |
| 45 | GrSamplerState::Filter, |
| 46 | const SkPMColor4f&, |
| 47 | Saturate, |
| 48 | SkBlendMode, |
| 49 | GrAAType, |
| 50 | GrQuadAAFlags, |
Michael Ludwig | 205224f | 2019-06-27 10:47:42 -0400 | [diff] [blame] | 51 | const GrQuad& deviceQuad, |
| 52 | const GrQuad& localQuad, |
| 53 | const SkRect* domain = nullptr); |
Michael Ludwig | 009b92e | 2019-02-15 16:03:53 -0500 | [diff] [blame] | 54 | |
Michael Ludwig | 22429f9 | 2019-06-27 10:44:48 -0400 | [diff] [blame] | 55 | // Unlike the single-proxy factory, this only supports src-over blending. |
Michael Ludwig | 009b92e | 2019-02-15 16:03:53 -0500 | [diff] [blame] | 56 | std::unique_ptr<GrDrawOp> MakeSet(GrRecordingContext*, |
| 57 | const GrRenderTargetContext::TextureSetEntry[], |
| 58 | int cnt, |
| 59 | GrSamplerState::Filter, |
Brian Salomon | f19f9ca | 2019-09-18 15:54:26 -0400 | [diff] [blame] | 60 | Saturate, |
Michael Ludwig | 009b92e | 2019-02-15 16:03:53 -0500 | [diff] [blame] | 61 | GrAAType, |
Michael Ludwig | 31ba718 | 2019-04-03 10:38:06 -0400 | [diff] [blame] | 62 | SkCanvas::SrcRectConstraint, |
Michael Ludwig | 009b92e | 2019-02-15 16:03:53 -0500 | [diff] [blame] | 63 | const SkMatrix& viewMatrix, |
| 64 | sk_sp<GrColorSpaceXform> textureXform); |
Michael Ludwig | a3c45c7 | 2019-01-17 17:26:48 -0500 | [diff] [blame] | 65 | |
Brian Salomon | 3416969 | 2017-08-28 15:32:01 -0400 | [diff] [blame] | 66 | } |
Hal Canary | 30e4bdf | 2019-07-02 10:31:45 -0400 | [diff] [blame] | 67 | #endif // GrTextureOp_DEFINED |