blob: 600bcc8a1a4e682e904e43ee1b02cddcbe274791 [file] [log] [blame]
Brian Salomon34169692017-08-28 15:32:01 -04001/*
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 Canary30e4bdf2019-07-02 10:31:45 -04007#ifndef GrTextureOp_DEFINED
8#define GrTextureOp_DEFINED
Brian Salomon34169692017-08-28 15:32:01 -04009
Mike Kleinc0bd9f92019-04-23 12:05:21 -050010#include "include/core/SkCanvas.h"
11#include "include/core/SkRefCnt.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050012#include "include/private/GrTypesPriv.h"
Greg Danielf91aeb22019-06-18 09:58:02 -040013#include "src/gpu/GrColor.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050014#include "src/gpu/GrRenderTargetContext.h"
Brian Salomon201cdbb2019-08-14 17:00:30 -040015#include "src/gpu/GrSamplerState.h"
Brian Salomon34169692017-08-28 15:32:01 -040016
Brian Osmand49e9462017-10-16 13:17:48 -040017class GrColorSpaceXform;
Brian Salomon34169692017-08-28 15:32:01 -040018class GrDrawOp;
19class GrTextureProxy;
20struct SkRect;
21class SkMatrix;
22
Robert Phillipse837e612019-11-15 11:02:50 -050023class GrTextureOp {
24public:
Brian Salomonb80ffee2018-05-23 16:39:39 -040025
Robert Phillipse837e612019-11-15 11:02:50 -050026 /**
27 * Controls whether saturate() is called after the texture is color-converted to ensure all
28 * color values are in 0..1 range.
29 */
30 enum class Saturate : bool { kNo = false, kYes = true };
Brian Salomonf19f9ca2019-09-18 15:54:26 -040031
Robert Phillipse837e612019-11-15 11:02:50 -050032 /**
33 * Creates an op that draws a sub-quadrilateral of a texture. The passed color is modulated by
34 * the texture's color. 'deviceQuad' specifies the device-space coordinates to draw, using
35 * 'localQuad' to map into the proxy's texture space. If non-null, 'domain' represents the
36 * boundary for the strict src rect constraint. If GrAAType is kCoverage then AA is applied to
37 * the edges indicated by GrQuadAAFlags. Otherwise, GrQuadAAFlags is ignored.
38 *
39 * This is functionally very similar to GrFillRectOp::Make, except that the GrPaint has been
40 * deconstructed into the texture, filter, modulating color, and blend mode. When blend mode is
41 * src over, this will return a GrFillRectOp with a paint that samples the proxy.
42 */
43 static std::unique_ptr<GrDrawOp> Make(GrRecordingContext*,
44 GrSurfaceProxyView,
Brian Salomon078e8fa2019-11-22 04:10:18 +000045 GrColorType srcColorType,
Robert Phillipse837e612019-11-15 11:02:50 -050046 sk_sp<GrColorSpaceXform>,
47 GrSamplerState::Filter,
48 const SkPMColor4f&,
49 Saturate,
50 SkBlendMode,
51 GrAAType,
52 GrQuadAAFlags,
53 const GrQuad& deviceQuad,
54 const GrQuad& localQuad,
55 const SkRect* domain = nullptr);
Michael Ludwig009b92e2019-02-15 16:03:53 -050056
Robert Phillipse837e612019-11-15 11:02:50 -050057 // Unlike the single-proxy factory, this only supports src-over blending.
58 static void CreateTextureSetOps(GrRenderTargetContext*,
59 const GrClip& clip,
60 GrRecordingContext*,
61 const GrRenderTargetContext::TextureSetEntry[],
62 int cnt,
63 GrSamplerState::Filter,
64 Saturate,
65 GrAAType,
66 SkCanvas::SrcRectConstraint,
67 const SkMatrix& viewMatrix,
68 sk_sp<GrColorSpaceXform> textureXform);
Michael Ludwiga3c45c72019-01-17 17:26:48 -050069
Robert Phillipse837e612019-11-15 11:02:50 -050070#if GR_TEST_UTILS
71 static uint32_t ClassID();
72#endif
73
74private:
75 class BatchSizeLimiter;
76};
77
Hal Canary30e4bdf2019-07-02 10:31:45 -040078#endif // GrTextureOp_DEFINED