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/GrRenderTargetProxy.h"
12ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips#include "GrColor.h"
13faf8203ea7588dcdca82f69f5a5447b3eb53a849bsalomon#include "GrContext.h"
146be756b673b823881e90a2ef68c12b640ddde549Robert Phillips#include "GrContextPriv.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"
21f18b1d88aa98f81d2c115a59d887265fea63f876Brian Salomon#include "text/GrTextUtils.h"
22ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
23a5cb781c17c09e01655defd0a84b431996b6a015Greg Danielclass GrBackendSemaphore;
241a325d25b941ef801b3e9b2c0342da43cf35cdbaChris Daltonclass GrCCPRAtlas;
25ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass GrClip;
262240be96d97b5ac0886381d74a21f1e2a0928f55Brian Osmanclass GrColorSpaceXform;
271a325d25b941ef801b3e9b2c0342da43cf35cdbaChris Daltonclass GrCoverageCountingPathRenderer;
2877a2e52c7d5c77de73ecab5fec79072ee4460706robertphillipsclass GrDrawingManager;
299afd371a8a66f992f98eb2a3fc75ae64bddc730bBrian Salomonclass GrDrawOp;
3029df76096fd30941086324902a82656df2d8becdcsmartdaltonclass GrFixedClip;
31ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass GrRenderTarget;
3245580d3e3024c1536e8e1b2017b704805442b634Brian Osmanclass GrRenderTargetContextPriv;
33f2361d2d93c200cd4555b5e8ecea4531801abaaaRobert Phillipsclass GrRenderTargetOpList;
342fad74a0fdc5eb3f505a052849c3cbeffa6e2d17Brian Salomonclass GrShape;
356663acff010ce752e4bf778da81fa97448c9db31bsalomonclass GrStyle;
36eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillipsclass GrTextureProxy;
37443023975e335e3630191227dbc21fa72c436af3robertphillipsstruct GrUserStencilSettings;
382334fb655f8d4ef5915770d32bf845c88d3627f4robertphillipsclass SkDrawFilter;
393af1af9e979552cf2e3b22feb1de5aeba810fc4eJim Van Verthstruct SkDrawShadowRec;
40ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsstruct SkIPoint;
41ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsstruct SkIRect;
4210e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarettclass SkLatticeIter;
43ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass SkMatrix;
442334fb655f8d4ef5915770d32bf845c88d3627f4robertphillipsclass SkPaint;
45ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass SkPath;
46ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsstruct SkPoint;
47ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsstruct SkRect;
4845580d3e3024c1536e8e1b2017b704805442b634Brian Osmanclass SkRegion;
49ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass SkRRect;
5031ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverthstruct SkRSXform;
512334fb655f8d4ef5915770d32bf845c88d3627f4robertphillipsclass SkTextBlob;
52199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomonclass SkVertices;
53ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
5445580d3e3024c1536e8e1b2017b704805442b634Brian Osman/**
5545580d3e3024c1536e8e1b2017b704805442b634Brian Osman * A helper object to orchestrate commands (draws, etc...) for GrSurfaces that are GrRenderTargets.
56ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */
5745580d3e3024c1536e8e1b2017b704805442b634Brian Osmanclass SK_API GrRenderTargetContext : public GrSurfaceContext {
58ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipspublic:
591105224f9701e57ec5ce0354d6a380b664f5c638Brian Osman    ~GrRenderTargetContext() override;
602334fb655f8d4ef5915770d32bf845c88d3627f4robertphillips
616f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon    // We use SkPaint rather than GrPaint here for two reasons:
626f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon    //    * The SkPaint carries extra text settings. If these were extracted to a lighter object
636f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon    //      we could use GrPaint except that
646f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon    //    * SkPaint->GrPaint conversion depends upon whether the glyphs are color or grayscale and
656f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon    //      this can vary within a text run.
666f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon    virtual void drawText(const GrClip&, const SkPaint&, const SkMatrix& viewMatrix,
6782f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                          const char text[], size_t byteLength, SkScalar x, SkScalar y,
6882f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                          const SkIRect& clipBounds);
696f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon    virtual void drawPosText(const GrClip&, const SkPaint&, const SkMatrix& viewMatrix,
7082f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                             const char text[], size_t byteLength, const SkScalar pos[],
7182f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                             int scalarsPerPosition, const SkPoint& offset,
7282f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                             const SkIRect& clipBounds);
7396880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt    virtual void drawTextBlob(const GrClip&, const SkPaint&,
7496880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt                              const SkMatrix& viewMatrix, const SkTextBlob*,
7596880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt                              SkScalar x, SkScalar y,
7696880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt                              SkDrawFilter*, const SkIRect& clipBounds);
77ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
78ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
79ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * Provides a perfomance hint that the render target's contents are allowed
80ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * to become undefined.
81ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
822e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips    void discard();
83ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
84344e9037e1befdee76691a1239a47829e6af4ea5Chris Dalton    enum class CanClearFullscreen : bool {
85344e9037e1befdee76691a1239a47829e6af4ea5Chris Dalton        kNo = false,
86344e9037e1befdee76691a1239a47829e6af4ea5Chris Dalton        kYes = true
87344e9037e1befdee76691a1239a47829e6af4ea5Chris Dalton    };
88344e9037e1befdee76691a1239a47829e6af4ea5Chris Dalton
89ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
90ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * Clear the entire or rect of the render target, ignoring any clips.
91ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param rect  the rect to clear or the whole thing if rect is NULL.
92ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param color the color to clear to.
93344e9037e1befdee76691a1239a47829e6af4ea5Chris Dalton     * @param CanClearFullscreen allows partial clears to be converted to fullscreen clears on
94344e9037e1befdee76691a1239a47829e6af4ea5Chris Dalton     *                           tiling platforms where that is an optimization.
95ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
96344e9037e1befdee76691a1239a47829e6af4ea5Chris Dalton    void clear(const SkIRect* rect, GrColor color, CanClearFullscreen);
97ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
98ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
99ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *  Draw everywhere (respecting the clip) with the paint.
100ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
10182f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon    void drawPaint(const GrClip&, GrPaint&&, const SkMatrix& viewMatrix);
102ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
103ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
1040e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * Draw the rect using a paint.
1050e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param paint        describes how to color pixels.
1060e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param GrAA         Controls whether rect is antialiased
1070e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param viewMatrix   transformation matrix
1080e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param style        The style to apply. Null means fill. Currently path effects are not
1090e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     *                     allowed.
1100e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * The rects coords are used to access the paint (through texture matrix)
111ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
1122e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips    void drawRect(const GrClip&,
11382f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                  GrPaint&& paint,
1140e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                  GrAA,
115ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                  const SkMatrix& viewMatrix,
116ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                  const SkRect&,
11782f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                  const GrStyle* style = nullptr);
118ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
119ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
120a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon     * Maps a rectangle of shader coordinates to a rectangle and fills that rectangle.
121ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *
1220e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param paint        describes how to color pixels.
1230e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param GrAA         Controls whether rect is antialiased
1240e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param viewMatrix   transformation matrix which applies to rectToDraw
1250e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param rectToDraw   the rectangle to draw
1260e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param localRect    the rectangle of shader coordinates applied to rectToDraw
127ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
128a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon    void fillRectToRect(const GrClip&,
12982f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                        GrPaint&& paint,
1300e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                        GrAA,
131a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon                        const SkMatrix& viewMatrix,
132a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon                        const SkRect& rectToDraw,
133a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon                        const SkRect& localRect);
134ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
135ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
136a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon     * Fills a rect with a paint and a localMatrix.
137ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
138a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon    void fillRectWithLocalMatrix(const GrClip& clip,
13982f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                                 GrPaint&& paint,
1400e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                                 GrAA,
141a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon                                 const SkMatrix& viewMatrix,
142a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon                                 const SkRect& rect,
143a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon                                 const SkMatrix& localMatrix);
144ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
145ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
1463416969605137214a9e1b1fb85182e5640a655abBrian Salomon     * Creates an op that draws a subrectangle of a texture. The passed color is modulated by the
1473416969605137214a9e1b1fb85182e5640a655abBrian Salomon     * texture's color. 'srcRect' specifies the rectangle of the texture to draw. 'dstRect'
1483416969605137214a9e1b1fb85182e5640a655abBrian Salomon     * specifies the rectangle to draw in local coords which will be transformed by 'viewMatrix' to
149b5ef1f9b13e36a427dd6350986d41db208b2df1bBrian Salomon     * device space. This asserts that the view matrix does not have perspective.
1503416969605137214a9e1b1fb85182e5640a655abBrian Salomon     */
1512bbdcc44c63974f29f3743bb58d929601a3f65c6Brian Salomon    void drawTextureAffine(const GrClip& clip, sk_sp<GrTextureProxy>, GrSamplerState::Filter,
152b5ef1f9b13e36a427dd6350986d41db208b2df1bBrian Salomon                           GrColor, const SkRect& srcRect, const SkRect& dstRect, GrAA aa,
1533416969605137214a9e1b1fb85182e5640a655abBrian Salomon                           const SkMatrix& viewMatrix, sk_sp<GrColorSpaceXform>);
1543416969605137214a9e1b1fb85182e5640a655abBrian Salomon
1553416969605137214a9e1b1fb85182e5640a655abBrian Salomon    /**
1560e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * Draw a roundrect using a paint.
157ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *
1580e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param paint       describes how to color pixels.
1590e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param GrAA        Controls whether rrect is antialiased.
1600e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param viewMatrix  transformation matrix
1610e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param rrect       the roundrect to draw
1620e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param style       style to apply to the rrect. Currently path effects are not allowed.
163ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
1642e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips    void drawRRect(const GrClip&,
16582f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                   GrPaint&&,
1660e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                   GrAA,
167ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                   const SkMatrix& viewMatrix,
168ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                   const SkRRect& rrect,
1696663acff010ce752e4bf778da81fa97448c9db31bsalomon                   const GrStyle& style);
170ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
171ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
1723af1af9e979552cf2e3b22feb1de5aeba810fc4eJim Van Verth     * Use a fast method to render the ambient and spot shadows for a path.
1733af1af9e979552cf2e3b22feb1de5aeba810fc4eJim Van Verth     * Will return false if not possible for the given path.
174c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth     *
1750e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param viewMatrix   transformation matrix
1763af1af9e979552cf2e3b22feb1de5aeba810fc4eJim Van Verth     * @param path         the path to shadow
1773af1af9e979552cf2e3b22feb1de5aeba810fc4eJim Van Verth     * @param rec          parameters for shadow rendering
178c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth     */
1793af1af9e979552cf2e3b22feb1de5aeba810fc4eJim Van Verth    bool drawFastShadow(const GrClip&,
1803af1af9e979552cf2e3b22feb1de5aeba810fc4eJim Van Verth                        const SkMatrix& viewMatrix,
1813af1af9e979552cf2e3b22feb1de5aeba810fc4eJim Van Verth                        const SkPath& path,
1823af1af9e979552cf2e3b22feb1de5aeba810fc4eJim Van Verth                        const SkDrawShadowRec& rec);
183c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth
184c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth    /**
1850e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * Shortcut for filling a SkPath consisting of nested rrects using a paint. The result is
1860e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * undefined if outer does not contain inner.
187000958973f4b514cddbfdcc01ec167437b66de2crobertphillips     *
1880e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param paint        describes how to color pixels.
1890e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param GrAA         Controls whether rrects edges are antialiased
1900e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param viewMatrix   transformation matrix
1910e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param outer        the outer roundrect
1920e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param inner        the inner roundrect
193000958973f4b514cddbfdcc01ec167437b66de2crobertphillips     */
194000958973f4b514cddbfdcc01ec167437b66de2crobertphillips    void drawDRRect(const GrClip&,
19582f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                    GrPaint&&,
1960e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                    GrAA,
197000958973f4b514cddbfdcc01ec167437b66de2crobertphillips                    const SkMatrix& viewMatrix,
198000958973f4b514cddbfdcc01ec167437b66de2crobertphillips                    const SkRRect& outer,
199000958973f4b514cddbfdcc01ec167437b66de2crobertphillips                    const SkRRect& inner);
200000958973f4b514cddbfdcc01ec167437b66de2crobertphillips
201000958973f4b514cddbfdcc01ec167437b66de2crobertphillips    /**
202ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * Draws a path.
203ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *
204ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param paint         describes how to color pixels.
2050e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param GrAA          Controls whether the path is antialiased.
206ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param viewMatrix    transformation matrix
207ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param path          the path to draw
2086663acff010ce752e4bf778da81fa97448c9db31bsalomon     * @param style         style to apply to the path.
209ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
2102e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips    void drawPath(const GrClip&,
21182f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                  GrPaint&&,
2120e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                  GrAA,
213ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                  const SkMatrix& viewMatrix,
214ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                  const SkPath&,
2156663acff010ce752e4bf778da81fa97448c9db31bsalomon                  const GrStyle& style);
216ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
217ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips    /**
218ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * Draws vertices with a paint.
219ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *
220ae0c50c62432ba9683bf2deec567bdabb2b9f825Brian Osman     * @param   paint            describes how to color pixels.
221ae0c50c62432ba9683bf2deec567bdabb2b9f825Brian Osman     * @param   viewMatrix       transformation matrix
222ae0c50c62432ba9683bf2deec567bdabb2b9f825Brian Osman     * @param   vertices         specifies the mesh to draw.
223ae0c50c62432ba9683bf2deec567bdabb2b9f825Brian Osman     * @param   overridePrimType primitive type to draw. If NULL, derive prim type from vertices.
224199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon     */
225199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon    void drawVertices(const GrClip&,
226199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon                      GrPaint&& paint,
227199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon                      const SkMatrix& viewMatrix,
228ae0c50c62432ba9683bf2deec567bdabb2b9f825Brian Osman                      sk_sp<SkVertices> vertices,
229ae0c50c62432ba9683bf2deec567bdabb2b9f825Brian Osman                      GrPrimitiveType* overridePrimType = nullptr);
230199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon
231199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon    /**
2320e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * Draws textured sprites from an atlas with a paint. This currently does not support AA for the
2330e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * sprite rectangle edges.
23431ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     *
23531ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     * @param   paint           describes how to color pixels.
23631ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     * @param   viewMatrix      transformation matrix
23731ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     * @param   spriteCount     number of sprites.
23831ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     * @param   xform           array of compressed transformation data, required.
23931ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     * @param   texRect         array of texture rectangles used to access the paint.
24031ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     * @param   colors          optional array of per-sprite colors, supercedes
24131ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     *                          the paint's color field.
24231ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth     */
2432e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips    void drawAtlas(const GrClip&,
24482f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                   GrPaint&& paint,
24531ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth                   const SkMatrix& viewMatrix,
24631ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth                   int spriteCount,
24731ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth                   const SkRSXform xform[],
24831ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth                   const SkRect texRect[],
24931ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth                   const SkColor colors[]);
250cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett
251cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett    /**
252cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett     * Draws a region.
253cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett     *
254cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett     * @param paint         describes how to color pixels
255cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett     * @param viewMatrix    transformation matrix
2560e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param aa            should the rects of the region be antialiased.
257cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett     * @param region        the region to be drawn
258cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett     * @param style         style to apply to the region
259cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett     */
260cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett    void drawRegion(const GrClip&,
26182f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                    GrPaint&& paint,
2620e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                    GrAA aa,
263cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett                    const SkMatrix& viewMatrix,
264cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett                    const SkRegion& region,
26573d8fd90653135bb1247f92ebc1d730a40b4f9d5Stan Iliev                    const GrStyle& style,
26673d8fd90653135bb1247f92ebc1d730a40b4f9d5Stan Iliev                    const GrUserStencilSettings* ss = nullptr);
267cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett
26831ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth    /**
269ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * Draws an oval.
270ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     *
271ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param paint         describes how to color pixels.
2720e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param GrAA          Controls whether the oval is antialiased.
273ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param viewMatrix    transformation matrix
274ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     * @param oval          the bounding rect of the oval.
2756663acff010ce752e4bf778da81fa97448c9db31bsalomon     * @param style         style to apply to the oval. Currently path effects are not allowed.
276ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips     */
2772e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips    void drawOval(const GrClip&,
27882f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                  GrPaint&& paint,
2790e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                  GrAA,
280ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                  const SkMatrix& viewMatrix,
281ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips                  const SkRect& oval,
2826663acff010ce752e4bf778da81fa97448c9db31bsalomon                  const GrStyle& style);
2830e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon    /**
2840e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * Draws a partial arc of an oval.
2850e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     *
2860e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param paint         describes how to color pixels.
2879950408c5f20148d5b726421454db718860077deBrian Salomon     * @param GrGrAA        Controls whether the arc is antialiased.
2880e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param viewMatrix    transformation matrix.
2890e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param oval          the bounding rect of the oval.
2900e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param startAngle    starting angle in degrees.
2910e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param sweepAngle    angle to sweep in degrees. Must be in (-360, 360)
2920e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param useCenter     true means that the implied path begins at the oval center, connects as
2930e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     *                      a line to the point indicated by the start contains the arc indicated by
2940e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     *                      the sweep angle. If false the line beginning at the center point is
2950e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     *                      omitted.
2960e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     * @param style         style to apply to the oval.
2970e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon     */
2984f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon    void drawArc(const GrClip&,
29982f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                 GrPaint&& paint,
3000e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                 GrAA,
3014f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon                 const SkMatrix& viewMatrix,
3024f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon                 const SkRect& oval,
3034f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon                 SkScalar startAngle,
3044f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon                 SkScalar sweepAngle,
3054f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon                 bool useCenter,
3064f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon                 const GrStyle& style);
307ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
30833a5fce6126dc5d3927a71fdc6c35af6f5893fd5joshualitt    /**
3094f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon     * Draw the image as a set of rects, specified by |iter|.
31033a5fce6126dc5d3927a71fdc6c35af6f5893fd5joshualitt     */
31110e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett    void drawImageLattice(const GrClip&,
31238784599f39026f54aa56b3c6e34afc15e00abd6Leon Scroggins III                          GrPaint&&,
31310e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett                          const SkMatrix& viewMatrix,
31438784599f39026f54aa56b3c6e34afc15e00abd6Leon Scroggins III                          sk_sp<GrTextureProxy>,
31538784599f39026f54aa56b3c6e34afc15e00abd6Leon Scroggins III                          sk_sp<GrColorSpaceXform>,
31638784599f39026f54aa56b3c6e34afc15e00abd6Leon Scroggins III                          GrSamplerState::Filter,
31738784599f39026f54aa56b3c6e34afc15e00abd6Leon Scroggins III                          std::unique_ptr<SkLatticeIter>,
31810e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett                          const SkRect& dst);
319ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
3208c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips    /**
3218c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips     * After this returns any pending surface IO will be issued to the backend 3D API and
3228c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips     * if the surface has MSAA it will be resolved.
3238c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips     */
3245131678123839cec0e974069b6d3f047c8a82049Greg Daniel    GrSemaphoresSubmitted prepareForExternalIO(int numSemaphores,
3255131678123839cec0e974069b6d3f047c8a82049Greg Daniel                                               GrBackendSemaphore backendSemaphores[]);
326a5cb781c17c09e01655defd0a84b431996b6a015Greg Daniel
327a5cb781c17c09e01655defd0a84b431996b6a015Greg Daniel    /**
328a5cb781c17c09e01655defd0a84b431996b6a015Greg Daniel     *  The next time this GrRenderTargetContext is flushed, the gpu will wait on the passed in
329a5cb781c17c09e01655defd0a84b431996b6a015Greg Daniel     *  semaphores before executing any commands.
330a5cb781c17c09e01655defd0a84b431996b6a015Greg Daniel     */
331c64ee46a982695dc32b9cad4dd4e635ac09cd25eGreg Daniel    bool waitOnSemaphores(int numSemaphores, const GrBackendSemaphore* waitSemaphores);
3328c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips
33365a88fadab72abd104fdf4cc4a97488b2e901c60Robert Phillips    void insertEventMarker(const SkString&);
33465a88fadab72abd104fdf4cc4a97488b2e901c60Robert Phillips
3357c8460e10135c05a42d0744b84838bbc24398ac2Brian Salomon    GrFSAAType fsaaType() const { return fRenderTargetProxy->fsaaType(); }
336faf8203ea7588dcdca82f69f5a5447b3eb53a849bsalomon    const GrCaps* caps() const { return fContext->caps(); }
337c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    int width() const { return fRenderTargetProxy->width(); }
338c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    int height() const { return fRenderTargetProxy->height(); }
339c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    int numColorSamples() const { return fRenderTargetProxy->numColorSamples(); }
34050e66d4ab43685acce5a7a942074d562c5fd9639Brian Salomon    int numStencilSamples() const { return fRenderTargetProxy->numStencilSamples(); }
341ca6eafc0f7e59ed89f03a9891b9fdf7de64f1f35robertphillips    const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; }
342c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    GrSurfaceOrigin origin() const { return fRenderTargetProxy->origin(); }
343e252f08982b0c747cd4d34c00ce413ab1005e99aGreg Daniel    GrMipMapped mipMapped() const;
3447bceedc550513b13e0065aca66e55204a2ba3e1frobertphillips
3457761d61876ea479dd9672b684fd5c7601932a767robertphillips    bool wasAbandoned() const;
3467761d61876ea479dd9672b684fd5c7601932a767robertphillips
34765048139bd26c8edbc6796f220e79b6c848151d7Robert Phillips    void setNeedsStencil() { fRenderTargetProxy->setNeedsStencil(); }
34865048139bd26c8edbc6796f220e79b6c848151d7Robert Phillips
349c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    GrRenderTarget* accessRenderTarget() {
350c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips        // TODO: usage of this entry point needs to be reduced and potentially eliminated
351c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips        // since it ends the deferral of the GrRenderTarget's allocation
3526be756b673b823881e90a2ef68c12b640ddde549Robert Phillips        if (!fRenderTargetProxy->instantiate(fContext->contextPriv().resourceProvider())) {
353eee4d6e4e8cc5c4c79f065abcc3ce609f71238f9Robert Phillips            return nullptr;
354eee4d6e4e8cc5c4c79f065abcc3ce609f71238f9Robert Phillips        }
355eee4d6e4e8cc5c4c79f065abcc3ce609f71238f9Robert Phillips        return fRenderTargetProxy->priv().peekRenderTarget();
356c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    }
3576c7e325236b7fbb9c9b14ebb4715f88a59718695robertphillips
358f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips    GrSurfaceProxy* asSurfaceProxy() override { return fRenderTargetProxy.get(); }
359f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips    const GrSurfaceProxy* asSurfaceProxy() const override { return fRenderTargetProxy.get(); }
360f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips    sk_sp<GrSurfaceProxy> asSurfaceProxyRef() override { return fRenderTargetProxy; }
361f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips
362f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips    GrTextureProxy* asTextureProxy() override;
363e252f08982b0c747cd4d34c00ce413ab1005e99aGreg Daniel    const GrTextureProxy* asTextureProxy() const override;
364f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips    sk_sp<GrTextureProxy> asTextureProxyRef() override;
365f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips
366f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips    GrRenderTargetProxy* asRenderTargetProxy() override { return fRenderTargetProxy.get(); }
367f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips    sk_sp<GrRenderTargetProxy> asRenderTargetProxyRef() override { return fRenderTargetProxy; }
368eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillips
369d46697ac36d5cb3b58571c6129cb5b26fe9d25d7Robert Phillips    GrRenderTargetContext* asRenderTargetContext() override { return this; }
370d46697ac36d5cb3b58571c6129cb5b26fe9d25d7Robert Phillips
371391395dcfbff09a83f8f0e9d3e02d38c855ae2e9robertphillips    // Provides access to functions that aren't part of the public API.
372693a540272a771c6b0830094c461397cb77543b1Brian Osman    GrRenderTargetContextPriv priv();
373693a540272a771c6b0830094c461397cb77543b1Brian Osman    const GrRenderTargetContextPriv priv() const;
374f5883a6d75a18c581507214d3057b5c721ed1ffcjoshualitt
375f18b1d88aa98f81d2c115a59d887265fea63f876Brian Salomon    GrTextUtils::Target* textTarget() { return fTextTarget.get(); }
376f18b1d88aa98f81d2c115a59d887265fea63f876Brian Salomon
377eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillips    bool isWrapped_ForTesting() const;
378eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillips
37996880d9e366d58e5960aa0ee6aa67260797679ebjoshualittprotected:
380c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips    GrRenderTargetContext(GrContext*, GrDrawingManager*, sk_sp<GrRenderTargetProxy>,
3812c86249465c28a532c8be55b6ba497021e3110ecRobert Phillips                          sk_sp<SkColorSpace>, const SkSurfaceProps*, GrAuditTrail*,
382941d1446e0247b3af5d607def3ae87ee66031381Robert Phillips                          GrSingleOwner*, bool managedOpList = true);
383ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
3842de8cfadc34cd92a6f99659fa565c137b386fa5fRobert Phillips    SkDEBUGCODE(void validate() const override;)
385ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
38696880d9e366d58e5960aa0ee6aa67260797679ebjoshualittprivate:
387f18b1d88aa98f81d2c115a59d887265fea63f876Brian Salomon    class TextTarget;
388f18b1d88aa98f81d2c115a59d887265fea63f876Brian Salomon
389ea26d6b81606a52eb2d8e3cb7007ece2c298b53cBrian Salomon    inline GrAAType chooseAAType(GrAA aa, GrAllowMixedSamples allowMixedSamples) {
390ea26d6b81606a52eb2d8e3cb7007ece2c298b53cBrian Salomon        return GrChooseAAType(aa, this->fsaaType(), allowMixedSamples, *this->caps());
3910e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon    }
3920e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon
393649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    friend class GrAtlasTextBlob;               // for access to add[Mesh]DrawOp
3945d034744ab749d37a0b4c889271160236ec8be4eBrian Osman    friend class GrClipStackClip;               // for access to getOpList
39555fdcccf01d49173bc731024b4283d3a3ea9150arobertphillips
39696880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt    friend class GrDrawingManager; // for ctor
3971105224f9701e57ec5ce0354d6a380b664f5c638Brian Osman    friend class GrRenderTargetContextPriv;
39842521e891081a7a85db4390a457074054649f194Brian Salomon
39942521e891081a7a85db4390a457074054649f194Brian Salomon    // All the path renderers currently make their own ops
400649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    friend class GrSoftwarePathRenderer;             // for access to add[Mesh]DrawOp
401649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    friend class GrAAConvexPathRenderer;             // for access to add[Mesh]DrawOp
402649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    friend class GrDashLinePathRenderer;             // for access to add[Mesh]DrawOp
403649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    friend class GrAAHairLinePathRenderer;           // for access to add[Mesh]DrawOp
404649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    friend class GrAALinearizingConvexPathRenderer;  // for access to add[Mesh]DrawOp
405830104632fd79eb5ac5bf8755a1c0271d13acb22Jim Van Verth    friend class GrSmallPathRenderer;                // for access to add[Mesh]DrawOp
406649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    friend class GrDefaultPathRenderer;              // for access to add[Mesh]DrawOp
407649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    friend class GrMSAAPathRenderer;                 // for access to add[Mesh]DrawOp
408649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    friend class GrStencilAndCoverPathRenderer;      // for access to add[Mesh]DrawOp
409649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    friend class GrTessellatingPathRenderer;         // for access to add[Mesh]DrawOp
410383a2ef6edb84dbebc7a9c22ea7423037bbf6a2fChris Dalton    friend class GrCCAtlas;                          // for access to addDrawOp
4111a325d25b941ef801b3e9b2c0342da43cf35cdbaChris Dalton    friend class GrCoverageCountingPathRenderer;     // for access to addDrawOp
4125d4cd9ea8818f65bb4878c050dbdb9dcd48505adBrian Salomon    // for a unit test
413aff329b8e9b239bca1d93b13a914fbef45ccf7feBrian Salomon    friend void test_draw_op(GrRenderTargetContext*, std::unique_ptr<GrFragmentProcessor>,
414aff329b8e9b239bca1d93b13a914fbef45ccf7feBrian Salomon                             sk_sp<GrTextureProxy>);
415ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
416344e9037e1befdee76691a1239a47829e6af4ea5Chris Dalton    void internalClear(const GrFixedClip&, const GrColor, CanClearFullscreen);
41729df76096fd30941086324902a82656df2d8becdcsmartdalton
41882f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon    // Only consumes the GrPaint if successful.
419000958973f4b514cddbfdcc01ec167437b66de2crobertphillips    bool drawFilledDRRect(const GrClip& clip,
42082f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                          GrPaint&& paint,
4210e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                          GrAA,
422000958973f4b514cddbfdcc01ec167437b66de2crobertphillips                          const SkMatrix& viewMatrix,
423000958973f4b514cddbfdcc01ec167437b66de2crobertphillips                          const SkRRect& origOuter,
424000958973f4b514cddbfdcc01ec167437b66de2crobertphillips                          const SkRRect& origInner);
425000958973f4b514cddbfdcc01ec167437b66de2crobertphillips
42682f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon    // Only consumes the GrPaint if successful.
427443023975e335e3630191227dbc21fa72c436af3robertphillips    bool drawFilledRect(const GrClip& clip,
42882f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon                        GrPaint&& paint,
4290e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon                        GrAA,
430443023975e335e3630191227dbc21fa72c436af3robertphillips                        const SkMatrix& viewMatrix,
431443023975e335e3630191227dbc21fa72c436af3robertphillips                        const SkRect& rect,
432443023975e335e3630191227dbc21fa72c436af3robertphillips                        const GrUserStencilSettings* ss);
433443023975e335e3630191227dbc21fa72c436af3robertphillips
4342fad74a0fdc5eb3f505a052849c3cbeffa6e2d17Brian Salomon    void drawShapeUsingPathRenderer(const GrClip&, GrPaint&&, GrAA, const SkMatrix&,
4352fad74a0fdc5eb3f505a052849c3cbeffa6e2d17Brian Salomon                                    const GrShape&);
436ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
437649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    // These perform processing specific to Gr[Mesh]DrawOp-derived ops before recording them into
438649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon    // the op list. They return the id of the opList to which the op was added, or 0, if it was
439c01389271162d08303088732c30f419807f25d33Robert Phillips    // dropped (e.g., due to clipping).
44054d212e1bfaea0be88c3c40820d0b1ae0daebecfBrian Salomon    uint32_t addDrawOp(const GrClip&, std::unique_ptr<GrDrawOp>);
4412334fb655f8d4ef5915770d32bf845c88d3627f4robertphillips
442bf25d433f48bb336f1f7f8bcb0a4a357ac08bb16Robert Phillips    // Makes a copy of the proxy if it is necessary for the draw and places the texture that should
443bf25d433f48bb336f1f7f8bcb0a4a357ac08bb16Robert Phillips    // be used by GrXferProcessor to access the destination color in 'result'. If the return
444bf25d433f48bb336f1f7f8bcb0a4a357ac08bb16Robert Phillips    // value is false then a texture copy could not be made.
445bb581ce30f55360fd3a12e7f5aa1fe324b16d085Robert Phillips    bool SK_WARN_UNUSED_RESULT setupDstProxy(GrRenderTargetProxy*,
446bb581ce30f55360fd3a12e7f5aa1fe324b16d085Robert Phillips                                             const GrClip&,
447bb581ce30f55360fd3a12e7f5aa1fe324b16d085Robert Phillips                                             const SkRect& opBounds,
448bb581ce30f55360fd3a12e7f5aa1fe324b16d085Robert Phillips                                             GrXferProcessor::DstProxy* result);
449467921e5e6479fe9cebba125657d8e33d89004aeBrian Salomon
4502de8cfadc34cd92a6f99659fa565c137b386fa5fRobert Phillips    GrRenderTargetOpList* getRTOpList();
4512de8cfadc34cd92a6f99659fa565c137b386fa5fRobert Phillips    GrOpList* getOpList() override;
452a106c627532ad669cf7d879955ae8ea6a53233c1robertphillips
453f18b1d88aa98f81d2c115a59d887265fea63f876Brian Salomon    std::unique_ptr<GrTextUtils::Target> fTextTarget;
454f18b1d88aa98f81d2c115a59d887265fea63f876Brian Salomon    sk_sp<GrRenderTargetProxy> fRenderTargetProxy;
455a106c627532ad669cf7d879955ae8ea6a53233c1robertphillips
4561105224f9701e57ec5ce0354d6a380b664f5c638Brian Osman    // In MDB-mode the GrOpList can be closed by some other renderTargetContext that has picked
457f2361d2d93c200cd4555b5e8ecea4531801abaaaRobert Phillips    // it up. For this reason, the GrOpList should only ever be accessed via 'getOpList'.
458f18b1d88aa98f81d2c115a59d887265fea63f876Brian Salomon    sk_sp<GrRenderTargetOpList> fOpList;
4592334fb655f8d4ef5915770d32bf845c88d3627f4robertphillips
460f18b1d88aa98f81d2c115a59d887265fea63f876Brian Salomon    SkSurfaceProps fSurfaceProps;
461f18b1d88aa98f81d2c115a59d887265fea63f876Brian Salomon    bool fManagedOpList;
462e305cc1f2a44e47d6a0dcc0ff34e2692349aed5dRobert Phillips
463e305cc1f2a44e47d6a0dcc0ff34e2692349aed5dRobert Phillips    typedef GrSurfaceContext INHERITED;
464ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips};
465ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips
466ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips#endif
467