blob: 2bf43b4bd1ae295453ab2365972999551af5a0d0 [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 */
7
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "include/core/SkCanvas.h"
9#include "include/core/SkRefCnt.h"
10#include "include/gpu/GrSamplerState.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/private/GrTypesPriv.h"
Greg Danielf91aeb22019-06-18 09:58:02 -040012#include "src/gpu/GrColor.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050013#include "src/gpu/GrRenderTargetContext.h"
Brian Salomon34169692017-08-28 15:32:01 -040014
Brian Osmand49e9462017-10-16 13:17:48 -040015class GrColorSpaceXform;
Brian Salomon34169692017-08-28 15:32:01 -040016class GrDrawOp;
17class GrTextureProxy;
18struct SkRect;
19class SkMatrix;
20
21namespace GrTextureOp {
Brian Salomonb80ffee2018-05-23 16:39:39 -040022
Brian Salomon34169692017-08-28 15:32:01 -040023/**
Michael Ludwig22429f92019-06-27 10:44:48 -040024 * 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 Salomon2213ee92018-10-02 10:44:21 -040028 * indicated by GrQuadAAFlags. Otherwise, GrQuadAAFlags is ignored.
Michael Ludwig22429f92019-06-27 10:44:48 -040029 *
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 Salomon34169692017-08-28 15:32:01 -040033 */
Michael Ludwig22429f92019-06-27 10:44:48 -040034std::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 Phillipsb97da532019-02-12 15:24:12 -050047std::unique_ptr<GrDrawOp> Make(GrRecordingContext*,
Robert Phillips7c525e62018-06-12 10:11:12 -040048 sk_sp<GrTextureProxy>,
49 GrSamplerState::Filter,
Brian Osman3d139a42018-11-19 10:42:10 -050050 const SkPMColor4f&,
Robert Phillips7c525e62018-06-12 10:11:12 -040051 const SkRect& srcRect,
52 const SkRect& dstRect,
53 GrAAType,
Brian Salomon2213ee92018-10-02 10:44:21 -040054 GrQuadAAFlags,
Robert Phillips7c525e62018-06-12 10:11:12 -040055 SkCanvas::SrcRectConstraint,
56 const SkMatrix& viewMatrix,
Michael Ludwig22429f92019-06-27 10:44:48 -040057 sk_sp<GrColorSpaceXform> textureXform,
58 SkBlendMode blendMode = SkBlendMode::kSrcOver);
Brian Salomond7065e72018-10-12 11:42:02 -040059
Michael Ludwig009b92e2019-02-15 16:03:53 -050060// 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 Ludwig22429f92019-06-27 10:44:48 -040063// FIXME (michaelludwig) - To be removed
Michael Ludwig009b92e2019-02-15 16:03:53 -050064std::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 Ludwig22429f92019-06-27 10:44:48 -040074 sk_sp<GrColorSpaceXform> textureXform,
75 SkBlendMode blendMode = SkBlendMode::kSrcOver);
Michael Ludwig009b92e2019-02-15 16:03:53 -050076
Michael Ludwig22429f92019-06-27 10:44:48 -040077// Unlike the single-proxy factory, this only supports src-over blending.
Michael Ludwig009b92e2019-02-15 16:03:53 -050078std::unique_ptr<GrDrawOp> MakeSet(GrRecordingContext*,
79 const GrRenderTargetContext::TextureSetEntry[],
80 int cnt,
81 GrSamplerState::Filter,
82 GrAAType,
Michael Ludwig31ba7182019-04-03 10:38:06 -040083 SkCanvas::SrcRectConstraint,
Michael Ludwig009b92e2019-02-15 16:03:53 -050084 const SkMatrix& viewMatrix,
85 sk_sp<GrColorSpaceXform> textureXform);
Michael Ludwiga3c45c72019-01-17 17:26:48 -050086
Brian Salomon34169692017-08-28 15:32:01 -040087}