GrRenderTargetContext.h revision 5d4cd9ea8818f65bb4878c050dbdb9dcd48505ad
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" 15ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips#include "SkRefCnt.h" 16fcf7829b67b798aff4c41c4688daa9c7381991e6robertphillips#include "SkSurfaceProps.h" 17a7f29640f6ab4eb50962a9d9f12d01ac2ce8b471csmartdalton#include "../private/GrInstancedPipelineInfo.h" 18c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips#include "../private/GrRenderTargetProxy.h" 19ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 20ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass GrClip; 2177a2e52c7d5c77de73ecab5fec79072ee4460706robertphillipsclass GrDrawingManager; 229afd371a8a66f992f98eb2a3fc75ae64bddc730bBrian Salomonclass GrDrawOp; 2329df76096fd30941086324902a82656df2d8becdcsmartdaltonclass GrFixedClip; 24ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass GrPipelineBuilder; 25ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass GrRenderTarget; 2645580d3e3024c1536e8e1b2017b704805442b634Brian Osmanclass GrRenderTargetContextPriv; 27f2361d2d93c200cd4555b5e8ecea4531801abaaaRobert Phillipsclass GrRenderTargetOpList; 286663acff010ce752e4bf778da81fa97448c9db31bsalomonclass GrStyle; 29ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass GrSurface; 30eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillipsclass GrTextureProxy; 31443023975e335e3630191227dbc21fa72c436af3robertphillipsstruct GrUserStencilSettings; 322334fb655f8d4ef5915770d32bf845c88d3627f4robertphillipsclass SkDrawFilter; 33ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsstruct SkIPoint; 34ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsstruct SkIRect; 3510e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarettclass SkLatticeIter; 36ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass SkMatrix; 372334fb655f8d4ef5915770d32bf845c88d3627f4robertphillipsclass SkPaint; 38ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass SkPath; 39ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsstruct SkPoint; 40ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsstruct SkRect; 4145580d3e3024c1536e8e1b2017b704805442b634Brian Osmanclass SkRegion; 42ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass SkRRect; 4331ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverthstruct SkRSXform; 442334fb655f8d4ef5915770d32bf845c88d3627f4robertphillipsclass SkTextBlob; 45199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomonclass SkVertices; 46ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 4745580d3e3024c1536e8e1b2017b704805442b634Brian Osman/** 4845580d3e3024c1536e8e1b2017b704805442b634Brian Osman * A helper object to orchestrate commands (draws, etc...) for GrSurfaces that are GrRenderTargets. 49ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 5045580d3e3024c1536e8e1b2017b704805442b634Brian Osmanclass SK_API GrRenderTargetContext : public GrSurfaceContext { 51ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipspublic: 521105224f9701e57ec5ce0354d6a380b664f5c638Brian Osman ~GrRenderTargetContext() override; 532334fb655f8d4ef5915770d32bf845c88d3627f4robertphillips 546f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon // We use SkPaint rather than GrPaint here for two reasons: 556f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon // * The SkPaint carries extra text settings. If these were extracted to a lighter object 566f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon // we could use GrPaint except that 576f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon // * SkPaint->GrPaint conversion depends upon whether the glyphs are color or grayscale and 586f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon // this can vary within a text run. 596f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon virtual void drawText(const GrClip&, const SkPaint&, const SkMatrix& viewMatrix, 6082f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon const char text[], size_t byteLength, SkScalar x, SkScalar y, 6182f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon const SkIRect& clipBounds); 626f1d36cc54dc635f5e4d0f925ef79c14914342bbBrian Salomon virtual void drawPosText(const GrClip&, const SkPaint&, const SkMatrix& viewMatrix, 6382f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon const char text[], size_t byteLength, const SkScalar pos[], 6482f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon int scalarsPerPosition, const SkPoint& offset, 6582f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon const SkIRect& clipBounds); 6696880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt virtual void drawTextBlob(const GrClip&, const SkPaint&, 6796880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt const SkMatrix& viewMatrix, const SkTextBlob*, 6896880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt SkScalar x, SkScalar y, 6996880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt SkDrawFilter*, const SkIRect& clipBounds); 70ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 71ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 72ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * Provides a perfomance hint that the render target's contents are allowed 73ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * to become undefined. 74ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 752e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void discard(); 76ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 77ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 78ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * Clear the entire or rect of the render target, ignoring any clips. 79ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param rect the rect to clear or the whole thing if rect is NULL. 80ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param color the color to clear to. 81ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param canIgnoreRect allows partial clears to be converted to whole 82ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * clears on platforms for which that is cheap 83ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 842e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void clear(const SkIRect* rect, GrColor color, bool canIgnoreRect); 85ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 86ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 87ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * Draw everywhere (respecting the clip) with the paint. 88ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 8982f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon void drawPaint(const GrClip&, GrPaint&&, const SkMatrix& viewMatrix); 90ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 91ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 920e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * Draw the rect using a paint. 930e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param paint describes how to color pixels. 940e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param GrAA Controls whether rect is antialiased 950e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param viewMatrix transformation matrix 960e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param style The style to apply. Null means fill. Currently path effects are not 970e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * allowed. 980e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * The rects coords are used to access the paint (through texture matrix) 99ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 1002e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void drawRect(const GrClip&, 10182f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&& paint, 1020e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon GrAA, 103ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkMatrix& viewMatrix, 104ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkRect&, 10582f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon const GrStyle* style = nullptr); 106ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 107ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 108a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon * Maps a rectangle of shader coordinates to a rectangle and fills that rectangle. 109ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * 1100e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param paint describes how to color pixels. 1110e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param GrAA Controls whether rect is antialiased 1120e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param viewMatrix transformation matrix which applies to rectToDraw 1130e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param rectToDraw the rectangle to draw 1140e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param localRect the rectangle of shader coordinates applied to rectToDraw 115ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 116a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon void fillRectToRect(const GrClip&, 11782f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&& paint, 1180e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon GrAA, 119a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon const SkMatrix& viewMatrix, 120a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon const SkRect& rectToDraw, 121a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon const SkRect& localRect); 122ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 123ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 124a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon * Fills a rect with a paint and a localMatrix. 125ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 126a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon void fillRectWithLocalMatrix(const GrClip& clip, 12782f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&& paint, 1280e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon GrAA, 129a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon const SkMatrix& viewMatrix, 130a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon const SkRect& rect, 131a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon const SkMatrix& localMatrix); 132ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 133ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 1340e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * Draw a roundrect using a paint. 135ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * 1360e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param paint describes how to color pixels. 1370e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param GrAA Controls whether rrect is antialiased. 1380e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param viewMatrix transformation matrix 1390e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param rrect the roundrect to draw 1400e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param style style to apply to the rrect. Currently path effects are not allowed. 141ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 1422e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void drawRRect(const GrClip&, 14382f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&&, 1440e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon GrAA, 145ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkMatrix& viewMatrix, 146ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkRRect& rrect, 1476663acff010ce752e4bf778da81fa97448c9db31bsalomon const GrStyle& style); 148ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 149ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 1500e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * Draw a roundrect using a paint and a shadow shader. This is separate from drawRRect 1510e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * because it uses different underlying geometry and GeometryProcessor 152c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth * 1530e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param paint describes how to color pixels. 1540e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param viewMatrix transformation matrix 1550e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param rrect the roundrect to draw 1560e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param blurRadius amount of shadow blur to apply (in device space) 1570e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param style style to apply to the rrect. Currently path effects are not allowed. 158c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth */ 159c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth void drawShadowRRect(const GrClip&, 16082f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&&, 161c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth const SkMatrix& viewMatrix, 162c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth const SkRRect& rrect, 163c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth SkScalar blurRadius, 164c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth const GrStyle& style); 165c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth 166c59034145862bf6dc0c503cb1e47eecd321ffa8cJim Van Verth /** 1670e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * Shortcut for filling a SkPath consisting of nested rrects using a paint. The result is 1680e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * undefined if outer does not contain inner. 169000958973f4b514cddbfdcc01ec167437b66de2crobertphillips * 1700e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param paint describes how to color pixels. 1710e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param GrAA Controls whether rrects edges are antialiased 1720e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param viewMatrix transformation matrix 1730e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param outer the outer roundrect 1740e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param inner the inner roundrect 175000958973f4b514cddbfdcc01ec167437b66de2crobertphillips */ 176000958973f4b514cddbfdcc01ec167437b66de2crobertphillips void drawDRRect(const GrClip&, 17782f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&&, 1780e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon GrAA, 179000958973f4b514cddbfdcc01ec167437b66de2crobertphillips const SkMatrix& viewMatrix, 180000958973f4b514cddbfdcc01ec167437b66de2crobertphillips const SkRRect& outer, 181000958973f4b514cddbfdcc01ec167437b66de2crobertphillips const SkRRect& inner); 182000958973f4b514cddbfdcc01ec167437b66de2crobertphillips 183000958973f4b514cddbfdcc01ec167437b66de2crobertphillips /** 184ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * Draws a path. 185ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * 186ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param paint describes how to color pixels. 1870e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param GrAA Controls whether the path is antialiased. 188ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param viewMatrix transformation matrix 189ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param path the path to draw 1906663acff010ce752e4bf778da81fa97448c9db31bsalomon * @param style style to apply to the path. 191ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 1922e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void drawPath(const GrClip&, 19382f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&&, 1940e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon GrAA, 195ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkMatrix& viewMatrix, 196ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkPath&, 1976663acff010ce752e4bf778da81fa97448c9db31bsalomon const GrStyle& style); 198ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 1993de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon enum class ColorArrayType { 2003de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon kPremulGrColor, 2013de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon kSkColor, 2023de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon }; 203ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 204ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * Draws vertices with a paint. 205ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * 206ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param paint describes how to color pixels. 207ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param viewMatrix transformation matrix 208ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param primitiveType primitives type to draw. 209ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param vertexCount number of vertices. 210ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param positions array of vertex positions, required. 211ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param texCoords optional array of texture coordinates used 212ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * to access the paint. 213ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param colors optional array of per-vertex colors, supercedes 214ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * the paint's color field. 215ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param indices optional array of indices. If NULL vertices 216ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * are drawn non-indexed. 217ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param indexCount if indices is non-null then this is the 218ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * number of indices. 2193de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon * @param ColorArrayType Determines how the color array should be interpreted. 220ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 2212e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void drawVertices(const GrClip&, 22282f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&& paint, 223ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkMatrix& viewMatrix, 224ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips GrPrimitiveType primitiveType, 225ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips int vertexCount, 226ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkPoint positions[], 227ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkPoint texs[], 2283de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon const uint32_t colors[], 229ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const uint16_t indices[], 2303de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon int indexCount, 2313de0aee181b8fe0013b15100cba7381eb0468db4Brian Salomon ColorArrayType = ColorArrayType::kPremulGrColor); 232ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 233ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 234199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon * Draws vertices with a paint. 235199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon * 236199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon * @param paint describes how to color pixels. 237199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon * @param viewMatrix transformation matrix 238199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon * @param veritces specifies the mesh to draw. 239199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon * @param flags A bitfield of options specified by SkCanvas::VerticesFlags. 240199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon */ 241199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon void drawVertices(const GrClip&, 242199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon GrPaint&& paint, 243199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon const SkMatrix& viewMatrix, 244199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon sk_sp<SkVertices> vertices, 245199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon uint32_t flags); 246199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon 247199fb875c5e63c13233209e89b943c7ac7ab6665Brian Salomon /** 2480e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * Draws textured sprites from an atlas with a paint. This currently does not support AA for the 2490e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * sprite rectangle edges. 25031ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * 25131ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * @param paint describes how to color pixels. 25231ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * @param viewMatrix transformation matrix 25331ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * @param spriteCount number of sprites. 25431ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * @param xform array of compressed transformation data, required. 25531ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * @param texRect array of texture rectangles used to access the paint. 25631ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * @param colors optional array of per-sprite colors, supercedes 25731ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * the paint's color field. 25831ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth */ 2592e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void drawAtlas(const GrClip&, 26082f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&& paint, 26131ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth const SkMatrix& viewMatrix, 26231ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth int spriteCount, 26331ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth const SkRSXform xform[], 26431ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth const SkRect texRect[], 26531ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth const SkColor colors[]); 266cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett 267cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett /** 268cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett * Draws a region. 269cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett * 270cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett * @param paint describes how to color pixels 271cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett * @param viewMatrix transformation matrix 2720e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param aa should the rects of the region be antialiased. 273cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett * @param region the region to be drawn 274cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett * @param style style to apply to the region 275cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett */ 276cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett void drawRegion(const GrClip&, 27782f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&& paint, 2780e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon GrAA aa, 279cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett const SkMatrix& viewMatrix, 280cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett const SkRegion& region, 281cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett const GrStyle& style); 282cc319b95a58ae15e88c3c028b8726e7cab9121ffmsarett 28331ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth /** 284ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * Draws an oval. 285ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * 286ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param paint describes how to color pixels. 2870e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param GrAA Controls whether the oval is antialiased. 288ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param viewMatrix transformation matrix 289ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param oval the bounding rect of the oval. 2906663acff010ce752e4bf778da81fa97448c9db31bsalomon * @param style style to apply to the oval. Currently path effects are not allowed. 291ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 2922e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void drawOval(const GrClip&, 29382f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&& paint, 2940e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon GrAA, 295ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkMatrix& viewMatrix, 296ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkRect& oval, 2976663acff010ce752e4bf778da81fa97448c9db31bsalomon const GrStyle& style); 2980e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon /** 2990e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * Draws a partial arc of an oval. 3000e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * 3010e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param paint describes how to color pixels. 3029950408c5f20148d5b726421454db718860077deBrian Salomon * @param GrGrAA Controls whether the arc is antialiased. 3030e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param viewMatrix transformation matrix. 3040e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param oval the bounding rect of the oval. 3050e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param startAngle starting angle in degrees. 3060e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param sweepAngle angle to sweep in degrees. Must be in (-360, 360) 3070e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param useCenter true means that the implied path begins at the oval center, connects as 3080e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * a line to the point indicated by the start contains the arc indicated by 3090e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * the sweep angle. If false the line beginning at the center point is 3100e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * omitted. 3110e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon * @param style style to apply to the oval. 3120e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon */ 3134f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon void drawArc(const GrClip&, 31482f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&& paint, 3150e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon GrAA, 3164f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon const SkMatrix& viewMatrix, 3174f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon const SkRect& oval, 3184f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon SkScalar startAngle, 3194f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon SkScalar sweepAngle, 3204f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon bool useCenter, 3214f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon const GrStyle& style); 322ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 32333a5fce6126dc5d3927a71fdc6c35af6f5893fd5joshualitt /** 3244f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon * Draw the image as a set of rects, specified by |iter|. 32533a5fce6126dc5d3927a71fdc6c35af6f5893fd5joshualitt */ 32610e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett void drawImageLattice(const GrClip&, 32782f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&& paint, 32810e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett const SkMatrix& viewMatrix, 32910e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett int imageWidth, 33010e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett int imageHeight, 33110e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett std::unique_ptr<SkLatticeIter> iter, 33210e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett const SkRect& dst); 333ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 3348c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips /** 3358c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips * After this returns any pending surface IO will be issued to the backend 3D API and 3368c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips * if the surface has MSAA it will be resolved. 3378c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips */ 3388c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips void prepareForExternalIO(); 3398c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips 340976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips bool isStencilBufferMultisampled() const { 341c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips return fRenderTargetProxy->isStencilBufferMultisampled(); 342976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips } 343c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips bool isUnifiedMultisampled() const { return fRenderTargetProxy->isUnifiedMultisampled(); } 344c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips bool hasMixedSamples() const { return fRenderTargetProxy->isMixedSampled(); } 34582ec6e59b8b694c128adcf8590667d37327dd1c4robertphillips 346faf8203ea7588dcdca82f69f5a5447b3eb53a849bsalomon const GrCaps* caps() const { return fContext->caps(); } 347c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips const GrSurfaceDesc& desc() const { return fRenderTargetProxy->desc(); } 348c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips int width() const { return fRenderTargetProxy->width(); } 349c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips int height() const { return fRenderTargetProxy->height(); } 350c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips GrPixelConfig config() const { return fRenderTargetProxy->config(); } 351c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips int numColorSamples() const { return fRenderTargetProxy->numColorSamples(); } 352ca6eafc0f7e59ed89f03a9891b9fdf7de64f1f35robertphillips const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; } 353c71a9b7f53938b4f33f36f48e867b8b72cc1cc61msarett GrColorSpaceXform* getColorXformFromSRGB() const { return fColorXformFromSRGB.get(); } 354c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips GrSurfaceOrigin origin() const { return fRenderTargetProxy->origin(); } 3557bceedc550513b13e0065aca66e55204a2ba3e1frobertphillips 3567761d61876ea479dd9672b684fd5c7601932a767robertphillips bool wasAbandoned() const; 3577761d61876ea479dd9672b684fd5c7601932a767robertphillips 358eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillips GrRenderTarget* instantiate(); 359eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillips 360c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips GrRenderTarget* accessRenderTarget() { 361c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips // TODO: usage of this entry point needs to be reduced and potentially eliminated 362c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips // since it ends the deferral of the GrRenderTarget's allocation 363c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips return fRenderTargetProxy->instantiate(fContext->textureProvider()); 364c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips } 3656c7e325236b7fbb9c9b14ebb4715f88a59718695robertphillips 366f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips GrSurfaceProxy* asSurfaceProxy() override { return fRenderTargetProxy.get(); } 367f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips const GrSurfaceProxy* asSurfaceProxy() const override { return fRenderTargetProxy.get(); } 368f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips sk_sp<GrSurfaceProxy> asSurfaceProxyRef() override { return fRenderTargetProxy; } 369f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips 370f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips GrTextureProxy* asTextureProxy() override; 371f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips sk_sp<GrTextureProxy> asTextureProxyRef() override; 372f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips 373f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips GrRenderTargetProxy* asRenderTargetProxy() override { return fRenderTargetProxy.get(); } 374f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips sk_sp<GrRenderTargetProxy> asRenderTargetProxyRef() override { return fRenderTargetProxy; } 375eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillips 376d46697ac36d5cb3b58571c6129cb5b26fe9d25d7Robert Phillips GrRenderTargetContext* asRenderTargetContext() override { return this; } 377d46697ac36d5cb3b58571c6129cb5b26fe9d25d7Robert Phillips 378c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips sk_sp<GrTexture> asTexture() { 379e60ad620fe236ce4c1e85a31bd53ed0c848da8c3Robert Phillips if (!this->accessRenderTarget()) { 380e60ad620fe236ce4c1e85a31bd53ed0c848da8c3Robert Phillips return nullptr; 381e60ad620fe236ce4c1e85a31bd53ed0c848da8c3Robert Phillips } 382e60ad620fe236ce4c1e85a31bd53ed0c848da8c3Robert Phillips 383c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips // TODO: usage of this entry point needs to be reduced and potentially eliminated 384c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips // since it ends the deferral of the GrRenderTarget's allocation 385f200a90f3e58ce20753420cadced850d7d00dca1Robert Phillips // It's usage should migrate to asTextureProxyRef 386c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips return sk_ref_sp(this->accessRenderTarget()->asTexture()); 387c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips } 388433625e67c61c3acce4fd95b3881493c9f4f2c7frobertphillips 389391395dcfbff09a83f8f0e9d3e02d38c855ae2e9robertphillips // Provides access to functions that aren't part of the public API. 390693a540272a771c6b0830094c461397cb77543b1Brian Osman GrRenderTargetContextPriv priv(); 391693a540272a771c6b0830094c461397cb77543b1Brian Osman const GrRenderTargetContextPriv priv() const; 392f5883a6d75a18c581507214d3057b5c721ed1ffcjoshualitt 393eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillips bool isWrapped_ForTesting() const; 394eaa862569dc91d55fc79d057df6e69b139e46888Robert Phillips 39596880d9e366d58e5960aa0ee6aa67260797679ebjoshualittprotected: 396c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips GrRenderTargetContext(GrContext*, GrDrawingManager*, sk_sp<GrRenderTargetProxy>, 3972c86249465c28a532c8be55b6ba497021e3110ecRobert Phillips sk_sp<SkColorSpace>, const SkSurfaceProps*, GrAuditTrail*, 398c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips GrSingleOwner*); 399ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 4002e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips SkDEBUGCODE(void validate() const;) 401ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 40296880d9e366d58e5960aa0ee6aa67260797679ebjoshualittprivate: 4030e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon inline GrAAType decideAAType(GrAA aa, bool allowMixedSamples = false) { 4040e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon if (GrAA::kNo == aa) { 4050e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon return GrAAType::kNone; 4060e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon } 4070e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon if (this->isUnifiedMultisampled()) { 4080e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon return GrAAType::kMSAA; 4090e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon } 4100e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon if (allowMixedSamples && this->isStencilBufferMultisampled()) { 4110e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon return GrAAType::kMixedSamples; 4120e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon } 4130e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon return GrAAType::kCoverage; 4140e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon } 4150e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon 41642521e891081a7a85db4390a457074054649f194Brian Salomon friend class GrAtlasTextBlob; // for access to addDrawOp 41742521e891081a7a85db4390a457074054649f194Brian Salomon friend class GrStencilAndCoverTextContext; // for access to addDrawOp 41855fdcccf01d49173bc731024b4283d3a3ea9150arobertphillips 41996880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt friend class GrDrawingManager; // for ctor 4201105224f9701e57ec5ce0354d6a380b664f5c638Brian Osman friend class GrRenderTargetContextPriv; 42142521e891081a7a85db4390a457074054649f194Brian Salomon friend class GrSWMaskHelper; // for access to addDrawOp 42242521e891081a7a85db4390a457074054649f194Brian Salomon 42342521e891081a7a85db4390a457074054649f194Brian Salomon // All the path renderers currently make their own ops 42442521e891081a7a85db4390a457074054649f194Brian Salomon friend class GrSoftwarePathRenderer; // for access to addDrawOp 42542521e891081a7a85db4390a457074054649f194Brian Salomon friend class GrAAConvexPathRenderer; // for access to addDrawOp 42642521e891081a7a85db4390a457074054649f194Brian Salomon friend class GrDashLinePathRenderer; // for access to addDrawOp 42742521e891081a7a85db4390a457074054649f194Brian Salomon friend class GrAAHairLinePathRenderer; // for access to addDrawOp 42842521e891081a7a85db4390a457074054649f194Brian Salomon friend class GrAALinearizingConvexPathRenderer; // for access to addDrawOp 42942521e891081a7a85db4390a457074054649f194Brian Salomon friend class GrAADistanceFieldPathRenderer; // for access to addDrawOp 43042521e891081a7a85db4390a457074054649f194Brian Salomon friend class GrDefaultPathRenderer; // for access to addDrawOp 43142521e891081a7a85db4390a457074054649f194Brian Salomon friend class GrPLSPathRenderer; // 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 4365d4cd9ea8818f65bb4878c050dbdb9dcd48505adBrian Salomon friend void test_draw_op(GrRenderTargetContext*, sk_sp<GrFragmentProcessor>, GrTexture*); 437ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 43829df76096fd30941086324902a82656df2d8becdcsmartdalton void internalClear(const GrFixedClip&, const GrColor, bool canIgnoreClip); 43929df76096fd30941086324902a82656df2d8becdcsmartdalton 44082f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon // Only consumes the GrPaint if successful. 441000958973f4b514cddbfdcc01ec167437b66de2crobertphillips bool drawFilledDRRect(const GrClip& clip, 44282f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&& paint, 4430e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon GrAA, 444000958973f4b514cddbfdcc01ec167437b66de2crobertphillips const SkMatrix& viewMatrix, 445000958973f4b514cddbfdcc01ec167437b66de2crobertphillips const SkRRect& origOuter, 446000958973f4b514cddbfdcc01ec167437b66de2crobertphillips const SkRRect& origInner); 447000958973f4b514cddbfdcc01ec167437b66de2crobertphillips 44882f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon // Only consumes the GrPaint if successful. 449443023975e335e3630191227dbc21fa72c436af3robertphillips bool drawFilledRect(const GrClip& clip, 45082f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&& paint, 4510e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon GrAA, 452443023975e335e3630191227dbc21fa72c436af3robertphillips const SkMatrix& viewMatrix, 453443023975e335e3630191227dbc21fa72c436af3robertphillips const SkRect& rect, 454443023975e335e3630191227dbc21fa72c436af3robertphillips const GrUserStencilSettings* ss); 455443023975e335e3630191227dbc21fa72c436af3robertphillips 456443023975e335e3630191227dbc21fa72c436af3robertphillips void drawNonAAFilledRect(const GrClip&, 45782f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon GrPaint&&, 458443023975e335e3630191227dbc21fa72c436af3robertphillips const SkMatrix& viewMatrix, 459443023975e335e3630191227dbc21fa72c436af3robertphillips const SkRect& rect, 460443023975e335e3630191227dbc21fa72c436af3robertphillips const SkRect* localRect, 461443023975e335e3630191227dbc21fa72c436af3robertphillips const SkMatrix* localMatrix, 46234ee0c950e1aa24818632084acdb382514f98c08csmartdalton const GrUserStencilSettings* ss, 4630e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon GrAAType hwOrNoneAAType); 4640e8fc8b9e6a138cf4a66b421fb824679df717329Brian Salomon 46582f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon void internalDrawPath( 46682f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon const GrClip&, GrPaint&&, GrAA, const SkMatrix&, const SkPath&, const GrStyle&); 467ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 468e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips bool onCopy(GrSurfaceProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint) override; 4692c86249465c28a532c8be55b6ba497021e3110ecRobert Phillips bool onReadPixels(const SkImageInfo& dstInfo, void* dstBuffer, 4702c86249465c28a532c8be55b6ba497021e3110ecRobert Phillips size_t dstRowBytes, int x, int y) override; 4712c86249465c28a532c8be55b6ba497021e3110ecRobert Phillips bool onWritePixels(const SkImageInfo& srcInfo, const void* srcBuffer, 4722c86249465c28a532c8be55b6ba497021e3110ecRobert Phillips size_t srcRowBytes, int x, int y) override; 473e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips 47442521e891081a7a85db4390a457074054649f194Brian Salomon // This entry point allows the GrTextContext-derived classes to add their ops to the GrOpList. 475f8334781914363caf537f22f012fcd5c03c60dadBrian Salomon void addDrawOp(const GrPipelineBuilder&, const GrClip&, std::unique_ptr<GrDrawOp>); 4762334fb655f8d4ef5915770d32bf845c88d3627f4robertphillips 477f2361d2d93c200cd4555b5e8ecea4531801abaaaRobert Phillips GrRenderTargetOpList* getOpList(); 478a106c627532ad669cf7d879955ae8ea6a53233c1robertphillips 479c7635fa374b87711e5ccd8222957a8fbdc772f7bRobert Phillips sk_sp<GrRenderTargetProxy> fRenderTargetProxy; 480a106c627532ad669cf7d879955ae8ea6a53233c1robertphillips 4811105224f9701e57ec5ce0354d6a380b664f5c638Brian Osman // In MDB-mode the GrOpList can be closed by some other renderTargetContext that has picked 482f2361d2d93c200cd4555b5e8ecea4531801abaaaRobert Phillips // it up. For this reason, the GrOpList should only ever be accessed via 'getOpList'. 483f2361d2d93c200cd4555b5e8ecea4531801abaaaRobert Phillips GrRenderTargetOpList* fOpList; 484c71a9b7f53938b4f33f36f48e867b8b72cc1cc61msarett GrInstancedPipelineInfo fInstancedPipelineInfo; 4852334fb655f8d4ef5915770d32bf845c88d3627f4robertphillips 486c71a9b7f53938b4f33f36f48e867b8b72cc1cc61msarett sk_sp<GrColorSpaceXform> fColorXformFromSRGB; 487c71a9b7f53938b4f33f36f48e867b8b72cc1cc61msarett SkSurfaceProps fSurfaceProps; 488e305cc1f2a44e47d6a0dcc0ff34e2692349aed5dRobert Phillips 489e305cc1f2a44e47d6a0dcc0ff34e2692349aed5dRobert Phillips typedef GrSurfaceContext INHERITED; 490ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips}; 491ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 492ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips#endif 493