GrRenderTargetContext.h revision 4f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14
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 8ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips#ifndef GrDrawContext_DEFINED 9ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips#define GrDrawContext_DEFINED 10ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 11ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips#include "GrColor.h" 12ecbc12b1c1c72de0cf7bba4a3f6a7cce4f43bf41csmartdalton#include "GrPaint.h" 137bceedc550513b13e0065aca66e55204a2ba3e1frobertphillips#include "GrRenderTarget.h" 14ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips#include "SkRefCnt.h" 15391395dcfbff09a83f8f0e9d3e02d38c855ae2e9robertphillips#include "SkRegion.h" 16fcf7829b67b798aff4c41c4688daa9c7381991e6robertphillips#include "SkSurfaceProps.h" 17a7f29640f6ab4eb50962a9d9f12d01ac2ce8b471csmartdalton#include "../private/GrInstancedPipelineInfo.h" 181de610a5287cf61d4f3a1fdc7413bd74827a8b6ajoshualitt#include "../private/GrSingleOwner.h" 19ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 20bc90735170b5d85a19b24df0baa865f7cf87d348joshualittclass GrAuditTrail; 21ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass GrClip; 22ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass GrContext; 23abd30f54b7ff1704a8930c4307ea242d09425d02bsalomonclass GrDrawBatch; 24391395dcfbff09a83f8f0e9d3e02d38c855ae2e9robertphillipsclass GrDrawContextPriv; 258ff8d24c83353fc421177886d82202da9ff89234cdaltonclass GrDrawPathBatchBase; 2677a2e52c7d5c77de73ecab5fec79072ee4460706robertphillipsclass GrDrawingManager; 27ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass GrDrawTarget; 28ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass GrPaint; 29ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass GrPathProcessor; 30ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass GrPipelineBuilder; 31ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass GrRenderTarget; 326663acff010ce752e4bf778da81fa97448c9db31bsalomonclass GrStyle; 33ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass GrSurface; 34443023975e335e3630191227dbc21fa72c436af3robertphillipsstruct GrUserStencilSettings; 352334fb655f8d4ef5915770d32bf845c88d3627f4robertphillipsclass SkDrawFilter; 36ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsstruct SkIPoint; 37ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsstruct SkIRect; 3810e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarettclass SkLatticeIter; 39ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass SkMatrix; 402334fb655f8d4ef5915770d32bf845c88d3627f4robertphillipsclass SkPaint; 41ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass SkPath; 42ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsstruct SkPoint; 43ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsstruct SkRect; 44ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass SkRRect; 4531ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverthstruct SkRSXform; 462334fb655f8d4ef5915770d32bf845c88d3627f4robertphillipsclass SkTextBlob; 47ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 48ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips/* 49ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * A helper object to orchestrate draws 50ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 51ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipsclass SK_API GrDrawContext : public SkRefCnt { 52ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillipspublic: 532334fb655f8d4ef5915770d32bf845c88d3627f4robertphillips ~GrDrawContext() override; 542334fb655f8d4ef5915770d32bf845c88d3627f4robertphillips 55b8fea97a7a493897fcff33aa2932d875c572f163bsalomon bool copySurface(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint); 56ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 572334fb655f8d4ef5915770d32bf845c88d3627f4robertphillips // TODO: it is odd that we need both the SkPaint in the following 3 methods. 582334fb655f8d4ef5915770d32bf845c88d3627f4robertphillips // We should extract the text parameters from SkPaint and pass them separately 596663acff010ce752e4bf778da81fa97448c9db31bsalomon // akin to GrStyle (GrTextInfo?) 6096880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt virtual void drawText(const GrClip&, const GrPaint&, const SkPaint&, 6196880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt const SkMatrix& viewMatrix, const char text[], size_t byteLength, 6296880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt SkScalar x, SkScalar y, const SkIRect& clipBounds); 6396880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt virtual void drawPosText(const GrClip&, const GrPaint&, const SkPaint&, 6496880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt const SkMatrix& viewMatrix, const char text[], size_t byteLength, 6596880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt const SkScalar pos[], int scalarsPerPosition, 6696880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt const SkPoint& offset, const SkIRect& clipBounds); 6796880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt virtual void drawTextBlob(const GrClip&, const SkPaint&, 6896880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt const SkMatrix& viewMatrix, const SkTextBlob*, 6996880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt SkScalar x, SkScalar y, 7096880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt SkDrawFilter*, const SkIRect& clipBounds); 71ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 72ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 73ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * Provides a perfomance hint that the render target's contents are allowed 74ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * to become undefined. 75ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 762e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void discard(); 77ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 78ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 79ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * Clear the entire or rect of the render target, ignoring any clips. 80ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param rect the rect to clear or the whole thing if rect is NULL. 81ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param color the color to clear to. 82ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param canIgnoreRect allows partial clears to be converted to whole 83ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * clears on platforms for which that is cheap 84ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 852e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void clear(const SkIRect* rect, GrColor color, bool canIgnoreRect); 86ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 87ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 88ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * Draw everywhere (respecting the clip) with the paint. 89ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 902e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void drawPaint(const GrClip&, const GrPaint&, const SkMatrix& viewMatrix); 91ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 92ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 93ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * Draw the rect using a paint. 94ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param paint describes how to color pixels. 95ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param viewMatrix transformation matrix 966663acff010ce752e4bf778da81fa97448c9db31bsalomon * @param style The style to apply. Null means fill. Currently path effects are not 976663acff010ce752e4bf778da81fa97448c9db31bsalomon * allowed. 98ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * The rects coords are used to access the paint (through texture matrix) 99ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 1002e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void drawRect(const GrClip&, 101ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const GrPaint& paint, 102ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkMatrix& viewMatrix, 103ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkRect&, 1046663acff010ce752e4bf778da81fa97448c9db31bsalomon const GrStyle* style = nullptr); 105ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 106ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 107a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon * Maps a rectangle of shader coordinates to a rectangle and fills that rectangle. 108ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * 109ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param paint describes how to color pixels. 110ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param viewMatrix transformation matrix which applies to rectToDraw 111ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param rectToDraw the rectangle to draw 112ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param localRect the rectangle of shader coordinates applied to rectToDraw 113ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 114a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon void fillRectToRect(const GrClip&, 115a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon const GrPaint& paint, 116a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon const SkMatrix& viewMatrix, 117a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon const SkRect& rectToDraw, 118a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon const SkRect& localRect); 119ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 120ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 121a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon * Fills a rect with a paint and a localMatrix. 122ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 123a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon void fillRectWithLocalMatrix(const GrClip& clip, 124a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon const GrPaint& paint, 125a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon const SkMatrix& viewMatrix, 126a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon const SkRect& rect, 127a2e69fcdedbd9a7762620e0e9dcdd86596369cffbsalomon const SkMatrix& localMatrix); 128ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 129ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 130ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * Draw a roundrect using a paint. 131ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * 132ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param paint describes how to color pixels. 133ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param viewMatrix transformation matrix 134ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param rrect the roundrect to draw 1356663acff010ce752e4bf778da81fa97448c9db31bsalomon * @param style style to apply to the rrect. Currently path effects are not allowed. 136ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 1372e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void drawRRect(const GrClip&, 138ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const GrPaint&, 139ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkMatrix& viewMatrix, 140ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkRRect& rrect, 1416663acff010ce752e4bf778da81fa97448c9db31bsalomon const GrStyle& style); 142ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 143ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 144000958973f4b514cddbfdcc01ec167437b66de2crobertphillips * Shortcut for drawing an SkPath consisting of nested rrects using a paint. 145000958973f4b514cddbfdcc01ec167437b66de2crobertphillips * Does not support stroking. The result is undefined if outer does not contain 146000958973f4b514cddbfdcc01ec167437b66de2crobertphillips * inner. 147000958973f4b514cddbfdcc01ec167437b66de2crobertphillips * 148000958973f4b514cddbfdcc01ec167437b66de2crobertphillips * @param paint describes how to color pixels. 149000958973f4b514cddbfdcc01ec167437b66de2crobertphillips * @param viewMatrix transformation matrix 150000958973f4b514cddbfdcc01ec167437b66de2crobertphillips * @param outer the outer roundrect 151000958973f4b514cddbfdcc01ec167437b66de2crobertphillips * @param inner the inner roundrect 152000958973f4b514cddbfdcc01ec167437b66de2crobertphillips */ 153000958973f4b514cddbfdcc01ec167437b66de2crobertphillips void drawDRRect(const GrClip&, 154000958973f4b514cddbfdcc01ec167437b66de2crobertphillips const GrPaint&, 155000958973f4b514cddbfdcc01ec167437b66de2crobertphillips const SkMatrix& viewMatrix, 156000958973f4b514cddbfdcc01ec167437b66de2crobertphillips const SkRRect& outer, 157000958973f4b514cddbfdcc01ec167437b66de2crobertphillips const SkRRect& inner); 158000958973f4b514cddbfdcc01ec167437b66de2crobertphillips 159000958973f4b514cddbfdcc01ec167437b66de2crobertphillips /** 160ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * Draws a path. 161ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * 162ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param paint describes how to color pixels. 163ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param viewMatrix transformation matrix 164ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param path the path to draw 1656663acff010ce752e4bf778da81fa97448c9db31bsalomon * @param style style to apply to the path. 166ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 1672e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void drawPath(const GrClip&, 168ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const GrPaint&, 169ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkMatrix& viewMatrix, 170ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkPath&, 1716663acff010ce752e4bf778da81fa97448c9db31bsalomon const GrStyle& style); 172ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 173ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 174ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * Draws vertices with a paint. 175ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * 176ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param paint describes how to color pixels. 177ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param viewMatrix transformation matrix 178ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param primitiveType primitives type to draw. 179ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param vertexCount number of vertices. 180ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param positions array of vertex positions, required. 181ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param texCoords optional array of texture coordinates used 182ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * to access the paint. 183ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param colors optional array of per-vertex colors, supercedes 184ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * the paint's color field. 185ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param indices optional array of indices. If NULL vertices 186ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * are drawn non-indexed. 187ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param indexCount if indices is non-null then this is the 188ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * number of indices. 189ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 1902e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void drawVertices(const GrClip&, 191ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const GrPaint& paint, 192ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkMatrix& viewMatrix, 193ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips GrPrimitiveType primitiveType, 194ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips int vertexCount, 195ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkPoint positions[], 196ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkPoint texs[], 197ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const GrColor colors[], 198ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const uint16_t indices[], 199ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips int indexCount); 200ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 201ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips /** 20231ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * Draws textured sprites from an atlas with a paint. 20331ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * 20431ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * @param paint describes how to color pixels. 20531ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * @param viewMatrix transformation matrix 20631ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * @param spriteCount number of sprites. 20731ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * @param xform array of compressed transformation data, required. 20831ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * @param texRect array of texture rectangles used to access the paint. 20931ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * @param colors optional array of per-sprite colors, supercedes 21031ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth * the paint's color field. 21131ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth */ 2122e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void drawAtlas(const GrClip&, 21331ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth const GrPaint& paint, 21431ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth const SkMatrix& viewMatrix, 21531ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth int spriteCount, 21631ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth const SkRSXform xform[], 21731ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth const SkRect texRect[], 21831ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth const SkColor colors[]); 21931ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth 22031ff762dc8bfcd86eb4af92b18fdad36913a04e5jvanverth /** 221ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * Draws an oval. 222ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * 223ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param paint describes how to color pixels. 224ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param viewMatrix transformation matrix 225ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips * @param oval the bounding rect of the oval. 2266663acff010ce752e4bf778da81fa97448c9db31bsalomon * @param style style to apply to the oval. Currently path effects are not allowed. 227ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips */ 2282e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips void drawOval(const GrClip&, 229ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const GrPaint& paint, 230ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkMatrix& viewMatrix, 231ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkRect& oval, 2326663acff010ce752e4bf778da81fa97448c9db31bsalomon const GrStyle& style); 2334f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon /** 2344f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon * Draws a partial arc of an oval. 2354f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon * 2364f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon * @param paint describes how to color pixels. 2374f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon * @param viewMatrix transformation matrix. 2384f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon * @param oval the bounding rect of the oval. 2394f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon * @param startAngle starting angle in degrees. 2404f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon * @param sweepAngle angle to sweep in degrees. Must be in (-360, 360) 2414f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon * @param useCenter true means that the implied path begins at the oval center, connects as a 2424f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon * line to the point indicated by the start contains the arc indicated by 2434f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon * the sweep angle. If false the line beginning at the center point is 2444f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon * omitted. 2454f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon * @param style style to apply to the oval. 2464f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon */ 2474f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon void drawArc(const GrClip&, 2484f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon const GrPaint& paint, 2494f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon const SkMatrix& viewMatrix, 2504f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon const SkRect& oval, 2514f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon SkScalar startAngle, 2524f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon SkScalar sweepAngle, 2534f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon bool useCenter, 2544f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon const GrStyle& style); 255ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 25633a5fce6126dc5d3927a71fdc6c35af6f5893fd5joshualitt /** 2574f3a0ca85d28a8fc7fcc1ac5c4a1864c66bdea14bsalomon * Draw the image as a set of rects, specified by |iter|. 25833a5fce6126dc5d3927a71fdc6c35af6f5893fd5joshualitt */ 25910e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett void drawImageLattice(const GrClip&, 26010e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett const GrPaint& paint, 26110e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett const SkMatrix& viewMatrix, 26210e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett int imageWidth, 26310e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett int imageHeight, 26410e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett std::unique_ptr<SkLatticeIter> iter, 26510e3d9bf59bdec92c05367ae0b71e1ce1ee4a690msarett const SkRect& dst); 266ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 2678c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips /** 2688c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips * After this returns any pending surface IO will be issued to the backend 3D API and 2698c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips * if the surface has MSAA it will be resolved. 2708c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips */ 2718c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips void prepareForExternalIO(); 2728c523e0f3ffa66eefd70f893e9f863b7d9ea3dc9robertphillips 273976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips bool isStencilBufferMultisampled() const { 274976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips return fRenderTarget->isStencilBufferMultisampled(); 275976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips } 27655fdcccf01d49173bc731024b4283d3a3ea9150arobertphillips bool isUnifiedMultisampled() const { return fRenderTarget->isUnifiedMultisampled(); } 277f9635999a4aa8810d04e8ef04594a9fbcc061e3dcsmartdalton bool hasMixedSamples() const { return fRenderTarget->isMixedSampled(); } 27882ec6e59b8b694c128adcf8590667d37327dd1c4robertphillips 279ecbc12b1c1c72de0cf7bba4a3f6a7cce4f43bf41csmartdalton bool mustUseHWAA(const GrPaint& paint) const { 280bb24383abb724c516e472af4eec68f2c3f17a6d0bsalomon return paint.isAntiAlias() && fRenderTarget->isUnifiedMultisampled(); 281ecbc12b1c1c72de0cf7bba4a3f6a7cce4f43bf41csmartdalton } 282ecbc12b1c1c72de0cf7bba4a3f6a7cce4f43bf41csmartdalton 283e576874b162f8c66aa6c2e06cb6bc459ccd8b6f9robertphillips const GrSurfaceDesc& desc() const { return fRenderTarget->desc(); } 2847bceedc550513b13e0065aca66e55204a2ba3e1frobertphillips int width() const { return fRenderTarget->width(); } 2857bceedc550513b13e0065aca66e55204a2ba3e1frobertphillips int height() const { return fRenderTarget->height(); } 286ca6eafc0f7e59ed89f03a9891b9fdf7de64f1f35robertphillips GrPixelConfig config() const { return fRenderTarget->config(); } 2877bceedc550513b13e0065aca66e55204a2ba3e1frobertphillips int numColorSamples() const { return fRenderTarget->numColorSamples(); } 2889dc935fa11521d4a6c7875699c050044a45d0871brianosman bool isGammaCorrect() const { return SkToBool(fColorSpace.get()); } 2898fe485b793f6b3c286700988138e1395b0d33487brianosman SkSourceGammaTreatment sourceGammaTreatment() const { 2908fe485b793f6b3c286700988138e1395b0d33487brianosman return this->isGammaCorrect() ? SkSourceGammaTreatment::kRespect 2918fe485b793f6b3c286700988138e1395b0d33487brianosman : SkSourceGammaTreatment::kIgnore; 2928fe485b793f6b3c286700988138e1395b0d33487brianosman } 293ca6eafc0f7e59ed89f03a9891b9fdf7de64f1f35robertphillips const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; } 294dfe4f2e4fe5b162d4adb4486fe751f1e3b30bea7brianosman SkColorSpace* getColorSpace() const { return fColorSpace.get(); } 2957e922765545f42ce691e4f3d5fbbd4e44ba47ff1robertphillips GrSurfaceOrigin origin() const { return fRenderTarget->origin(); } 2967bceedc550513b13e0065aca66e55204a2ba3e1frobertphillips 2977761d61876ea479dd9672b684fd5c7601932a767robertphillips bool wasAbandoned() const; 2987761d61876ea479dd9672b684fd5c7601932a767robertphillips 2996c7e325236b7fbb9c9b14ebb4715f88a59718695robertphillips GrRenderTarget* accessRenderTarget() { return fRenderTarget.get(); } 3006c7e325236b7fbb9c9b14ebb4715f88a59718695robertphillips 3016c7e325236b7fbb9c9b14ebb4715f88a59718695robertphillips sk_sp<GrRenderTarget> renderTarget() { return fRenderTarget; } 3026c7e325236b7fbb9c9b14ebb4715f88a59718695robertphillips 3036c7e325236b7fbb9c9b14ebb4715f88a59718695robertphillips sk_sp<GrTexture> asTexture() { return sk_ref_sp(fRenderTarget->asTexture()); } 304433625e67c61c3acce4fd95b3881493c9f4f2c7frobertphillips 305391395dcfbff09a83f8f0e9d3e02d38c855ae2e9robertphillips // Provides access to functions that aren't part of the public API. 306391395dcfbff09a83f8f0e9d3e02d38c855ae2e9robertphillips GrDrawContextPriv drawContextPriv(); 307391395dcfbff09a83f8f0e9d3e02d38c855ae2e9robertphillips const GrDrawContextPriv drawContextPriv() const; 308f5883a6d75a18c581507214d3057b5c721ed1ffcjoshualitt 309976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips GrAuditTrail* auditTrail() { return fAuditTrail; } 310976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips 31196880d9e366d58e5960aa0ee6aa67260797679ebjoshualittprotected: 312dfe4f2e4fe5b162d4adb4486fe751f1e3b30bea7brianosman GrDrawContext(GrContext*, GrDrawingManager*, sk_sp<GrRenderTarget>, sk_sp<SkColorSpace>, 31396880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt const SkSurfaceProps* surfaceProps, GrAuditTrail*, GrSingleOwner*); 314ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 31596880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt GrDrawingManager* drawingManager() { return fDrawingManager; } 316ca6eafc0f7e59ed89f03a9891b9fdf7de64f1f35robertphillips 31796880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt SkDEBUGCODE(GrSingleOwner* singleOwner() { return fSingleOwner; }) 3182e1e51f04985f7c258b96f0decc190456f5dd74drobertphillips SkDEBUGCODE(void validate() const;) 319ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 32096880d9e366d58e5960aa0ee6aa67260797679ebjoshualittprivate: 32196880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt friend class GrAtlasTextBlob; // for access to drawBatch 322193d9cf8f2280cd4f8e509c6f3af6b47cea04935cdalton friend class GrStencilAndCoverTextContext; // for access to drawBatch 32355fdcccf01d49173bc731024b4283d3a3ea9150arobertphillips 32496880d9e366d58e5960aa0ee6aa67260797679ebjoshualitt friend class GrDrawingManager; // for ctor 325391395dcfbff09a83f8f0e9d3e02d38c855ae2e9robertphillips friend class GrDrawContextPriv; 32687f15c8ff11ad2bfb0c6711d7837020a50fe7fb8robertphillips friend class GrTestTarget; // for access to getDrawTarget 327976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips friend class GrSWMaskHelper; // for access to drawBatch 328976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips 329976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips // All the path renderers currently make their own batches 330976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips friend class GrSoftwarePathRenderer; // for access to drawBatch 331976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips friend class GrAAConvexPathRenderer; // for access to drawBatch 332976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips friend class GrDashLinePathRenderer; // for access to drawBatch 333976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips friend class GrAAHairLinePathRenderer; // for access to drawBatch 334976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips friend class GrAALinearizingConvexPathRenderer; // for access to drawBatch 335976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips friend class GrAADistanceFieldPathRenderer; // for access to drawBatch 336976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips friend class GrDefaultPathRenderer; // for access to drawBatch 337976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips friend class GrPLSPathRenderer; // for access to drawBatch 338976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips friend class GrMSAAPathRenderer; // for access to drawBatch 339976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips friend class GrStencilAndCoverPathRenderer; // for access to drawBatch 340976f5f0dc5e907d1ca50685fad117bd15d7fc87brobertphillips friend class GrTessellatingPathRenderer; // for access to drawBatch 341ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 342000958973f4b514cddbfdcc01ec167437b66de2crobertphillips bool drawFilledDRRect(const GrClip& clip, 343000958973f4b514cddbfdcc01ec167437b66de2crobertphillips const GrPaint& paint, 344000958973f4b514cddbfdcc01ec167437b66de2crobertphillips const SkMatrix& viewMatrix, 345000958973f4b514cddbfdcc01ec167437b66de2crobertphillips const SkRRect& origOuter, 346000958973f4b514cddbfdcc01ec167437b66de2crobertphillips const SkRRect& origInner); 347000958973f4b514cddbfdcc01ec167437b66de2crobertphillips 348443023975e335e3630191227dbc21fa72c436af3robertphillips bool drawFilledRect(const GrClip& clip, 349443023975e335e3630191227dbc21fa72c436af3robertphillips const GrPaint& paint, 350443023975e335e3630191227dbc21fa72c436af3robertphillips const SkMatrix& viewMatrix, 351443023975e335e3630191227dbc21fa72c436af3robertphillips const SkRect& rect, 352443023975e335e3630191227dbc21fa72c436af3robertphillips const GrUserStencilSettings* ss); 353443023975e335e3630191227dbc21fa72c436af3robertphillips 354443023975e335e3630191227dbc21fa72c436af3robertphillips void drawNonAAFilledRect(const GrClip&, 355443023975e335e3630191227dbc21fa72c436af3robertphillips const GrPaint&, 356443023975e335e3630191227dbc21fa72c436af3robertphillips const SkMatrix& viewMatrix, 357443023975e335e3630191227dbc21fa72c436af3robertphillips const SkRect& rect, 358443023975e335e3630191227dbc21fa72c436af3robertphillips const SkRect* localRect, 359443023975e335e3630191227dbc21fa72c436af3robertphillips const SkMatrix* localMatrix, 36034ee0c950e1aa24818632084acdb382514f98c08csmartdalton const GrUserStencilSettings* ss, 36134ee0c950e1aa24818632084acdb382514f98c08csmartdalton bool useHWAA); 362391395dcfbff09a83f8f0e9d3e02d38c855ae2e9robertphillips 3634bc31815ba1aa42ea13c5637c6b52262422b7bdbrobertphillips void internalDrawPath(const GrClip& clip, 3644bc31815ba1aa42ea13c5637c6b52262422b7bdbrobertphillips const GrPaint& paint, 365ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips const SkMatrix& viewMatrix, 3664bc31815ba1aa42ea13c5637c6b52262422b7bdbrobertphillips const SkPath& path, 3676663acff010ce752e4bf778da81fa97448c9db31bsalomon const GrStyle& style); 368ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 3692334fb655f8d4ef5915770d32bf845c88d3627f4robertphillips // This entry point allows the GrTextContext-derived classes to add their batches to 3702334fb655f8d4ef5915770d32bf845c88d3627f4robertphillips // the drawTarget. 371bb24383abb724c516e472af4eec68f2c3f17a6d0bsalomon void drawBatch(const GrPipelineBuilder& pipelineBuilder, const GrClip&, GrDrawBatch* batch); 3722334fb655f8d4ef5915770d32bf845c88d3627f4robertphillips 373a106c627532ad669cf7d879955ae8ea6a53233c1robertphillips GrDrawTarget* getDrawTarget(); 374a106c627532ad669cf7d879955ae8ea6a53233c1robertphillips 3758db867820bd9cd31b8aea14632a05739f5d44965joshualitt GrDrawingManager* fDrawingManager; 3766c7e325236b7fbb9c9b14ebb4715f88a59718695robertphillips sk_sp<GrRenderTarget> fRenderTarget; 377a106c627532ad669cf7d879955ae8ea6a53233c1robertphillips 378a106c627532ad669cf7d879955ae8ea6a53233c1robertphillips // In MDB-mode the drawTarget can be closed by some other drawContext that has picked 379a106c627532ad669cf7d879955ae8ea6a53233c1robertphillips // it up. For this reason, the drawTarget should only ever be accessed via 'getDrawTarget'. 3808db867820bd9cd31b8aea14632a05739f5d44965joshualitt GrDrawTarget* fDrawTarget; 3818db867820bd9cd31b8aea14632a05739f5d44965joshualitt GrContext* fContext; 382a7f29640f6ab4eb50962a9d9f12d01ac2ce8b471csmartdalton GrInstancedPipelineInfo fInstancedPipelineInfo; 3832334fb655f8d4ef5915770d32bf845c88d3627f4robertphillips 384dfe4f2e4fe5b162d4adb4486fe751f1e3b30bea7brianosman sk_sp<SkColorSpace> fColorSpace; 3858db867820bd9cd31b8aea14632a05739f5d44965joshualitt SkSurfaceProps fSurfaceProps; 3868db867820bd9cd31b8aea14632a05739f5d44965joshualitt GrAuditTrail* fAuditTrail; 3871de610a5287cf61d4f3a1fdc7413bd74827a8b6ajoshualitt 3881de610a5287cf61d4f3a1fdc7413bd74827a8b6ajoshualitt // In debug builds we guard against improper thread handling 3896d0872d9bd97de5301214a258e141dd5fbeecffcjoshualitt SkDEBUGCODE(mutable GrSingleOwner* fSingleOwner;) 390ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips}; 391ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips 392ea4615034498aca2f9ca1753fb9a1ef10508d8ccrobertphillips#endif 393