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" 9 #include "GrRenderTargetContext.h" 10 #include "GrSamplerState.h" 11 #include "GrTypesPriv.h" 12 #include "SkCanvas.h" 13 #include "SkRefCnt.h" 14 15 class GrColorSpaceXform; 16 class GrDrawOp; 17 class GrTextureProxy; 18 struct SkRect; 19 class SkMatrix; 20 21 namespace GrTextureOp { 22 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 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. 29 */ 30 std::unique_ptr<GrDrawOp> Make(GrContext*, 31 sk_sp<GrTextureProxy>, 32 GrSamplerState::Filter, 33 const SkPMColor4f&, 34 const SkRect& srcRect, 35 const SkRect& dstRect, 36 GrAAType, 37 GrQuadAAFlags, 38 SkCanvas::SrcRectConstraint, 39 const SkMatrix& viewMatrix, 40 sk_sp<GrColorSpaceXform> textureXform); 41 42 std::unique_ptr<GrDrawOp> Make(GrContext*, 43 const GrRenderTargetContext::TextureSetEntry[], 44 int cnt, 45 GrSamplerState::Filter, 46 GrAAType, 47 const SkMatrix& viewMatrix, 48 sk_sp<GrColorSpaceXform> textureXform); 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 56 } 57