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; 25c48af934608bbb65650641f66adb51f2102d4274Brian Salomonclass GrMeshDrawOp; 2654d212e1bfaea0be88c3c40820d0b1ae0daebecfBrian Salomonclass GrPipelineBuilder; 27ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass GrRenderTarget; 2845580d3e3024c1536e8e1b2017b704805442b634Brian Osmanclass GrRenderTargetContextPriv; 29f2361d2d93c200cd4555b5e8ecea4531801abaaaRobert Phillipsclass GrRenderTargetOpList; 306663acff010ce752e4bf778da81fa97448c9db31bsalomonclass GrStyle; 31ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass GrSurface; 32eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillipsclass GrTextureProxy; 33443023975e335e3630191227dbc21fa72c436af3robertphillipsstruct GrUserStencilSettings; 342334fb655f8d4ef5915770d32bf845c88d3627f4robertphillipsclass SkDrawFilter; 35ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsstruct SkIPoint; 36ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsstruct SkIRect; 3710e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarettclass SkLatticeIter; 38ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass SkMatrix; 392334fb655f8d4ef5915770d32bf845c88d3627f4robertphillipsclass SkPaint; 40ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass SkPath; 41ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsstruct SkPoint; 42ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsstruct SkRect; 4345580d3e3024c1536e8e1b2017b704805442b634Brian Osmanclass SkRegion; 44ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass SkRRect; 4531ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverthstruct SkRSXform; 462334fb655f8d4ef5915770d32bf845c88d3627f4robertphillipsclass SkTextBlob; 47199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomonclass SkVertices; 48ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 4945580d3e3024c1536e8e1b2017b704805442b634Brian Osman/** 5045580d3e3024c1536e8e1b2017b704805442b634Brian Osman * A helper object to orchestrate commands (draws, etc...) for GrSurfaces that are GrRenderTargets. 51ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 5245580d3e3024c1536e8e1b2017b704805442b634Brian Osmanclass SK_API GrRenderTargetContext : public GrSurfaceContext { 53ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipspublic: 541105224f9701e57ec5ce0354d6a380b664f5c638Brian Osman ~GrRenderTargetContext() override; 552334fb655f8d4ef5915770d32bf845c88d3627f4robertphillips 5626c90e04797e15c37ec00e0f836292b8a207d294Robert Phillips GrResourceProvider* resourceProvider() { return fContext->resourceProvider(); } 5726c90e04797e15c37ec00e0f836292b8a207d294Robert Phillips 586f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon // We use SkPaint rather than GrPaint here for two reasons: 596f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon // * The SkPaint carries extra text settings. If these were extracted to a lighter object 606f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon // we could use GrPaint except that 616f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon // * SkPaint->GrPaint conversion depends upon whether the glyphs are color or grayscale and 626f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon // this can vary within a text run. 636f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon virtual void drawText(const GrClip&, const SkPaint&, const SkMatrix& viewMatrix, 6482f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon const char text[], size_t byteLength, SkScalar x, SkScalar y, 6582f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon const SkIRect& clipBounds); 666f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon virtual void drawPosText(const GrClip&, const SkPaint&, const SkMatrix& viewMatrix, 6782f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon const char text[], size_t byteLength, const SkScalar pos[], 6882f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon int scalarsPerPosition, const SkPoint& offset, 6982f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon const SkIRect& clipBounds); 7096880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt virtual void drawTextBlob(const GrClip&, const SkPaint&, 7196880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt const SkMatrix& viewMatrix, const SkTextBlob*, 7296880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt SkScalar x, SkScalar y, 7396880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt SkDrawFilter*, const SkIRect& clipBounds); 74ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 75ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 76ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * Provides a perfomance hint that the render target's contents are allowed 77ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * to become undefined. 78ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 792e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void discard(); 80ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 81ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 82ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * Clear the entire or rect of the render target, ignoring any clips. 83ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param rect the rect to clear or the whole thing if rect is NULL. 84ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param color the color to clear to. 85ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param canIgnoreRect allows partial clears to be converted to whole 86ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * clears on platforms for which that is cheap 87ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 882e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void clear(const SkIRect* rect, GrColor color, bool canIgnoreRect); 89ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 90ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 91ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * Draw everywhere (respecting the clip) with the paint. 92ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 9382f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon void drawPaint(const GrClip&, GrPaint&&, const SkMatrix& viewMatrix); 94ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 95ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 960e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * Draw the rect using a paint. 970e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param paint describes how to color pixels. 980e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param GrAA Controls whether rect is antialiased 990e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param viewMatrix transformation matrix 1000e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param style The style to apply. Null means fill. Currently path effects are not 1010e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * allowed. 1020e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * The rects coords are used to access the paint (through texture matrix) 103ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 1042e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void drawRect(const GrClip&, 10582f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&& paint, 1060e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon GrAA, 107ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkMatrix& viewMatrix, 108ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkRect&, 10982f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon const GrStyle* style = nullptr); 110ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 111ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 112a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon * Maps a rectangle of shader coordinates to a rectangle and fills that rectangle. 113ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * 1140e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param paint describes how to color pixels. 1150e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param GrAA Controls whether rect is antialiased 1160e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param viewMatrix transformation matrix which applies to rectToDraw 1170e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param rectToDraw the rectangle to draw 1180e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param localRect the rectangle of shader coordinates applied to rectToDraw 119ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 120a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon void fillRectToRect(const GrClip&, 12182f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&& paint, 1220e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon GrAA, 123a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon const SkMatrix& viewMatrix, 124a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon const SkRect& rectToDraw, 125a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon const SkRect& localRect); 126ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 127ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 128a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon * Fills a rect with a paint and a localMatrix. 129ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 130a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon void fillRectWithLocalMatrix(const GrClip& clip, 13182f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&& paint, 1320e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon GrAA, 133a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon const SkMatrix& viewMatrix, 134a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon const SkRect& rect, 135a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon const SkMatrix& localMatrix); 136ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 137ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 1380e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * Draw a roundrect using a paint. 139ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * 1400e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param paint describes how to color pixels. 1410e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param GrAA Controls whether rrect is antialiased. 1420e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param viewMatrix transformation matrix 1430e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param rrect the roundrect to draw 1440e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param style style to apply to the rrect. Currently path effects are not allowed. 145ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 1462e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void drawRRect(const GrClip&, 14782f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&&, 1480e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon GrAA, 149ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkMatrix& viewMatrix, 150ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkRRect& rrect, 1516663acff010ce752e4bf778da81fa97448c9db31bsalomon const GrStyle& style); 152ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 153ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 1540e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * Draw a roundrect using a paint and a shadow shader. This is separate from drawRRect 1550e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * because it uses different underlying geometry and GeometryProcessor 156c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth * 1570e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param paint describes how to color pixels. 1580e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param viewMatrix transformation matrix 1590e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param rrect the roundrect to draw 1600e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param blurRadius amount of shadow blur to apply (in device space) 1610e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param style style to apply to the rrect. Currently path effects are not allowed. 162c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth */ 163c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth void drawShadowRRect(const GrClip&, 16482f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&&, 165c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth const SkMatrix& viewMatrix, 166c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth const SkRRect& rrect, 167c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth SkScalar blurRadius, 168c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth const GrStyle& style); 169c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth 170c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth /** 1710e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * Shortcut for filling a SkPath consisting of nested rrects using a paint. The result is 1720e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * undefined if outer does not contain inner. 173000958973f4b514cddbfdcc01ec167437b66de2crobertphillips * 1740e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param paint describes how to color pixels. 1750e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param GrAA Controls whether rrects edges are antialiased 1760e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param viewMatrix transformation matrix 1770e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param outer the outer roundrect 1780e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param inner the inner roundrect 179000958973f4b514cddbfdcc01ec167437b66de2crobertphillips */ 180000958973f4b514cddbfdcc01ec167437b66de2crobertphillips void drawDRRect(const GrClip&, 18182f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&&, 1820e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon GrAA, 183000958973f4b514cddbfdcc01ec167437b66de2crobertphillips const SkMatrix& viewMatrix, 184000958973f4b514cddbfdcc01ec167437b66de2crobertphillips const SkRRect& outer, 185000958973f4b514cddbfdcc01ec167437b66de2crobertphillips const SkRRect& inner); 186000958973f4b514cddbfdcc01ec167437b66de2crobertphillips 187000958973f4b514cddbfdcc01ec167437b66de2crobertphillips /** 188ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * Draws a path. 189ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * 190ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param paint describes how to color pixels. 1910e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param GrAA Controls whether the path is antialiased. 192ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param viewMatrix transformation matrix 193ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param path the path to draw 1946663acff010ce752e4bf778da81fa97448c9db31bsalomon * @param style style to apply to the path. 195ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 1962e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void drawPath(const GrClip&, 19782f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&&, 1980e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon GrAA, 199ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkMatrix& viewMatrix, 200ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkPath&, 2016663acff010ce752e4bf778da81fa97448c9db31bsalomon const GrStyle& style); 202ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 2033de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon enum class ColorArrayType { 2043de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon kPremulGrColor, 2053de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon kSkColor, 2063de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon }; 207ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 208ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * Draws vertices with a paint. 209ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * 210ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param paint describes how to color pixels. 211ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param viewMatrix transformation matrix 212ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param primitiveType primitives type to draw. 213ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param vertexCount number of vertices. 214ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param positions array of vertex positions, required. 215ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param texCoords optional array of texture coordinates used 216ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * to access the paint. 217ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param colors optional array of per-vertex colors, supercedes 218ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * the paint's color field. 219ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param indices optional array of indices. If NULL vertices 220ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * are drawn non-indexed. 221ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param indexCount if indices is non-null then this is the 222ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * number of indices. 2233de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon * @param ColorArrayType Determines how the color array should be interpreted. 224ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 2252e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void drawVertices(const GrClip&, 22682f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&& paint, 227ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkMatrix& viewMatrix, 228ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips GrPrimitiveType primitiveType, 229ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips int vertexCount, 230ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkPoint positions[], 231ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkPoint texs[], 2323de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon const uint32_t colors[], 233ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const uint16_t indices[], 2343de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon int indexCount, 2353de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon ColorArrayType = ColorArrayType::kPremulGrColor); 236ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 237ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 238199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon * Draws vertices with a paint. 239199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon * 240199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon * @param paint describes how to color pixels. 241199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon * @param viewMatrix transformation matrix 242199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon * @param veritces specifies the mesh to draw. 243199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon * @param flags A bitfield of options specified by SkCanvas::VerticesFlags. 244199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon */ 245199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon void drawVertices(const GrClip&, 246199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon GrPaint&& paint, 247199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon const SkMatrix& viewMatrix, 2485fa6645dbe4f56a51ce0f59c13c99afb12ff3f5cMike Reed sk_sp<SkVertices> vertices); 249199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon 250199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon /** 2510e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * Draws textured sprites from an atlas with a paint. This currently does not support AA for the 2520e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * sprite rectangle edges. 25331ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * 25431ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * @param paint describes how to color pixels. 25531ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * @param viewMatrix transformation matrix 25631ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * @param spriteCount number of sprites. 25731ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * @param xform array of compressed transformation data, required. 25831ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * @param texRect array of texture rectangles used to access the paint. 25931ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * @param colors optional array of per-sprite colors, supercedes 26031ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * the paint's color field. 26131ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth */ 2622e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void drawAtlas(const GrClip&, 26382f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&& paint, 26431ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth const SkMatrix& viewMatrix, 26531ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth int spriteCount, 26631ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth const SkRSXform xform[], 26731ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth const SkRect texRect[], 26831ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth const SkColor colors[]); 269cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett 270cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett /** 271cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett * Draws a region. 272cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett * 273cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett * @param paint describes how to color pixels 274cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett * @param viewMatrix transformation matrix 2750e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param aa should the rects of the region be antialiased. 276cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett * @param region the region to be drawn 277cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett * @param style style to apply to the region 278cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett */ 279cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett void drawRegion(const GrClip&, 28082f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&& paint, 2810e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon GrAA aa, 282cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett const SkMatrix& viewMatrix, 283cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett const SkRegion& region, 284cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett const GrStyle& style); 285cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett 28631ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth /** 287ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * Draws an oval. 288ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * 289ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param paint describes how to color pixels. 2900e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param GrAA Controls whether the oval is antialiased. 291ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param viewMatrix transformation matrix 292ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param oval the bounding rect of the oval. 2936663acff010ce752e4bf778da81fa97448c9db31bsalomon * @param style style to apply to the oval. Currently path effects are not allowed. 294ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 2952e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void drawOval(const GrClip&, 29682f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&& paint, 2970e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon GrAA, 298ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkMatrix& viewMatrix, 299ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkRect& oval, 3006663acff010ce752e4bf778da81fa97448c9db31bsalomon const GrStyle& style); 3010e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon /** 3020e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * Draws a partial arc of an oval. 3030e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * 3040e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param paint describes how to color pixels. 3059950408c5f20148d5b726421454db718860077deBrian Salomon * @param GrGrAA Controls whether the arc is antialiased. 3060e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param viewMatrix transformation matrix. 3070e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param oval the bounding rect of the oval. 3080e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param startAngle starting angle in degrees. 3090e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param sweepAngle angle to sweep in degrees. Must be in (-360, 360) 3100e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param useCenter true means that the implied path begins at the oval center, connects as 3110e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * a line to the point indicated by the start contains the arc indicated by 3120e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * the sweep angle. If false the line beginning at the center point is 3130e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * omitted. 3140e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param style style to apply to the oval. 3150e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon */ 3164f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon void drawArc(const GrClip&, 31782f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&& paint, 3180e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon GrAA, 3194f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon const SkMatrix& viewMatrix, 3204f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon const SkRect& oval, 3214f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon SkScalar startAngle, 3224f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon SkScalar sweepAngle, 3234f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon bool useCenter, 3244f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon const GrStyle& style); 325ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 32633a5fce6126dc5d3927a71fdc6c35af6f5893fd5joshualitt /** 3274f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon * Draw the image as a set of rects, specified by |iter|. 32833a5fce6126dc5d3927a71fdc6c35af6f5893fd5joshualitt */ 32910e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett void drawImageLattice(const GrClip&, 33082f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&& paint, 33110e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett const SkMatrix& viewMatrix, 33210e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett int imageWidth, 33310e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett int imageHeight, 33410e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett std::unique_ptr<SkLatticeIter> iter, 33510e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett const SkRect& dst); 336ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 3378c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips /** 3388c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips * After this returns any pending surface IO will be issued to the backend 3D API and 3398c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips * if the surface has MSAA it will be resolved. 3408c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips */ 3418c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips void prepareForExternalIO(); 3428c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips 343976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips bool isStencilBufferMultisampled() const { 344c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips return fRenderTargetProxy->isStencilBufferMultisampled(); 345976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips } 346c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips bool isUnifiedMultisampled() const { return fRenderTargetProxy->isUnifiedMultisampled(); } 347c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips bool hasMixedSamples() const { return fRenderTargetProxy->isMixedSampled(); } 34882ec6e59b8b694c128adcf8590667d37327dd1c4robertphillips 349faf8203ea7588dcdca82f69f5a5447b3eb53a849bsalomon const GrCaps* caps() const { return fContext->caps(); } 350c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips const GrSurfaceDesc& desc() const { return fRenderTargetProxy->desc(); } 351c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips int width() const { return fRenderTargetProxy->width(); } 352c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips int height() const { return fRenderTargetProxy->height(); } 353c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips GrPixelConfig config() const { return fRenderTargetProxy->config(); } 354c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips int numColorSamples() const { return fRenderTargetProxy->numColorSamples(); } 355ca6eafc0f7e59ed89f03a9891b9fdf7de64f1f35robertphillips const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; } 356c71a9b7f53938b4f33f36f48e867b8b72cc1cc61msarett GrColorSpaceXform* getColorXformFromSRGB() const { return fColorXformFromSRGB.get(); } 357c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips GrSurfaceOrigin origin() const { return fRenderTargetProxy->origin(); } 3587bceedc550513b13e0065aca66e55204a2ba3e1frobertphillips 3597761d61876ea479dd9672b684fd5c7601932a767robertphillips bool wasAbandoned() const; 3607761d61876ea479dd9672b684fd5c7601932a767robertphillips 361eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillips GrRenderTarget* instantiate(); 362eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillips 363c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips GrRenderTarget* accessRenderTarget() { 364c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips // TODO: usage of this entry point needs to be reduced and potentially eliminated 365c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips // since it ends the deferral of the GrRenderTarget's allocation 36632342f032e1dfd133040324f851f0365f9d4cb51Brian Osman return fRenderTargetProxy->instantiate(fContext->resourceProvider()); 367c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips } 3686c7e325236b7fbb9c9b14ebb4715f88a59718695robertphillips 369f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips GrSurfaceProxy* asSurfaceProxy() override { return fRenderTargetProxy.get(); } 370f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips const GrSurfaceProxy* asSurfaceProxy() const override { return fRenderTargetProxy.get(); } 371f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips sk_sp<GrSurfaceProxy> asSurfaceProxyRef() override { return fRenderTargetProxy; } 372f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips 373f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips GrTextureProxy* asTextureProxy() override; 374f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips sk_sp<GrTextureProxy> asTextureProxyRef() override; 375f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips 376f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips GrRenderTargetProxy* asRenderTargetProxy() override { return fRenderTargetProxy.get(); } 377f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips sk_sp<GrRenderTargetProxy> asRenderTargetProxyRef() override { return fRenderTargetProxy; } 378eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillips 379d46697ac36d5cb3b58571c6129cb5b26fe9d25d7Robert Phillips GrRenderTargetContext* asRenderTargetContext() override { return this; } 380d46697ac36d5cb3b58571c6129cb5b26fe9d25d7Robert Phillips 381c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips sk_sp<GrTexture> asTexture() { 382e60ad620fe236ce4c1e85a31bd53ed0c848da8c3Robert Phillips if (!this->accessRenderTarget()) { 383e60ad620fe236ce4c1e85a31bd53ed0c848da8c3Robert Phillips return nullptr; 384e60ad620fe236ce4c1e85a31bd53ed0c848da8c3Robert Phillips } 385e60ad620fe236ce4c1e85a31bd53ed0c848da8c3Robert Phillips 386c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips // TODO: usage of this entry point needs to be reduced and potentially eliminated 387c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips // since it ends the deferral of the GrRenderTarget's allocation 388f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips // It's usage should migrate to asTextureProxyRef 389c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips return sk_ref_sp(this->accessRenderTarget()->asTexture()); 390c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips } 391433625e67c61c3acce4fd95b3881493c9f4f2c7frobertphillips 392391395dcfbff09a83f8f0e9d3e02d38c855ae2e9robertphillips // Provides access to functions that aren't part of the public API. 393693a540272a771c6b0830094c461397cb77543b1Brian Osman GrRenderTargetContextPriv priv(); 394693a540272a771c6b0830094c461397cb77543b1Brian Osman const GrRenderTargetContextPriv priv() const; 395f5883a6d75a18c581507214d3057b5c721ed1ffcjoshualitt 396eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillips bool isWrapped_ForTesting() const; 397eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillips 39896880d9e366d58e5960aa0ee6aa67260797679ebjoshualittprotected: 399c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips GrRenderTargetContext(GrContext*, GrDrawingManager*, sk_sp<GrRenderTargetProxy>, 4002c86249465c28a532c8be55b6ba497021e3110ecRobert Phillips sk_sp<SkColorSpace>, const SkSurfaceProps*, GrAuditTrail*, 401c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips GrSingleOwner*); 402ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 4032e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips SkDEBUGCODE(void validate() const;) 404ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 40596880d9e366d58e5960aa0ee6aa67260797679ebjoshualittprivate: 4060e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon inline GrAAType decideAAType(GrAA aa, bool allowMixedSamples = false) { 4070e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon if (GrAA::kNo == aa) { 4080e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon return GrAAType::kNone; 4090e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon } 4100e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon if (this->isUnifiedMultisampled()) { 4110e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon return GrAAType::kMSAA; 4120e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon } 4130e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon if (allowMixedSamples && this->isStencilBufferMultisampled()) { 4140e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon return GrAAType::kMixedSamples; 4150e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon } 4160e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon return GrAAType::kCoverage; 4170e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon } 4180e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon 419649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon friend class GrAtlasTextBlob; // for access to add[Mesh]DrawOp 420649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon friend class GrStencilAndCoverTextContext; // for access to add[Mesh]DrawOp 42155fdcccf01d49173bc731024b4283d3a3ea9150arobertphillips 42296880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt friend class GrDrawingManager; // for ctor 4231105224f9701e57ec5ce0354d6a380b664f5c638Brian Osman friend class GrRenderTargetContextPriv; 424649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon friend class GrSWMaskHelper; // for access to add[Mesh]DrawOp 42542521e891081a7a85db4390a457074054649f194Brian Salomon 42642521e891081a7a85db4390a457074054649f194Brian Salomon // All the path renderers currently make their own ops 427649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon friend class GrSoftwarePathRenderer; // for access to add[Mesh]DrawOp 428649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon friend class GrAAConvexPathRenderer; // for access to add[Mesh]DrawOp 429649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon friend class GrDashLinePathRenderer; // for access to add[Mesh]DrawOp 430649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon friend class GrAAHairLinePathRenderer; // for access to add[Mesh]DrawOp 431649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon friend class GrAALinearizingConvexPathRenderer; // for access to add[Mesh]DrawOp 432830104632fd79eb5ac5bf8755a1c0271d13acb22Jim Van Verth friend class GrSmallPathRenderer; // for access to add[Mesh]DrawOp 433649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon friend class GrDefaultPathRenderer; // for access to add[Mesh]DrawOp 434649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon friend class GrMSAAPathRenderer; // for access to add[Mesh]DrawOp 435649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon friend class GrStencilAndCoverPathRenderer; // for access to add[Mesh]DrawOp 436649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon friend class GrTessellatingPathRenderer; // for access to add[Mesh]DrawOp 4375d4cd9ea8818f65bb4878c050dbdb9dcd48505adBrian Salomon // for a unit test 438296b1ccf9b8e9c8b945645efcbaa9c71c7135f58Robert Phillips friend void test_draw_op(GrRenderTargetContext*, 43930f9bc69cfc506075e1fce8e7934f941c0203023Robert Phillips sk_sp<GrFragmentProcessor>, sk_sp<GrTextureProxy>); 440ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 44129df76096fd30941086324902a82656df2d8becdcsmartdalton void internalClear(const GrFixedClip&, const GrColor, bool canIgnoreClip); 44229df76096fd30941086324902a82656df2d8becdcsmartdalton 44382f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon // Only consumes the GrPaint if successful. 444000958973f4b514cddbfdcc01ec167437b66de2crobertphillips bool drawFilledDRRect(const GrClip& clip, 44582f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&& paint, 4460e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon GrAA, 447000958973f4b514cddbfdcc01ec167437b66de2crobertphillips const SkMatrix& viewMatrix, 448000958973f4b514cddbfdcc01ec167437b66de2crobertphillips const SkRRect& origOuter, 449000958973f4b514cddbfdcc01ec167437b66de2crobertphillips const SkRRect& origInner); 450000958973f4b514cddbfdcc01ec167437b66de2crobertphillips 45182f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon // Only consumes the GrPaint if successful. 452443023975e335e3630191227dbc21fa72c436af3robertphillips bool drawFilledRect(const GrClip& clip, 45382f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&& paint, 4540e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon GrAA, 455443023975e335e3630191227dbc21fa72c436af3robertphillips const SkMatrix& viewMatrix, 456443023975e335e3630191227dbc21fa72c436af3robertphillips const SkRect& rect, 457443023975e335e3630191227dbc21fa72c436af3robertphillips const GrUserStencilSettings* ss); 458443023975e335e3630191227dbc21fa72c436af3robertphillips 459443023975e335e3630191227dbc21fa72c436af3robertphillips void drawNonAAFilledRect(const GrClip&, 46082f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&&, 461443023975e335e3630191227dbc21fa72c436af3robertphillips const SkMatrix& viewMatrix, 462443023975e335e3630191227dbc21fa72c436af3robertphillips const SkRect& rect, 463443023975e335e3630191227dbc21fa72c436af3robertphillips const SkRect* localRect, 464443023975e335e3630191227dbc21fa72c436af3robertphillips const SkMatrix* localMatrix, 46534ee0c950e1aa24818632084acdb382514f98c08csmartdalton const GrUserStencilSettings* ss, 4660e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon GrAAType hwOrNoneAAType); 4670e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon 46882f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon void internalDrawPath( 46982f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon const GrClip&, GrPaint&&, GrAA, const SkMatrix&, const SkPath&, const GrStyle&); 470ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 471e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips bool onCopy(GrSurfaceProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint) override; 4722c86249465c28a532c8be55b6ba497021e3110ecRobert Phillips bool onReadPixels(const SkImageInfo& dstInfo, void* dstBuffer, 473b726d58efc91c4eefa5cea0881a823ee108db8fdRobert Phillips size_t dstRowBytes, int x, int y, uint32_t flags) override; 4742c86249465c28a532c8be55b6ba497021e3110ecRobert Phillips bool onWritePixels(const SkImageInfo& srcInfo, const void* srcBuffer, 47530f9bc69cfc506075e1fce8e7934f941c0203023Robert Phillips size_t srcRowBytes, int x, int y, uint32_t flags) override; 476e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips 477649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon // These perform processing specific to Gr[Mesh]DrawOp-derived ops before recording them into 478649a3411f99a8aea3c46e4ef1f495f61b9801164Brian Salomon // the op list. They return the id of the opList to which the op was added, or 0, if it was 479c01389271162d08303088732c30f419807f25d33Robert Phillips // dropped (e.g., due to clipping). 48054d212e1bfaea0be88c3c40820d0b1ae0daebecfBrian Salomon uint32_t addDrawOp(const GrClip&, std::unique_ptr<GrDrawOp>); 48154d212e1bfaea0be88c3c40820d0b1ae0daebecfBrian Salomon uint32_t addMeshDrawOp(const GrPipelineBuilder&, const GrClip&, std::unique_ptr<GrMeshDrawOp>); 4822334fb655f8d4ef5915770d32bf845c88d3627f4robertphillips 483467921e5e6479fe9cebba125657d8e33d89004aeBrian Salomon // Makes a copy of the dst if it is necessary for the draw and returns the texture that should 484467921e5e6479fe9cebba125657d8e33d89004aeBrian Salomon // be used by GrXferProcessor to access the destination color. If the texture is nullptr then 485467921e5e6479fe9cebba125657d8e33d89004aeBrian Salomon // a texture copy could not be made. 486467921e5e6479fe9cebba125657d8e33d89004aeBrian Salomon void setupDstTexture(GrRenderTarget*, const GrClip&, const SkRect& opBounds, 487467921e5e6479fe9cebba125657d8e33d89004aeBrian Salomon GrXferProcessor::DstTexture*); 488467921e5e6479fe9cebba125657d8e33d89004aeBrian Salomon 489467921e5e6479fe9cebba125657d8e33d89004aeBrian Salomon 490f2361d2d93c200cd4555b5e8ecea4531801abaaaRobert Phillips GrRenderTargetOpList* getOpList(); 491a106c627532ad669cf7d879955ae8ea6a53233c1robertphillips 492c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips sk_sp<GrRenderTargetProxy> fRenderTargetProxy; 493a106c627532ad669cf7d879955ae8ea6a53233c1robertphillips 4941105224f9701e57ec5ce0354d6a380b664f5c638Brian Osman // In MDB-mode the GrOpList can be closed by some other renderTargetContext that has picked 495f2361d2d93c200cd4555b5e8ecea4531801abaaaRobert Phillips // it up. For this reason, the GrOpList should only ever be accessed via 'getOpList'. 496f2361d2d93c200cd4555b5e8ecea4531801abaaaRobert Phillips GrRenderTargetOpList* fOpList; 497c71a9b7f53938b4f33f36f48e867b8b72cc1cc61msarett GrInstancedPipelineInfo fInstancedPipelineInfo; 4982334fb655f8d4ef5915770d32bf845c88d3627f4robertphillips 499c71a9b7f53938b4f33f36f48e867b8b72cc1cc61msarett sk_sp<GrColorSpaceXform> fColorXformFromSRGB; 500c71a9b7f53938b4f33f36f48e867b8b72cc1cc61msarett SkSurfaceProps fSurfaceProps; 501e305cc1f2a44e47d6a0dcc0ff34e2692349aed5dRobert Phillips 502e305cc1f2a44e47d6a0dcc0ff34e2692349aed5dRobert Phillips typedef GrSurfaceContext INHERITED; 503ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips}; 504ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 505ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips#endif 506