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 | |
| 8 | #include "GrColor.h" |
Brian Salomon | d7065e7 | 2018-10-12 11:42:02 -0400 | [diff] [blame] | 9 | #include "GrRenderTargetContext.h" |
Brian Salomon | 2bbdcc4 | 2017-09-07 12:36:34 -0400 | [diff] [blame] | 10 | #include "GrSamplerState.h" |
Brian Salomon | 485b8c6 | 2018-01-12 15:11:06 -0500 | [diff] [blame] | 11 | #include "GrTypesPriv.h" |
Brian Salomon | b80ffee | 2018-05-23 16:39:39 -0400 | [diff] [blame] | 12 | #include "SkCanvas.h" |
Brian Osman | d49e946 | 2017-10-16 13:17:48 -0400 | [diff] [blame] | 13 | #include "SkRefCnt.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 | /** |
| 24 | * Creates an op that draws a sub-rectangle of a texture. The passed color is modulated by the |
| 25 | * texture's color. 'srcRect' specifies the rectangle of the texture to draw. 'dstRect' specifies |
| 26 | * the rectangle to draw in local coords which will be transformed by 'viewMatrix' to be in device |
Brian Salomon | 2213ee9 | 2018-10-02 10:44:21 -0400 | [diff] [blame] | 27 | * space. 'viewMatrix' must be affine. If GrAAType is kCoverage then AA is applied to the edges |
| 28 | * indicated by GrQuadAAFlags. Otherwise, GrQuadAAFlags is ignored. |
Brian Salomon | 3416969 | 2017-08-28 15:32:01 -0400 | [diff] [blame] | 29 | */ |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 30 | std::unique_ptr<GrDrawOp> Make(GrContext*, |
| 31 | sk_sp<GrTextureProxy>, |
| 32 | GrSamplerState::Filter, |
Brian Osman | 3d139a4 | 2018-11-19 10:42:10 -0500 | [diff] [blame] | 33 | const SkPMColor4f&, |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 34 | const SkRect& srcRect, |
| 35 | const SkRect& dstRect, |
| 36 | GrAAType, |
Brian Salomon | 2213ee9 | 2018-10-02 10:44:21 -0400 | [diff] [blame] | 37 | GrQuadAAFlags, |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 38 | SkCanvas::SrcRectConstraint, |
| 39 | const SkMatrix& viewMatrix, |
Brian Osman | 3d139a4 | 2018-11-19 10:42:10 -0500 | [diff] [blame] | 40 | sk_sp<GrColorSpaceXform> textureXform); |
Brian Salomon | d7065e7 | 2018-10-12 11:42:02 -0400 | [diff] [blame] | 41 | |
| 42 | std::unique_ptr<GrDrawOp> Make(GrContext*, |
| 43 | const GrRenderTargetContext::TextureSetEntry[], |
| 44 | int cnt, |
| 45 | GrSamplerState::Filter, |
Brian Salomon | d7065e7 | 2018-10-12 11:42:02 -0400 | [diff] [blame] | 46 | GrAAType, |
| 47 | const SkMatrix& viewMatrix, |
Brian Osman | 3d139a4 | 2018-11-19 10:42:10 -0500 | [diff] [blame] | 48 | sk_sp<GrColorSpaceXform> textureXform); |
Michael Ludwig | a3c45c7 | 2019-01-17 17:26:48 -0500 | [diff] [blame^] | 49 | |
| 50 | /** |
| 51 | * Returns true if bilerp texture filtering matters when rendering the src rect |
| 52 | * texels to dst rect, with the given view matrix. |
| 53 | */ |
| 54 | bool GetFilterHasEffect(const SkMatrix& viewMatrix, const SkRect& srcRect, const SkRect& dstRect); |
| 55 | |
Brian Salomon | 3416969 | 2017-08-28 15:32:01 -0400 | [diff] [blame] | 56 | } |