GrRenderTargetContext.h revision 50e66d4ab43685acce5a7a942074d562c5fd9639
1ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips/*
2ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * Copyright 2015 Google Inc.
3ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips *
4ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * Use of this source code is governed by a BSD-style license that can be
5ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * found in the LICENSE file.
6ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */
7ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
81105224f9701e57ec5ce0354d6a380b664f5c638Brian Osman#ifndef GrRenderTargetContext_DEFINED
91105224f9701e57ec5ce0354d6a380b664f5c638Brian Osman#define GrRenderTargetContext_DEFINED
10ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
117c8460e10135c05a42d0744b84838bbc24398ac2Brian Salomon#include "../private/GrInstancedPipelineInfo.h"
127c8460e10135c05a42d0744b84838bbc24398ac2Brian Salomon#include "../private/GrRenderTargetProxy.h"
13ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips#include "GrColor.h"
14faf8203ea7588dcdca82f69f5a5447b3eb53a849bsalomon#include "GrContext.h"
15ecbc12b1c1c72de0cf7bba4a3f6a7cce4f43bf41csmartdalton#include "GrPaint.h"
1645580d3e3024c1536e8e1b2017b704805442b634Brian Osman#include "GrSurfaceContext.h"
177c8460e10135c05a42d0744b84838bbc24398ac2Brian Salomon#include "GrTypesPriv.h"
18467921e5e6479fe9cebba125657d8e33d89004aeBrian Salomon#include "GrXferProcessor.h"
19ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips#include "SkRefCnt.h"
20fcf7829b67b798aff4c41c4688daa9c7381991e6robertphillips#include "SkSurfaceProps.h"
21ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
22ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass GrClip;
2377a2e52c7d5c77de73ecab5fec79072ee4460706robertphillipsclass GrDrawingManager;
249afd371a8a66f992f98eb2a3fc75ae64bddc730bBrian Salomonclass GrDrawOp;
2529df76096fd30941086324902a82656df2d8becdcsmartdaltonclass GrFixedClip;
26d3ccb0a37f0e62c84fdcd6a77b7b15476b04db7aBrian Salomonclass GrLegacyMeshDrawOp;
2754d212e1bfaea0be88c3c40820d0b1ae0daebecfBrian Salomonclass GrPipelineBuilder;
28ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass GrRenderTarget;
2945580d3e3024c1536e8e1b2017b704805442b634Brian Osmanclass GrRenderTargetContextPriv;
30f2361d2d93c200cd4555b5e8ecea4531801abaaaRobert Phillipsclass GrRenderTargetOpList;
316663acff010ce752e4bf778da81fa97448c9db31bsalomonclass GrStyle;
32eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillipsclass GrTextureProxy;
33443023975e335e3630191227dbc21fa72c436af3robertphillipsstruct GrUserStencilSettings;
342334fb655f8d4ef5915770d32bf845c88d3627f4robertphillipsclass SkDrawFilter;
35ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsstruct SkIPoint;
36ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsstruct SkIRect;
3710e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarettclass SkLatticeIter;
38ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass SkMatrix;
392334fb655f8d4ef5915770d32bf845c88d3627f4robertphillipsclass SkPaint;
40ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass SkPath;
41ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsstruct SkPoint;
42ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsstruct SkRect;
4345580d3e3024c1536e8e1b2017b704805442b634Brian Osmanclass SkRegion;
44ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass SkRRect;
4531ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverthstruct SkRSXform;
462334fb655f8d4ef5915770d32bf845c88d3627f4robertphillipsclass SkTextBlob;
47199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomonclass SkVertices;
48ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
4945580d3e3024c1536e8e1b2017b704805442b634Brian Osman/**
5045580d3e3024c1536e8e1b2017b704805442b634Brian Osman * A helper object to orchestrate commands (draws, etc...) for GrSurfaces that are GrRenderTargets.
51ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */
5245580d3e3024c1536e8e1b2017b704805442b634Brian Osmanclass SK_API GrRenderTargetContext : public GrSurfaceContext {
53ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipspublic:
541105224f9701e57ec5ce0354d6a380b664f5c638Brian Osman    ~GrRenderTargetContext() override;
552334fb655f8d4ef5915770d32bf845c88d3627f4robertphillips
5677f1edce072756a6226874be9a41283d19307fefRobert Phillips    // MDB TODO: This access is mainly provided for the image filters. Remove it when they
5777f1edce072756a6226874be9a41283d19307fefRobert Phillips    // no longer need to pass it to the FragmentProcessor ctors.
5826c90e04797e15c37ec00e0f836292b8a207d294Robert Phillips    GrResourceProvider* resourceProvider() { return fContext->resourceProvider(); }
5926c90e04797e15c37ec00e0f836292b8a207d294Robert Phillips
606f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon    // We use SkPaint rather than GrPaint here for two reasons:
616f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon    //    * The SkPaint carries extra text settings. If these were extracted to a lighter object
626f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon    //      we could use GrPaint except that
636f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon    //    * SkPaint->GrPaint conversion depends upon whether the glyphs are color or grayscale and
646f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon    //      this can vary within a text run.
656f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon    virtual void drawText(const GrClip&, const SkPaint&, const SkMatrix& viewMatrix,
6682f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                          const char text[], size_t byteLength, SkScalar x, SkScalar y,
6782f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                          const SkIRect& clipBounds);
686f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon    virtual void drawPosText(const GrClip&, const SkPaint&, const SkMatrix& viewMatrix,
6982f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                             const char text[], size_t byteLength, const SkScalar pos[],
7082f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                             int scalarsPerPosition, const SkPoint& offset,
7182f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                             const SkIRect& clipBounds);
7296880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt    virtual void drawTextBlob(const GrClip&, const SkPaint&,
7396880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt                              const SkMatrix& viewMatrix, const SkTextBlob*,
7496880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt                              SkScalar x, SkScalar y,
7596880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt                              SkDrawFilter*, const SkIRect& clipBounds);
76ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
77ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
78ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * Provides a perfomance hint that the render target's contents are allowed
79ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * to become undefined.
80ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
812e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips    void discard();
82ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
83ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
84ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * Clear the entire or rect of the render target, ignoring any clips.
85ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param rect  the rect to clear or the whole thing if rect is NULL.
86ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param color the color to clear to.
87ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param canIgnoreRect allows partial clears to be converted to whole
88ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *                      clears on platforms for which that is cheap
89ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
902e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips    void clear(const SkIRect* rect, GrColor color, bool canIgnoreRect);
91ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
92ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
93ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *  Draw everywhere (respecting the clip) with the paint.
94ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
9582f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon    void drawPaint(const GrClip&, GrPaint&&, const SkMatrix& viewMatrix);
96ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
97ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
980e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * Draw the rect using a paint.
990e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param paint        describes how to color pixels.
1000e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param GrAA         Controls whether rect is antialiased
1010e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param viewMatrix   transformation matrix
1020e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param style        The style to apply. Null means fill. Currently path effects are not
1030e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     *                     allowed.
1040e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * The rects coords are used to access the paint (through texture matrix)
105ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
1062e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips    void drawRect(const GrClip&,
10782f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                  GrPaint&& paint,
1080e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                  GrAA,
109ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                  const SkMatrix& viewMatrix,
110ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                  const SkRect&,
11182f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                  const GrStyle* style = nullptr);
112ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
113ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
114a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon     * Maps a rectangle of shader coordinates to a rectangle and fills that rectangle.
115ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *
1160e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param paint        describes how to color pixels.
1170e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param GrAA         Controls whether rect is antialiased
1180e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param viewMatrix   transformation matrix which applies to rectToDraw
1190e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param rectToDraw   the rectangle to draw
1200e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param localRect    the rectangle of shader coordinates applied to rectToDraw
121ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
122a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon    void fillRectToRect(const GrClip&,
12382f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                        GrPaint&& paint,
1240e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                        GrAA,
125a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon                        const SkMatrix& viewMatrix,
126a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon                        const SkRect& rectToDraw,
127a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon                        const SkRect& localRect);
128ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
129ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
130a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon     * Fills a rect with a paint and a localMatrix.
131ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
132a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon    void fillRectWithLocalMatrix(const GrClip& clip,
13382f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                                 GrPaint&& paint,
1340e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                                 GrAA,
135a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon                                 const SkMatrix& viewMatrix,
136a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon                                 const SkRect& rect,
137a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon                                 const SkMatrix& localMatrix);
138ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
139ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
1400e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * Draw a roundrect using a paint.
141ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *
1420e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param paint       describes how to color pixels.
1430e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param GrAA        Controls whether rrect is antialiased.
1440e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param viewMatrix  transformation matrix
1450e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param rrect       the roundrect to draw
1460e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param style       style to apply to the rrect. Currently path effects are not allowed.
147ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
1482e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips    void drawRRect(const GrClip&,
14982f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                   GrPaint&&,
1500e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                   GrAA,
151ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                   const SkMatrix& viewMatrix,
152ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                   const SkRRect& rrect,
1536663acff010ce752e4bf778da81fa97448c9db31bsalomon                   const GrStyle& style);
154ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
155ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
1560e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * Draw a roundrect using a paint and a shadow shader. This is separate from drawRRect
1570e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * because it uses different underlying geometry and GeometryProcessor
158c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth     *
1590e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param paint        describes how to color pixels.
1600e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param viewMatrix   transformation matrix
1610e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param rrect        the roundrect to draw
1628d1e0ac9989c4caa537930e352bfc2dfe375c69bJim Van Verth     * @param blurWidth    amount of shadow blur to apply (in device space)
1638d1e0ac9989c4caa537930e352bfc2dfe375c69bJim Van Verth     * @param insetWidth   minimum amount to inset from the rrect edge (in local space).
1648d1e0ac9989c4caa537930e352bfc2dfe375c69bJim Van Verth     *                     We may inset more depending on the blur radius and geometry.
165a8b5cf3550fd3d843f075cae6b82cd342e32981bJim Van Verth     * @param blurClamp    Optional parameter used to indicate fraction of blur to actually apply
166c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth     */
167c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth    void drawShadowRRect(const GrClip&,
16882f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                         GrPaint&&,
169c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth                         const SkMatrix& viewMatrix,
170c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth                         const SkRRect& rrect,
171c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth                         SkScalar blurRadius,
172a8b5cf3550fd3d843f075cae6b82cd342e32981bJim Van Verth                         SkScalar insetWidth,
173a8b5cf3550fd3d843f075cae6b82cd342e32981bJim Van Verth                         SkScalar blurClamp = 1);
174c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth
175c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth    /**
1760e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * Shortcut for filling a SkPath consisting of nested rrects using a paint. The result is
1770e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * undefined if outer does not contain inner.
178000958973f4b514cddbfdcc01ec167437b66de2crobertphillips     *
1790e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param paint        describes how to color pixels.
1800e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param GrAA         Controls whether rrects edges are antialiased
1810e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param viewMatrix   transformation matrix
1820e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param outer        the outer roundrect
1830e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param inner        the inner roundrect
184000958973f4b514cddbfdcc01ec167437b66de2crobertphillips     */
185000958973f4b514cddbfdcc01ec167437b66de2crobertphillips    void drawDRRect(const GrClip&,
18682f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                    GrPaint&&,
1870e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                    GrAA,
188000958973f4b514cddbfdcc01ec167437b66de2crobertphillips                    const SkMatrix& viewMatrix,
189000958973f4b514cddbfdcc01ec167437b66de2crobertphillips                    const SkRRect& outer,
190000958973f4b514cddbfdcc01ec167437b66de2crobertphillips                    const SkRRect& inner);
191000958973f4b514cddbfdcc01ec167437b66de2crobertphillips
192000958973f4b514cddbfdcc01ec167437b66de2crobertphillips    /**
193ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * Draws a path.
194ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *
195ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param paint         describes how to color pixels.
1960e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param GrAA          Controls whether the path is antialiased.
197ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param viewMatrix    transformation matrix
198ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param path          the path to draw
1996663acff010ce752e4bf778da81fa97448c9db31bsalomon     * @param style         style to apply to the path.
200ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
2012e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips    void drawPath(const GrClip&,
20282f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                  GrPaint&&,
2030e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                  GrAA,
204ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                  const SkMatrix& viewMatrix,
205ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                  const SkPath&,
2066663acff010ce752e4bf778da81fa97448c9db31bsalomon                  const GrStyle& style);
207ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
2083de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon    enum class ColorArrayType {
2093de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon        kPremulGrColor,
2103de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon        kSkColor,
2113de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon    };
212ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
213ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * Draws vertices with a paint.
214ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *
215ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param   paint           describes how to color pixels.
216ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param   viewMatrix      transformation matrix
217ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param   primitiveType   primitives type to draw.
218ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param   vertexCount     number of vertices.
219ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param   positions       array of vertex positions, required.
220ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param   texCoords       optional array of texture coordinates used
221ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *                          to access the paint.
222ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param   colors          optional array of per-vertex colors, supercedes
223ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *                          the paint's color field.
224ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param   indices         optional array of indices. If NULL vertices
225ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *                          are drawn non-indexed.
226ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param   indexCount      if indices is non-null then this is the
227ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *                          number of indices.
2283de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon     * @param   ColorArrayType  Determines how the color array should be interpreted.
229ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
2302e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips    void drawVertices(const GrClip&,
23182f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                      GrPaint&& paint,
232ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                      const SkMatrix& viewMatrix,
233ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                      GrPrimitiveType primitiveType,
234ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                      int vertexCount,
235ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                      const SkPoint positions[],
236ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                      const SkPoint texs[],
2373de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon                      const uint32_t colors[],
238ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                      const uint16_t indices[],
2393de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon                      int indexCount,
2403de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon                      ColorArrayType = ColorArrayType::kPremulGrColor);
241ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
242ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
243199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon     * Draws vertices with a paint.
244199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon     *
245199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon     * @param   paint           describes how to color pixels.
246199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon     * @param   viewMatrix      transformation matrix
247199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon     * @param   veritces        specifies the mesh to draw.
248199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon     * @param   flags           A bitfield of options specified by SkCanvas::VerticesFlags.
249199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon     */
250199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon    void drawVertices(const GrClip&,
251199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon                      GrPaint&& paint,
252199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon                      const SkMatrix& viewMatrix,
2535fa6645dbe4f56a51ce0f59c13c99afb12ff3f5cMike Reed                      sk_sp<SkVertices> vertices);
254199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon
255199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon    /**
2560e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * Draws textured sprites from an atlas with a paint. This currently does not support AA for the
2570e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * sprite rectangle edges.
25831ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     *
25931ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     * @param   paint           describes how to color pixels.
26031ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     * @param   viewMatrix      transformation matrix
26131ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     * @param   spriteCount     number of sprites.
26231ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     * @param   xform           array of compressed transformation data, required.
26331ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     * @param   texRect         array of texture rectangles used to access the paint.
26431ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     * @param   colors          optional array of per-sprite colors, supercedes
26531ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     *                          the paint's color field.
26631ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     */
2672e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips    void drawAtlas(const GrClip&,
26882f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                   GrPaint&& paint,
26931ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth                   const SkMatrix& viewMatrix,
27031ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth                   int spriteCount,
27131ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth                   const SkRSXform xform[],
27231ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth                   const SkRect texRect[],
27331ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth                   const SkColor colors[]);
274cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett
275cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett    /**
276cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett     * Draws a region.
277cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett     *
278cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett     * @param paint         describes how to color pixels
279cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett     * @param viewMatrix    transformation matrix
2800e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param aa            should the rects of the region be antialiased.
281cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett     * @param region        the region to be drawn
282cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett     * @param style         style to apply to the region
283cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett     */
284cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett    void drawRegion(const GrClip&,
28582f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                    GrPaint&& paint,
2860e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                    GrAA aa,
287cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett                    const SkMatrix& viewMatrix,
288cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett                    const SkRegion& region,
289cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett                    const GrStyle& style);
290cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett
29131ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth    /**
292ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * Draws an oval.
293ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *
294ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param paint         describes how to color pixels.
2950e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param GrAA          Controls whether the oval is antialiased.
296ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param viewMatrix    transformation matrix
297ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param oval          the bounding rect of the oval.
2986663acff010ce752e4bf778da81fa97448c9db31bsalomon     * @param style         style to apply to the oval. Currently path effects are not allowed.
299ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
3002e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips    void drawOval(const GrClip&,
30182f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                  GrPaint&& paint,
3020e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                  GrAA,
303ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                  const SkMatrix& viewMatrix,
304ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                  const SkRect& oval,
3056663acff010ce752e4bf778da81fa97448c9db31bsalomon                  const GrStyle& style);
3060e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon    /**
3070e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * Draws a partial arc of an oval.
3080e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     *
3090e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param paint         describes how to color pixels.
3109950408c5f20148d5b726421454db718860077deBrian Salomon     * @param GrGrAA        Controls whether the arc is antialiased.
3110e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param viewMatrix    transformation matrix.
3120e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param oval          the bounding rect of the oval.
3130e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param startAngle    starting angle in degrees.
3140e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param sweepAngle    angle to sweep in degrees. Must be in (-360, 360)
3150e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param useCenter     true means that the implied path begins at the oval center, connects as
3160e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     *                      a line to the point indicated by the start contains the arc indicated by
3170e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     *                      the sweep angle. If false the line beginning at the center point is
3180e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     *                      omitted.
3190e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param style         style to apply to the oval.
3200e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     */
3214f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon    void drawArc(const GrClip&,
32282f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                 GrPaint&& paint,
3230e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                 GrAA,
3244f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon                 const SkMatrix& viewMatrix,
3254f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon                 const SkRect& oval,
3264f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon                 SkScalar startAngle,
3274f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon                 SkScalar sweepAngle,
3284f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon                 bool useCenter,
3294f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon                 const GrStyle& style);
330ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
33133a5fce6126dc5d3927a71fdc6c35af6f5893fd5joshualitt    /**
3324f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon     * Draw the image as a set of rects, specified by |iter|.
33333a5fce6126dc5d3927a71fdc6c35af6f5893fd5joshualitt     */
33410e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett    void drawImageLattice(const GrClip&,
33582f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                          GrPaint&& paint,
33610e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett                          const SkMatrix& viewMatrix,
33710e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett                          int imageWidth,
33810e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett                          int imageHeight,
33910e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett                          std::unique_ptr<SkLatticeIter> iter,
34010e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett                          const SkRect& dst);
341ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
3428c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips    /**
3438c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips     * After this returns any pending surface IO will be issued to the backend 3D API and
3448c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips     * if the surface has MSAA it will be resolved.
3458c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips     */
3468c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips    void prepareForExternalIO();
3478c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips
3487c8460e10135c05a42d0744b84838bbc24398ac2Brian Salomon    GrFSAAType fsaaType() const { return fRenderTargetProxy->fsaaType(); }
349faf8203ea7588dcdca82f69f5a5447b3eb53a849bsalomon    const GrCaps* caps() const { return fContext->caps(); }
350c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    int width() const { return fRenderTargetProxy->width(); }
351c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    int height() const { return fRenderTargetProxy->height(); }
352c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    GrPixelConfig config() const { return fRenderTargetProxy->config(); }
353c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    int numColorSamples() const { return fRenderTargetProxy->numColorSamples(); }
35450e66d4ab43685acce5a7a942074d562c5fd9639Brian Salomon    int numStencilSamples() const { return fRenderTargetProxy->numStencilSamples(); }
355ca6eafc0f7e59ed89f03a9891b9fdf7de64f1f35robertphillips    const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; }
356c71a9b7f53938b4f33f36f48e867b8b72cc1cc61msarett    GrColorSpaceXform* getColorXformFromSRGB() const { return fColorXformFromSRGB.get(); }
357c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    GrSurfaceOrigin origin() const { return fRenderTargetProxy->origin(); }
3587bceedc550513b13e0065aca66e55204a2ba3e1frobertphillips
3597761d61876ea479dd9672b684fd5c7601932a767robertphillips    bool wasAbandoned() const;
3607761d61876ea479dd9672b684fd5c7601932a767robertphillips
361c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    GrRenderTarget* accessRenderTarget() {
362c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips        // TODO: usage of this entry point needs to be reduced and potentially eliminated
363c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips        // since it ends the deferral of the GrRenderTarget's allocation
36432342f032e1dfd133040324f851f0365f9d4cb51Brian Osman        return fRenderTargetProxy->instantiate(fContext->resourceProvider());
365c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    }
3666c7e325236b7fbb9c9b14ebb4715f88a59718695robertphillips
367f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips    GrSurfaceProxy* asSurfaceProxy() override { return fRenderTargetProxy.get(); }
368f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips    const GrSurfaceProxy* asSurfaceProxy() const override { return fRenderTargetProxy.get(); }
369f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips    sk_sp<GrSurfaceProxy> asSurfaceProxyRef() override { return fRenderTargetProxy; }
370f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips
371f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips    GrTextureProxy* asTextureProxy() override;
372f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips    sk_sp<GrTextureProxy> asTextureProxyRef() override;
373f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips
374f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips    GrRenderTargetProxy* asRenderTargetProxy() override { return fRenderTargetProxy.get(); }
375f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips    sk_sp<GrRenderTargetProxy> asRenderTargetProxyRef() override { return fRenderTargetProxy; }
376eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillips
377d46697ac36d5cb3b58571c6129cb5b26fe9d25d7Robert Phillips    GrRenderTargetContext* asRenderTargetContext() override { return this; }
378d46697ac36d5cb3b58571c6129cb5b26fe9d25d7Robert Phillips
379391395dcfbff09a83f8f0e9d3e02d38c855ae2e9robertphillips    // Provides access to functions that aren't part of the public API.
380693a540272a771c6b0830094c461397cb77543b1Brian Osman    GrRenderTargetContextPriv priv();
381693a540272a771c6b0830094c461397cb77543b1Brian Osman    const GrRenderTargetContextPriv priv() const;
382f5883a6d75a18c581507214d3057b5c721ed1ffcjoshualitt
383eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillips    bool isWrapped_ForTesting() const;
384eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillips
38596880d9e366d58e5960aa0ee6aa67260797679ebjoshualittprotected:
386c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    GrRenderTargetContext(GrContext*, GrDrawingManager*, sk_sp<GrRenderTargetProxy>,
3872c86249465c28a532c8be55b6ba497021e3110ecRobert Phillips                          sk_sp<SkColorSpace>, const SkSurfaceProps*, GrAuditTrail*,
388c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips                          GrSingleOwner*);
389ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
3902e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips    SkDEBUGCODE(void validate() const;)
391ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
39296880d9e366d58e5960aa0ee6aa67260797679ebjoshualittprivate:
3937c8460e10135c05a42d0744b84838bbc24398ac2Brian Salomon    inline GrAAType chooseAAType(GrAA aa, GrAllowMixedSamples allowMixedSamples) {
3947c8460e10135c05a42d0744b84838bbc24398ac2Brian Salomon        return GrChooseAAType(aa, this->fsaaType(), allowMixedSamples);
3950e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon    }
3960e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon
397649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    friend class GrAtlasTextBlob;               // for access to add[Mesh]DrawOp
398649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    friend class GrStencilAndCoverTextContext;  // for access to add[Mesh]DrawOp
39955fdcccf01d49173bc731024b4283d3a3ea9150arobertphillips
40096880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt    friend class GrDrawingManager; // for ctor
4011105224f9701e57ec5ce0354d6a380b664f5c638Brian Osman    friend class GrRenderTargetContextPriv;
402649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    friend class GrSWMaskHelper;  // for access to add[Mesh]DrawOp
40342521e891081a7a85db4390a457074054649f194Brian Salomon
40442521e891081a7a85db4390a457074054649f194Brian Salomon    // All the path renderers currently make their own ops
405649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    friend class GrSoftwarePathRenderer;             // for access to add[Mesh]DrawOp
406649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    friend class GrAAConvexPathRenderer;             // for access to add[Mesh]DrawOp
407649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    friend class GrDashLinePathRenderer;             // for access to add[Mesh]DrawOp
408649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    friend class GrAAHairLinePathRenderer;           // for access to add[Mesh]DrawOp
409649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    friend class GrAALinearizingConvexPathRenderer;  // for access to add[Mesh]DrawOp
410830104632fd79eb5ac5bf8755a1c0271d13acb22Jim Van Verth    friend class GrSmallPathRenderer;                // for access to add[Mesh]DrawOp
411649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    friend class GrDefaultPathRenderer;              // for access to add[Mesh]DrawOp
412649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    friend class GrMSAAPathRenderer;                 // for access to add[Mesh]DrawOp
413649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    friend class GrStencilAndCoverPathRenderer;      // for access to add[Mesh]DrawOp
414649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    friend class GrTessellatingPathRenderer;         // for access to add[Mesh]DrawOp
4155d4cd9ea8818f65bb4878c050dbdb9dcd48505adBrian Salomon    // for a unit test
416296b1ccf9b8e9c8b945645efcbaa9c71c7135f58Robert Phillips    friend void test_draw_op(GrRenderTargetContext*,
41730f9bc69cfc506075e1fce8e7934f941c0203023Robert Phillips                             sk_sp<GrFragmentProcessor>, sk_sp<GrTextureProxy>);
418ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
41929df76096fd30941086324902a82656df2d8becdcsmartdalton    void internalClear(const GrFixedClip&, const GrColor, bool canIgnoreClip);
42029df76096fd30941086324902a82656df2d8becdcsmartdalton
42182f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon    // Only consumes the GrPaint if successful.
422000958973f4b514cddbfdcc01ec167437b66de2crobertphillips    bool drawFilledDRRect(const GrClip& clip,
42382f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                          GrPaint&& paint,
4240e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                          GrAA,
425000958973f4b514cddbfdcc01ec167437b66de2crobertphillips                          const SkMatrix& viewMatrix,
426000958973f4b514cddbfdcc01ec167437b66de2crobertphillips                          const SkRRect& origOuter,
427000958973f4b514cddbfdcc01ec167437b66de2crobertphillips                          const SkRRect& origInner);
428000958973f4b514cddbfdcc01ec167437b66de2crobertphillips
42982f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon    // Only consumes the GrPaint if successful.
430443023975e335e3630191227dbc21fa72c436af3robertphillips    bool drawFilledRect(const GrClip& clip,
43182f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                        GrPaint&& paint,
4320e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                        GrAA,
433443023975e335e3630191227dbc21fa72c436af3robertphillips                        const SkMatrix& viewMatrix,
434443023975e335e3630191227dbc21fa72c436af3robertphillips                        const SkRect& rect,
435443023975e335e3630191227dbc21fa72c436af3robertphillips                        const GrUserStencilSettings* ss);
436443023975e335e3630191227dbc21fa72c436af3robertphillips
437443023975e335e3630191227dbc21fa72c436af3robertphillips    void drawNonAAFilledRect(const GrClip&,
43882f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                             GrPaint&&,
439443023975e335e3630191227dbc21fa72c436af3robertphillips                             const SkMatrix& viewMatrix,
440443023975e335e3630191227dbc21fa72c436af3robertphillips                             const SkRect& rect,
441443023975e335e3630191227dbc21fa72c436af3robertphillips                             const SkRect* localRect,
442443023975e335e3630191227dbc21fa72c436af3robertphillips                             const SkMatrix* localMatrix,
44334ee0c950e1aa24818632084acdb382514f98c08csmartdalton                             const GrUserStencilSettings* ss,
4440e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                             GrAAType hwOrNoneAAType);
4450e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon
44682f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon    void internalDrawPath(
44782f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon            const GrClip&, GrPaint&&, GrAA, const SkMatrix&, const SkPath&, const GrStyle&);
448ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
449e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips    bool onCopy(GrSurfaceProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint) override;
450e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips
451649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    // These perform processing specific to Gr[Mesh]DrawOp-derived ops before recording them into
452649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    // the op list. They return the id of the opList to which the op was added, or 0, if it was
453c01389271162d08303088732c30f419807f25d33Robert Phillips    // dropped (e.g., due to clipping).
45454d212e1bfaea0be88c3c40820d0b1ae0daebecfBrian Salomon    uint32_t addDrawOp(const GrClip&, std::unique_ptr<GrDrawOp>);
455e14bd80db048277daa3db28496310e1863b5b7a9Brian Salomon    uint32_t addLegacyMeshDrawOp(GrPipelineBuilder&&, const GrClip&,
456d3ccb0a37f0e62c84fdcd6a77b7b15476b04db7aBrian Salomon                                 std::unique_ptr<GrLegacyMeshDrawOp>);
4572334fb655f8d4ef5915770d32bf845c88d3627f4robertphillips
458bf25d433f48bb336f1f7f8bcb0a4a357ac08bb16Robert Phillips    // Makes a copy of the proxy if it is necessary for the draw and places the texture that should
459bf25d433f48bb336f1f7f8bcb0a4a357ac08bb16Robert Phillips    // be used by GrXferProcessor to access the destination color in 'result'. If the return
460bf25d433f48bb336f1f7f8bcb0a4a357ac08bb16Robert Phillips    // value is false then a texture copy could not be made.
461bf25d433f48bb336f1f7f8bcb0a4a357ac08bb16Robert Phillips    bool SK_WARN_UNUSED_RESULT setupDstTexture(GrRenderTargetProxy*,
462bf25d433f48bb336f1f7f8bcb0a4a357ac08bb16Robert Phillips                                               const GrClip&,
463bf25d433f48bb336f1f7f8bcb0a4a357ac08bb16Robert Phillips                                               const SkRect& opBounds,
464bf25d433f48bb336f1f7f8bcb0a4a357ac08bb16Robert Phillips                                               GrXferProcessor::DstTexture* result);
465467921e5e6479fe9cebba125657d8e33d89004aeBrian Salomon
466f2361d2d93c200cd4555b5e8ecea4531801abaaaRobert Phillips    GrRenderTargetOpList* getOpList();
467a106c627532ad669cf7d879955ae8ea6a53233c1robertphillips
468c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    sk_sp<GrRenderTargetProxy>        fRenderTargetProxy;
469a106c627532ad669cf7d879955ae8ea6a53233c1robertphillips
4701105224f9701e57ec5ce0354d6a380b664f5c638Brian Osman    // In MDB-mode the GrOpList can be closed by some other renderTargetContext that has picked
471f2361d2d93c200cd4555b5e8ecea4531801abaaaRobert Phillips    // it up. For this reason, the GrOpList should only ever be accessed via 'getOpList'.
472dc83b892a0ae431c5fe123a7e6873d63264bd64cRobert Phillips    sk_sp<GrRenderTargetOpList>       fOpList;
473c71a9b7f53938b4f33f36f48e867b8b72cc1cc61msarett    GrInstancedPipelineInfo           fInstancedPipelineInfo;
4742334fb655f8d4ef5915770d32bf845c88d3627f4robertphillips
475c71a9b7f53938b4f33f36f48e867b8b72cc1cc61msarett    sk_sp<GrColorSpaceXform>          fColorXformFromSRGB;
476c71a9b7f53938b4f33f36f48e867b8b72cc1cc61msarett    SkSurfaceProps                    fSurfaceProps;
477e305cc1f2a44e47d6a0dcc0ff34e2692349aed5dRobert Phillips
478e305cc1f2a44e47d6a0dcc0ff34e2692349aed5dRobert Phillips    typedef GrSurfaceContext INHERITED;
479ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips};
480ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
481ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips#endif
482