blob: 1e85c2969dd568a85c7ae8339ba60306d3948233 [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
23namespace GrTextureOp {
Brian Salomonb80ffee2018-05-23 16:39:39 -040024
Brian Salomon34169692017-08-28 15:32:01 -040025/**
Brian Salomonf19f9ca2019-09-18 15:54:26 -040026 * Controls whether saturate() is called after the texture is color-converted to ensure all
27 * color values are in 0..1 range.
28 */
29enum class Saturate : bool { kNo = false, kYes = true };
30
31/**
Michael Ludwig22429f92019-06-27 10:44:48 -040032 * 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 Salomon2213ee92018-10-02 10:44:21 -040036 * indicated by GrQuadAAFlags. Otherwise, GrQuadAAFlags is ignored.
Michael Ludwig22429f92019-06-27 10:44:48 -040037 *
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 Salomon34169692017-08-28 15:32:01 -040041 */
Brian Salomonf19f9ca2019-09-18 15:54:26 -040042std::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 Ludwig205224f2019-06-27 10:47:42 -040051 const GrQuad& deviceQuad,
52 const GrQuad& localQuad,
53 const SkRect* domain = nullptr);
Michael Ludwig009b92e2019-02-15 16:03:53 -050054
Michael Ludwig22429f92019-06-27 10:44:48 -040055// Unlike the single-proxy factory, this only supports src-over blending.
Michael Ludwig009b92e2019-02-15 16:03:53 -050056std::unique_ptr<GrDrawOp> MakeSet(GrRecordingContext*,
57 const GrRenderTargetContext::TextureSetEntry[],
58 int cnt,
59 GrSamplerState::Filter,
Brian Salomonf19f9ca2019-09-18 15:54:26 -040060 Saturate,
Michael Ludwig009b92e2019-02-15 16:03:53 -050061 GrAAType,
Michael Ludwig31ba7182019-04-03 10:38:06 -040062 SkCanvas::SrcRectConstraint,
Michael Ludwig009b92e2019-02-15 16:03:53 -050063 const SkMatrix& viewMatrix,
64 sk_sp<GrColorSpaceXform> textureXform);
Michael Ludwiga3c45c72019-01-17 17:26:48 -050065
Brian Salomon34169692017-08-28 15:32:01 -040066}
Hal Canary30e4bdf2019-07-02 10:31:45 -040067#endif // GrTextureOp_DEFINED