blob: 1942344cc5a7ff8391d1e8a10e68b52b20ff81ed [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
8#include "GrColor.h"
Brian Salomond7065e72018-10-12 11:42:02 -04009#include "GrRenderTargetContext.h"
Brian Salomon2bbdcc42017-09-07 12:36:34 -040010#include "GrSamplerState.h"
Brian Salomon485b8c62018-01-12 15:11:06 -050011#include "GrTypesPriv.h"
Brian Salomonb80ffee2018-05-23 16:39:39 -040012#include "SkCanvas.h"
Brian Osmand49e9462017-10-16 13:17:48 -040013#include "SkRefCnt.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/**
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 Salomon2213ee92018-10-02 10:44:21 -040027 * 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 Salomon34169692017-08-28 15:32:01 -040029 */
Robert Phillips7c525e62018-06-12 10:11:12 -040030std::unique_ptr<GrDrawOp> Make(GrContext*,
31 sk_sp<GrTextureProxy>,
32 GrSamplerState::Filter,
Brian Osman3d139a42018-11-19 10:42:10 -050033 const SkPMColor4f&,
Robert Phillips7c525e62018-06-12 10:11:12 -040034 const SkRect& srcRect,
35 const SkRect& dstRect,
36 GrAAType,
Brian Salomon2213ee92018-10-02 10:44:21 -040037 GrQuadAAFlags,
Robert Phillips7c525e62018-06-12 10:11:12 -040038 SkCanvas::SrcRectConstraint,
39 const SkMatrix& viewMatrix,
Brian Osman3d139a42018-11-19 10:42:10 -050040 sk_sp<GrColorSpaceXform> textureXform);
Brian Salomond7065e72018-10-12 11:42:02 -040041
42std::unique_ptr<GrDrawOp> Make(GrContext*,
43 const GrRenderTargetContext::TextureSetEntry[],
44 int cnt,
45 GrSamplerState::Filter,
Brian Salomond7065e72018-10-12 11:42:02 -040046 GrAAType,
47 const SkMatrix& viewMatrix,
Brian Osman3d139a42018-11-19 10:42:10 -050048 sk_sp<GrColorSpaceXform> textureXform);
Michael Ludwiga3c45c72019-01-17 17:26:48 -050049
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 */
54bool GetFilterHasEffect(const SkMatrix& viewMatrix, const SkRect& srcRect, const SkRect& dstRect);
55
Brian Salomon34169692017-08-28 15:32:01 -040056}