GrRenderTargetContext.h revision 467921e5e6479fe9cebba125657d8e33d89004ae
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
11ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips#include "GrColor.h"
12faf8203ea7588dcdca82f69f5a5447b3eb53a849bsalomon#include "GrContext.h"
13ecbc12b1c1c72de0cf7bba4a3f6a7cce4f43bf41csmartdalton#include "GrPaint.h"
1445580d3e3024c1536e8e1b2017b704805442b634Brian Osman#include "GrSurfaceContext.h"
15467921e5e6479fe9cebba125657d8e33d89004aeBrian Salomon#include "GrXferProcessor.h"
16ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips#include "SkRefCnt.h"
17fcf7829b67b798aff4c41c4688daa9c7381991e6robertphillips#include "SkSurfaceProps.h"
18a7f29640f6ab4eb50962a9d9f12d01ac2ce8b471csmartdalton#include "../private/GrInstancedPipelineInfo.h"
19c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips#include "../private/GrRenderTargetProxy.h"
20ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
21ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass GrClip;
2277a2e52c7d5c77de73ecab5fec79072ee4460706robertphillipsclass GrDrawingManager;
239afd371a8a66f992f98eb2a3fc75ae64bddc730bBrian Salomonclass GrDrawOp;
2429df76096fd30941086324902a82656df2d8becdcsmartdaltonclass GrFixedClip;
25ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass GrPipelineBuilder;
26ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass GrRenderTarget;
2745580d3e3024c1536e8e1b2017b704805442b634Brian Osmanclass GrRenderTargetContextPriv;
28f2361d2d93c200cd4555b5e8ecea4531801abaaaRobert Phillipsclass GrRenderTargetOpList;
296663acff010ce752e4bf778da81fa97448c9db31bsalomonclass GrStyle;
30ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass GrSurface;
31eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillipsclass GrTextureProxy;
32443023975e335e3630191227dbc21fa72c436af3robertphillipsstruct GrUserStencilSettings;
332334fb655f8d4ef5915770d32bf845c88d3627f4robertphillipsclass SkDrawFilter;
34ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsstruct SkIPoint;
35ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsstruct SkIRect;
3610e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarettclass SkLatticeIter;
37ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass SkMatrix;
382334fb655f8d4ef5915770d32bf845c88d3627f4robertphillipsclass SkPaint;
39ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass SkPath;
40ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsstruct SkPoint;
41ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsstruct SkRect;
4245580d3e3024c1536e8e1b2017b704805442b634Brian Osmanclass SkRegion;
43ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass SkRRect;
4431ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverthstruct SkRSXform;
452334fb655f8d4ef5915770d32bf845c88d3627f4robertphillipsclass SkTextBlob;
46199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomonclass SkVertices;
47ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
4845580d3e3024c1536e8e1b2017b704805442b634Brian Osman/**
4945580d3e3024c1536e8e1b2017b704805442b634Brian Osman * A helper object to orchestrate commands (draws, etc...) for GrSurfaces that are GrRenderTargets.
50ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */
5145580d3e3024c1536e8e1b2017b704805442b634Brian Osmanclass SK_API GrRenderTargetContext : public GrSurfaceContext {
52ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipspublic:
531105224f9701e57ec5ce0354d6a380b664f5c638Brian Osman    ~GrRenderTargetContext() override;
542334fb655f8d4ef5915770d32bf845c88d3627f4robertphillips
556f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon    // We use SkPaint rather than GrPaint here for two reasons:
566f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon    //    * The SkPaint carries extra text settings. If these were extracted to a lighter object
576f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon    //      we could use GrPaint except that
586f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon    //    * SkPaint->GrPaint conversion depends upon whether the glyphs are color or grayscale and
596f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon    //      this can vary within a text run.
606f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon    virtual void drawText(const GrClip&, const SkPaint&, const SkMatrix& viewMatrix,
6182f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                          const char text[], size_t byteLength, SkScalar x, SkScalar y,
6282f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                          const SkIRect& clipBounds);
636f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon    virtual void drawPosText(const GrClip&, const SkPaint&, const SkMatrix& viewMatrix,
6482f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                             const char text[], size_t byteLength, const SkScalar pos[],
6582f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                             int scalarsPerPosition, const SkPoint& offset,
6682f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                             const SkIRect& clipBounds);
6796880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt    virtual void drawTextBlob(const GrClip&, const SkPaint&,
6896880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt                              const SkMatrix& viewMatrix, const SkTextBlob*,
6996880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt                              SkScalar x, SkScalar y,
7096880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt                              SkDrawFilter*, const SkIRect& clipBounds);
71ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
72ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
73ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * Provides a perfomance hint that the render target's contents are allowed
74ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * to become undefined.
75ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
762e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips    void discard();
77ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
78ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
79ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * Clear the entire or rect of the render target, ignoring any clips.
80ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param rect  the rect to clear or the whole thing if rect is NULL.
81ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param color the color to clear to.
82ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param canIgnoreRect allows partial clears to be converted to whole
83ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *                      clears on platforms for which that is cheap
84ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
852e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips    void clear(const SkIRect* rect, GrColor color, bool canIgnoreRect);
86ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
87ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
88ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *  Draw everywhere (respecting the clip) with the paint.
89ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
9082f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon    void drawPaint(const GrClip&, GrPaint&&, const SkMatrix& viewMatrix);
91ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
92ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
930e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * Draw the rect using a paint.
940e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param paint        describes how to color pixels.
950e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param GrAA         Controls whether rect is antialiased
960e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param viewMatrix   transformation matrix
970e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param style        The style to apply. Null means fill. Currently path effects are not
980e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     *                     allowed.
990e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * The rects coords are used to access the paint (through texture matrix)
100ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
1012e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips    void drawRect(const GrClip&,
10282f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                  GrPaint&& paint,
1030e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                  GrAA,
104ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                  const SkMatrix& viewMatrix,
105ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                  const SkRect&,
10682f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                  const GrStyle* style = nullptr);
107ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
108ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
109a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon     * Maps a rectangle of shader coordinates to a rectangle and fills that rectangle.
110ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *
1110e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param paint        describes how to color pixels.
1120e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param GrAA         Controls whether rect is antialiased
1130e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param viewMatrix   transformation matrix which applies to rectToDraw
1140e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param rectToDraw   the rectangle to draw
1150e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param localRect    the rectangle of shader coordinates applied to rectToDraw
116ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
117a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon    void fillRectToRect(const GrClip&,
11882f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                        GrPaint&& paint,
1190e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                        GrAA,
120a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon                        const SkMatrix& viewMatrix,
121a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon                        const SkRect& rectToDraw,
122a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon                        const SkRect& localRect);
123ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
124ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
125a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon     * Fills a rect with a paint and a localMatrix.
126ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
127a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon    void fillRectWithLocalMatrix(const GrClip& clip,
12882f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                                 GrPaint&& paint,
1290e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                                 GrAA,
130a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon                                 const SkMatrix& viewMatrix,
131a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon                                 const SkRect& rect,
132a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon                                 const SkMatrix& localMatrix);
133ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
134ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
1350e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * Draw a roundrect using a paint.
136ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *
1370e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param paint       describes how to color pixels.
1380e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param GrAA        Controls whether rrect is antialiased.
1390e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param viewMatrix  transformation matrix
1400e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param rrect       the roundrect to draw
1410e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param style       style to apply to the rrect. Currently path effects are not allowed.
142ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
1432e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips    void drawRRect(const GrClip&,
14482f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                   GrPaint&&,
1450e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                   GrAA,
146ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                   const SkMatrix& viewMatrix,
147ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                   const SkRRect& rrect,
1486663acff010ce752e4bf778da81fa97448c9db31bsalomon                   const GrStyle& style);
149ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
150ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
1510e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * Draw a roundrect using a paint and a shadow shader. This is separate from drawRRect
1520e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * because it uses different underlying geometry and GeometryProcessor
153c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth     *
1540e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param paint        describes how to color pixels.
1550e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param viewMatrix   transformation matrix
1560e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param rrect        the roundrect to draw
1570e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param blurRadius   amount of shadow blur to apply (in device space)
1580e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param style        style to apply to the rrect. Currently path effects are not allowed.
159c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth     */
160c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth    void drawShadowRRect(const GrClip&,
16182f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                         GrPaint&&,
162c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth                         const SkMatrix& viewMatrix,
163c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth                         const SkRRect& rrect,
164c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth                         SkScalar blurRadius,
165c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth                         const GrStyle& style);
166c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth
167c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth    /**
1680e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * Shortcut for filling a SkPath consisting of nested rrects using a paint. The result is
1690e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * undefined if outer does not contain inner.
170000958973f4b514cddbfdcc01ec167437b66de2crobertphillips     *
1710e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param paint        describes how to color pixels.
1720e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param GrAA         Controls whether rrects edges are antialiased
1730e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param viewMatrix   transformation matrix
1740e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param outer        the outer roundrect
1750e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param inner        the inner roundrect
176000958973f4b514cddbfdcc01ec167437b66de2crobertphillips     */
177000958973f4b514cddbfdcc01ec167437b66de2crobertphillips    void drawDRRect(const GrClip&,
17882f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                    GrPaint&&,
1790e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                    GrAA,
180000958973f4b514cddbfdcc01ec167437b66de2crobertphillips                    const SkMatrix& viewMatrix,
181000958973f4b514cddbfdcc01ec167437b66de2crobertphillips                    const SkRRect& outer,
182000958973f4b514cddbfdcc01ec167437b66de2crobertphillips                    const SkRRect& inner);
183000958973f4b514cddbfdcc01ec167437b66de2crobertphillips
184000958973f4b514cddbfdcc01ec167437b66de2crobertphillips    /**
185ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * Draws a path.
186ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *
187ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param paint         describes how to color pixels.
1880e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param GrAA          Controls whether the path is antialiased.
189ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param viewMatrix    transformation matrix
190ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param path          the path to draw
1916663acff010ce752e4bf778da81fa97448c9db31bsalomon     * @param style         style to apply to the path.
192ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
1932e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips    void drawPath(const GrClip&,
19482f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                  GrPaint&&,
1950e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                  GrAA,
196ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                  const SkMatrix& viewMatrix,
197ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                  const SkPath&,
1986663acff010ce752e4bf778da81fa97448c9db31bsalomon                  const GrStyle& style);
199ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
2003de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon    enum class ColorArrayType {
2013de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon        kPremulGrColor,
2023de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon        kSkColor,
2033de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon    };
204ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
205ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * Draws vertices with a paint.
206ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *
207ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param   paint           describes how to color pixels.
208ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param   viewMatrix      transformation matrix
209ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param   primitiveType   primitives type to draw.
210ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param   vertexCount     number of vertices.
211ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param   positions       array of vertex positions, required.
212ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param   texCoords       optional array of texture coordinates used
213ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *                          to access the paint.
214ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param   colors          optional array of per-vertex colors, supercedes
215ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *                          the paint's color field.
216ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param   indices         optional array of indices. If NULL vertices
217ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *                          are drawn non-indexed.
218ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param   indexCount      if indices is non-null then this is the
219ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *                          number of indices.
2203de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon     * @param   ColorArrayType  Determines how the color array should be interpreted.
221ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
2222e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips    void drawVertices(const GrClip&,
22382f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                      GrPaint&& paint,
224ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                      const SkMatrix& viewMatrix,
225ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                      GrPrimitiveType primitiveType,
226ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                      int vertexCount,
227ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                      const SkPoint positions[],
228ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                      const SkPoint texs[],
2293de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon                      const uint32_t colors[],
230ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                      const uint16_t indices[],
2313de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon                      int indexCount,
2323de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon                      ColorArrayType = ColorArrayType::kPremulGrColor);
233ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
234ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
235199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon     * Draws vertices with a paint.
236199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon     *
237199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon     * @param   paint           describes how to color pixels.
238199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon     * @param   viewMatrix      transformation matrix
239199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon     * @param   veritces        specifies the mesh to draw.
240199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon     * @param   flags           A bitfield of options specified by SkCanvas::VerticesFlags.
241199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon     */
242199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon    void drawVertices(const GrClip&,
243199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon                      GrPaint&& paint,
244199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon                      const SkMatrix& viewMatrix,
245199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon                      sk_sp<SkVertices> vertices,
246199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon                      uint32_t flags);
247199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon
248199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon    /**
2490e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * Draws textured sprites from an atlas with a paint. This currently does not support AA for the
2500e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * sprite rectangle edges.
25131ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     *
25231ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     * @param   paint           describes how to color pixels.
25331ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     * @param   viewMatrix      transformation matrix
25431ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     * @param   spriteCount     number of sprites.
25531ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     * @param   xform           array of compressed transformation data, required.
25631ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     * @param   texRect         array of texture rectangles used to access the paint.
25731ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     * @param   colors          optional array of per-sprite colors, supercedes
25831ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     *                          the paint's color field.
25931ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     */
2602e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips    void drawAtlas(const GrClip&,
26182f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                   GrPaint&& paint,
26231ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth                   const SkMatrix& viewMatrix,
26331ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth                   int spriteCount,
26431ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth                   const SkRSXform xform[],
26531ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth                   const SkRect texRect[],
26631ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth                   const SkColor colors[]);
267cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett
268cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett    /**
269cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett     * Draws a region.
270cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett     *
271cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett     * @param paint         describes how to color pixels
272cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett     * @param viewMatrix    transformation matrix
2730e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param aa            should the rects of the region be antialiased.
274cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett     * @param region        the region to be drawn
275cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett     * @param style         style to apply to the region
276cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett     */
277cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett    void drawRegion(const GrClip&,
27882f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                    GrPaint&& paint,
2790e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                    GrAA aa,
280cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett                    const SkMatrix& viewMatrix,
281cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett                    const SkRegion& region,
282cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett                    const GrStyle& style);
283cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett
28431ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth    /**
285ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * Draws an oval.
286ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *
287ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param paint         describes how to color pixels.
2880e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param GrAA          Controls whether the oval is antialiased.
289ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param viewMatrix    transformation matrix
290ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param oval          the bounding rect of the oval.
2916663acff010ce752e4bf778da81fa97448c9db31bsalomon     * @param style         style to apply to the oval. Currently path effects are not allowed.
292ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
2932e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips    void drawOval(const GrClip&,
29482f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                  GrPaint&& paint,
2950e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                  GrAA,
296ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                  const SkMatrix& viewMatrix,
297ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                  const SkRect& oval,
2986663acff010ce752e4bf778da81fa97448c9db31bsalomon                  const GrStyle& style);
2990e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon    /**
3000e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * Draws a partial arc of an oval.
3010e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     *
3020e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param paint         describes how to color pixels.
3039950408c5f20148d5b726421454db718860077deBrian Salomon     * @param GrGrAA        Controls whether the arc is antialiased.
3040e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param viewMatrix    transformation matrix.
3050e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param oval          the bounding rect of the oval.
3060e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param startAngle    starting angle in degrees.
3070e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param sweepAngle    angle to sweep in degrees. Must be in (-360, 360)
3080e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param useCenter     true means that the implied path begins at the oval center, connects as
3090e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     *                      a line to the point indicated by the start contains the arc indicated by
3100e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     *                      the sweep angle. If false the line beginning at the center point is
3110e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     *                      omitted.
3120e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param style         style to apply to the oval.
3130e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     */
3144f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon    void drawArc(const GrClip&,
31582f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                 GrPaint&& paint,
3160e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                 GrAA,
3174f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon                 const SkMatrix& viewMatrix,
3184f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon                 const SkRect& oval,
3194f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon                 SkScalar startAngle,
3204f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon                 SkScalar sweepAngle,
3214f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon                 bool useCenter,
3224f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon                 const GrStyle& style);
323ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
32433a5fce6126dc5d3927a71fdc6c35af6f5893fd5joshualitt    /**
3254f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon     * Draw the image as a set of rects, specified by |iter|.
32633a5fce6126dc5d3927a71fdc6c35af6f5893fd5joshualitt     */
32710e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett    void drawImageLattice(const GrClip&,
32882f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                          GrPaint&& paint,
32910e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett                          const SkMatrix& viewMatrix,
33010e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett                          int imageWidth,
33110e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett                          int imageHeight,
33210e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett                          std::unique_ptr<SkLatticeIter> iter,
33310e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett                          const SkRect& dst);
334ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
3358c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips    /**
3368c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips     * After this returns any pending surface IO will be issued to the backend 3D API and
3378c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips     * if the surface has MSAA it will be resolved.
3388c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips     */
3398c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips    void prepareForExternalIO();
3408c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips
341976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips    bool isStencilBufferMultisampled() const {
342c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips        return fRenderTargetProxy->isStencilBufferMultisampled();
343976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips    }
344c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    bool isUnifiedMultisampled() const { return fRenderTargetProxy->isUnifiedMultisampled(); }
345c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    bool hasMixedSamples() const { return fRenderTargetProxy->isMixedSampled(); }
34682ec6e59b8b694c128adcf8590667d37327dd1c4robertphillips
347faf8203ea7588dcdca82f69f5a5447b3eb53a849bsalomon    const GrCaps* caps() const { return fContext->caps(); }
348c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    const GrSurfaceDesc& desc() const { return fRenderTargetProxy->desc(); }
349c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    int width() const { return fRenderTargetProxy->width(); }
350c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    int height() const { return fRenderTargetProxy->height(); }
351c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    GrPixelConfig config() const { return fRenderTargetProxy->config(); }
352c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    int numColorSamples() const { return fRenderTargetProxy->numColorSamples(); }
353ca6eafc0f7e59ed89f03a9891b9fdf7de64f1f35robertphillips    const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; }
354c71a9b7f53938b4f33f36f48e867b8b72cc1cc61msarett    GrColorSpaceXform* getColorXformFromSRGB() const { return fColorXformFromSRGB.get(); }
355c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    GrSurfaceOrigin origin() const { return fRenderTargetProxy->origin(); }
3567bceedc550513b13e0065aca66e55204a2ba3e1frobertphillips
3577761d61876ea479dd9672b684fd5c7601932a767robertphillips    bool wasAbandoned() const;
3587761d61876ea479dd9672b684fd5c7601932a767robertphillips
359eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillips    GrRenderTarget* instantiate();
360eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillips
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
379c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    sk_sp<GrTexture> asTexture() {
380e60ad620fe236ce4c1e85a31bd53ed0c848da8c3Robert Phillips        if (!this->accessRenderTarget()) {
381e60ad620fe236ce4c1e85a31bd53ed0c848da8c3Robert Phillips            return nullptr;
382e60ad620fe236ce4c1e85a31bd53ed0c848da8c3Robert Phillips        }
383e60ad620fe236ce4c1e85a31bd53ed0c848da8c3Robert Phillips
384c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips        // TODO: usage of this entry point needs to be reduced and potentially eliminated
385c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips        // since it ends the deferral of the GrRenderTarget's allocation
386f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips        // It's usage should migrate to asTextureProxyRef
387c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips        return sk_ref_sp(this->accessRenderTarget()->asTexture());
388c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    }
389433625e67c61c3acce4fd95b3881493c9f4f2c7frobertphillips
390391395dcfbff09a83f8f0e9d3e02d38c855ae2e9robertphillips    // Provides access to functions that aren't part of the public API.
391693a540272a771c6b0830094c461397cb77543b1Brian Osman    GrRenderTargetContextPriv priv();
392693a540272a771c6b0830094c461397cb77543b1Brian Osman    const GrRenderTargetContextPriv priv() const;
393f5883a6d75a18c581507214d3057b5c721ed1ffcjoshualitt
394eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillips    bool isWrapped_ForTesting() const;
395eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillips
39696880d9e366d58e5960aa0ee6aa67260797679ebjoshualittprotected:
397c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    GrRenderTargetContext(GrContext*, GrDrawingManager*, sk_sp<GrRenderTargetProxy>,
3982c86249465c28a532c8be55b6ba497021e3110ecRobert Phillips                          sk_sp<SkColorSpace>, const SkSurfaceProps*, GrAuditTrail*,
399c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips                          GrSingleOwner*);
400ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
4012e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips    SkDEBUGCODE(void validate() const;)
402ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
40396880d9e366d58e5960aa0ee6aa67260797679ebjoshualittprivate:
4040e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon    inline GrAAType decideAAType(GrAA aa, bool allowMixedSamples = false) {
4050e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon        if (GrAA::kNo == aa) {
4060e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon            return GrAAType::kNone;
4070e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon        }
4080e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon        if (this->isUnifiedMultisampled()) {
4090e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon            return GrAAType::kMSAA;
4100e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon        }
4110e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon        if (allowMixedSamples && this->isStencilBufferMultisampled()) {
4120e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon            return GrAAType::kMixedSamples;
4130e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon        }
4140e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon        return GrAAType::kCoverage;
4150e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon    }
4160e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon
41742521e891081a7a85db4390a457074054649f194Brian Salomon    friend class GrAtlasTextBlob; // for access to addDrawOp
41842521e891081a7a85db4390a457074054649f194Brian Salomon    friend class GrStencilAndCoverTextContext; // for access to addDrawOp
41955fdcccf01d49173bc731024b4283d3a3ea9150arobertphillips
42096880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt    friend class GrDrawingManager; // for ctor
4211105224f9701e57ec5ce0354d6a380b664f5c638Brian Osman    friend class GrRenderTargetContextPriv;
42242521e891081a7a85db4390a457074054649f194Brian Salomon    friend class GrSWMaskHelper;                 // for access to addDrawOp
42342521e891081a7a85db4390a457074054649f194Brian Salomon
42442521e891081a7a85db4390a457074054649f194Brian Salomon    // All the path renderers currently make their own ops
42542521e891081a7a85db4390a457074054649f194Brian Salomon    friend class GrSoftwarePathRenderer;         // for access to addDrawOp
42642521e891081a7a85db4390a457074054649f194Brian Salomon    friend class GrAAConvexPathRenderer;         // for access to addDrawOp
42742521e891081a7a85db4390a457074054649f194Brian Salomon    friend class GrDashLinePathRenderer;         // for access to addDrawOp
42842521e891081a7a85db4390a457074054649f194Brian Salomon    friend class GrAAHairLinePathRenderer;       // for access to addDrawOp
42942521e891081a7a85db4390a457074054649f194Brian Salomon    friend class GrAALinearizingConvexPathRenderer;  // for access to addDrawOp
43042521e891081a7a85db4390a457074054649f194Brian Salomon    friend class GrAADistanceFieldPathRenderer;  // for access to addDrawOp
43142521e891081a7a85db4390a457074054649f194Brian Salomon    friend class GrDefaultPathRenderer;          // for access to addDrawOp
43242521e891081a7a85db4390a457074054649f194Brian Salomon    friend class GrMSAAPathRenderer;             // for access to addDrawOp
43342521e891081a7a85db4390a457074054649f194Brian Salomon    friend class GrStencilAndCoverPathRenderer;  // for access to addDrawOp
43442521e891081a7a85db4390a457074054649f194Brian Salomon    friend class GrTessellatingPathRenderer;     // for access to addDrawOp
4355d4cd9ea8818f65bb4878c050dbdb9dcd48505adBrian Salomon    // for a unit test
43630f9bc69cfc506075e1fce8e7934f941c0203023Robert Phillips    friend void test_draw_op(GrContext*, GrRenderTargetContext*,
43730f9bc69cfc506075e1fce8e7934f941c0203023Robert Phillips                             sk_sp<GrFragmentProcessor>, sk_sp<GrTextureProxy>);
438ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
43929df76096fd30941086324902a82656df2d8becdcsmartdalton    void internalClear(const GrFixedClip&, const GrColor, bool canIgnoreClip);
44029df76096fd30941086324902a82656df2d8becdcsmartdalton
44182f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon    // Only consumes the GrPaint if successful.
442000958973f4b514cddbfdcc01ec167437b66de2crobertphillips    bool drawFilledDRRect(const GrClip& clip,
44382f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                          GrPaint&& paint,
4440e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                          GrAA,
445000958973f4b514cddbfdcc01ec167437b66de2crobertphillips                          const SkMatrix& viewMatrix,
446000958973f4b514cddbfdcc01ec167437b66de2crobertphillips                          const SkRRect& origOuter,
447000958973f4b514cddbfdcc01ec167437b66de2crobertphillips                          const SkRRect& origInner);
448000958973f4b514cddbfdcc01ec167437b66de2crobertphillips
44982f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon    // Only consumes the GrPaint if successful.
450443023975e335e3630191227dbc21fa72c436af3robertphillips    bool drawFilledRect(const GrClip& clip,
45182f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                        GrPaint&& paint,
4520e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                        GrAA,
453443023975e335e3630191227dbc21fa72c436af3robertphillips                        const SkMatrix& viewMatrix,
454443023975e335e3630191227dbc21fa72c436af3robertphillips                        const SkRect& rect,
455443023975e335e3630191227dbc21fa72c436af3robertphillips                        const GrUserStencilSettings* ss);
456443023975e335e3630191227dbc21fa72c436af3robertphillips
457443023975e335e3630191227dbc21fa72c436af3robertphillips    void drawNonAAFilledRect(const GrClip&,
45882f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                             GrPaint&&,
459443023975e335e3630191227dbc21fa72c436af3robertphillips                             const SkMatrix& viewMatrix,
460443023975e335e3630191227dbc21fa72c436af3robertphillips                             const SkRect& rect,
461443023975e335e3630191227dbc21fa72c436af3robertphillips                             const SkRect* localRect,
462443023975e335e3630191227dbc21fa72c436af3robertphillips                             const SkMatrix* localMatrix,
46334ee0c950e1aa24818632084acdb382514f98c08csmartdalton                             const GrUserStencilSettings* ss,
4640e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                             GrAAType hwOrNoneAAType);
4650e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon
46682f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon    void internalDrawPath(
46782f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon            const GrClip&, GrPaint&&, GrAA, const SkMatrix&, const SkPath&, const GrStyle&);
468ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
469e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips    bool onCopy(GrSurfaceProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint) override;
4702c86249465c28a532c8be55b6ba497021e3110ecRobert Phillips    bool onReadPixels(const SkImageInfo& dstInfo, void* dstBuffer,
4712c86249465c28a532c8be55b6ba497021e3110ecRobert Phillips                      size_t dstRowBytes, int x, int y) override;
4722c86249465c28a532c8be55b6ba497021e3110ecRobert Phillips    bool onWritePixels(const SkImageInfo& srcInfo, const void* srcBuffer,
47330f9bc69cfc506075e1fce8e7934f941c0203023Robert Phillips                       size_t srcRowBytes, int x, int y, uint32_t flags) override;
474e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips
475467921e5e6479fe9cebba125657d8e33d89004aeBrian Salomon    // This performs processing specific to GrDrawOp-derived ops before recording them into the
476467921e5e6479fe9cebba125657d8e33d89004aeBrian Salomon    // op list.
477f8334781914363caf537f22f012fcd5c03c60dadBrian Salomon    void addDrawOp(const GrPipelineBuilder&, const GrClip&, std::unique_ptr<GrDrawOp>);
4782334fb655f8d4ef5915770d32bf845c88d3627f4robertphillips
479467921e5e6479fe9cebba125657d8e33d89004aeBrian Salomon    // Makes a copy of the dst if it is necessary for the draw and returns the texture that should
480467921e5e6479fe9cebba125657d8e33d89004aeBrian Salomon    // be used by GrXferProcessor to access the destination color. If the texture is nullptr then
481467921e5e6479fe9cebba125657d8e33d89004aeBrian Salomon    // a texture copy could not be made.
482467921e5e6479fe9cebba125657d8e33d89004aeBrian Salomon    void setupDstTexture(GrRenderTarget*, const GrClip&, const SkRect& opBounds,
483467921e5e6479fe9cebba125657d8e33d89004aeBrian Salomon                         GrXferProcessor::DstTexture*);
484467921e5e6479fe9cebba125657d8e33d89004aeBrian Salomon
485467921e5e6479fe9cebba125657d8e33d89004aeBrian Salomon
486f2361d2d93c200cd4555b5e8ecea4531801abaaaRobert Phillips    GrRenderTargetOpList* getOpList();
487a106c627532ad669cf7d879955ae8ea6a53233c1robertphillips
488c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    sk_sp<GrRenderTargetProxy>        fRenderTargetProxy;
489a106c627532ad669cf7d879955ae8ea6a53233c1robertphillips
4901105224f9701e57ec5ce0354d6a380b664f5c638Brian Osman    // In MDB-mode the GrOpList can be closed by some other renderTargetContext that has picked
491f2361d2d93c200cd4555b5e8ecea4531801abaaaRobert Phillips    // it up. For this reason, the GrOpList should only ever be accessed via 'getOpList'.
492f2361d2d93c200cd4555b5e8ecea4531801abaaaRobert Phillips    GrRenderTargetOpList*             fOpList;
493c71a9b7f53938b4f33f36f48e867b8b72cc1cc61msarett    GrInstancedPipelineInfo           fInstancedPipelineInfo;
4942334fb655f8d4ef5915770d32bf845c88d3627f4robertphillips
495c71a9b7f53938b4f33f36f48e867b8b72cc1cc61msarett    sk_sp<GrColorSpaceXform>          fColorXformFromSRGB;
496c71a9b7f53938b4f33f36f48e867b8b72cc1cc61msarett    SkSurfaceProps                    fSurfaceProps;
497e305cc1f2a44e47d6a0dcc0ff34e2692349aed5dRobert Phillips
498e305cc1f2a44e47d6a0dcc0ff34e2692349aed5dRobert Phillips    typedef GrSurfaceContext INHERITED;
499ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips};
500ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
501ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips#endif
502