2015-05-26 18:38:03 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2015 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GrDrawContext_DEFINED
|
|
|
|
#define GrDrawContext_DEFINED
|
|
|
|
|
|
|
|
#include "GrColor.h"
|
2016-09-16 16:53:27 +00:00
|
|
|
#include "GrContext.h"
|
2016-06-08 17:08:43 +00:00
|
|
|
#include "GrPaint.h"
|
2015-12-01 20:51:26 +00:00
|
|
|
#include "GrRenderTarget.h"
|
2015-05-26 18:38:03 +00:00
|
|
|
#include "SkRefCnt.h"
|
2016-03-02 17:26:36 +00:00
|
|
|
#include "SkRegion.h"
|
2015-06-19 18:49:52 +00:00
|
|
|
#include "SkSurfaceProps.h"
|
Begin instanced rendering for simple shapes
Adds a module that performs instanced rendering and starts using it
for a select subset of draws on Mac GL platforms. The instance
processor can currently handle rects, ovals, round rects, and double
round rects. It can generalize shapes as round rects in order to
improve batching. The instance processor also employs new drawing
algorithms, irrespective of instanced rendering, that improve GPU-side
performance (e.g. sample mask, different triangle layouts, etc.).
This change only scratches the surface of instanced rendering. The
majority of draws still only have one instance. Future work may
include:
* Passing coord transforms through the texel buffer.
* Sending FP uniforms through instanced vertex attribs.
* Using instanced rendering for more draws (stencil writes,
drawAtlas, etc.).
* Adding more shapes to the instance processor’s repertoire.
* Batching draws that have mismatched scissors (analyzing draw
bounds, inserting clip planes, etc.).
* Bindless textures.
* Uber shaders.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2066993003
Committed: https://skia.googlesource.com/skia/+/42eafa4bc00354b132ad114d22ed6b95d8849891
Review-Url: https://codereview.chromium.org/2066993003
2016-07-07 15:49:11 +00:00
|
|
|
#include "../private/GrInstancedPipelineInfo.h"
|
2016-01-06 16:26:09 +00:00
|
|
|
#include "../private/GrSingleOwner.h"
|
2015-05-26 18:38:03 +00:00
|
|
|
|
2016-01-13 14:45:40 +00:00
|
|
|
class GrAuditTrail;
|
2015-05-26 18:38:03 +00:00
|
|
|
class GrClip;
|
2015-08-13 20:34:48 +00:00
|
|
|
class GrDrawBatch;
|
2016-03-02 17:26:36 +00:00
|
|
|
class GrDrawContextPriv;
|
2015-12-08 18:20:32 +00:00
|
|
|
class GrDrawPathBatchBase;
|
2015-10-17 14:43:27 +00:00
|
|
|
class GrDrawingManager;
|
2015-05-26 18:38:03 +00:00
|
|
|
class GrDrawTarget;
|
2016-08-31 18:55:52 +00:00
|
|
|
class GrFixedClip;
|
2015-05-26 18:38:03 +00:00
|
|
|
class GrPaint;
|
|
|
|
class GrPathProcessor;
|
|
|
|
class GrPipelineBuilder;
|
|
|
|
class GrRenderTarget;
|
2016-05-10 16:14:17 +00:00
|
|
|
class GrStyle;
|
2015-05-26 18:38:03 +00:00
|
|
|
class GrSurface;
|
2016-07-08 21:43:03 +00:00
|
|
|
struct GrUserStencilSettings;
|
2015-06-17 12:43:33 +00:00
|
|
|
class SkDrawFilter;
|
2015-05-26 18:38:03 +00:00
|
|
|
struct SkIPoint;
|
|
|
|
struct SkIRect;
|
Batched implementation of drawLattice() for GPU
Bechmarks (Nexus 6P):
Src=100x100, Dst=250x250, NumRects=9
Android 77.7us
Skia (without patch) 57.2us
Skia (with patch) 30.9us
Src=100x100, Dst=500x500, NumRects=9
Android 77.0us
Skia (without patch) 56.9us
Skia (with patch) 31.8us
Src=100x100, Dst=1000x1000, NumRects=9
Android 180us
Skia (without patch) 96.8us
Skia (with patch) 70.5us
Src=100x100, Dst=250x250, NumRects=15
Android 208us
Skia (without patch) 155us
Skia (with patch) 38.2us
Src=100x100, Dst=500x500, NumRects=15
Android 207us
Skia (without patch) 152us
Skia (with patch) 38.4us
Src=100x100, Dst=1000x1000, NumRects=15
Android 233us
Skia (without patch) 156us
Skia (with patch) 99.9us
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2255963002
Committed: https://skia.googlesource.com/skia/+/93242c4ae50dfcc0d922cdb3ba80bbc7b4bbe93d
Review-Url: https://codereview.chromium.org/2255963002
2016-08-18 22:46:03 +00:00
|
|
|
class SkLatticeIter;
|
2015-05-26 18:38:03 +00:00
|
|
|
class SkMatrix;
|
2015-06-17 12:43:33 +00:00
|
|
|
class SkPaint;
|
2015-05-26 18:38:03 +00:00
|
|
|
class SkPath;
|
|
|
|
struct SkPoint;
|
|
|
|
struct SkRect;
|
|
|
|
class SkRRect;
|
2015-08-07 17:09:28 +00:00
|
|
|
struct SkRSXform;
|
2015-06-17 12:43:33 +00:00
|
|
|
class SkTextBlob;
|
2015-05-26 18:38:03 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* A helper object to orchestrate draws
|
|
|
|
*/
|
|
|
|
class SK_API GrDrawContext : public SkRefCnt {
|
|
|
|
public:
|
2015-06-17 12:43:33 +00:00
|
|
|
~GrDrawContext() override;
|
|
|
|
|
2016-02-16 15:34:17 +00:00
|
|
|
bool copySurface(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint);
|
2015-05-26 18:38:03 +00:00
|
|
|
|
2015-06-17 12:43:33 +00:00
|
|
|
// TODO: it is odd that we need both the SkPaint in the following 3 methods.
|
|
|
|
// We should extract the text parameters from SkPaint and pass them separately
|
2016-05-10 16:14:17 +00:00
|
|
|
// akin to GrStyle (GrTextInfo?)
|
2016-02-16 18:36:53 +00:00
|
|
|
virtual void drawText(const GrClip&, const GrPaint&, const SkPaint&,
|
|
|
|
const SkMatrix& viewMatrix, const char text[], size_t byteLength,
|
|
|
|
SkScalar x, SkScalar y, const SkIRect& clipBounds);
|
|
|
|
virtual void drawPosText(const GrClip&, const GrPaint&, const SkPaint&,
|
|
|
|
const SkMatrix& viewMatrix, const char text[], size_t byteLength,
|
|
|
|
const SkScalar pos[], int scalarsPerPosition,
|
|
|
|
const SkPoint& offset, const SkIRect& clipBounds);
|
|
|
|
virtual void drawTextBlob(const GrClip&, const SkPaint&,
|
|
|
|
const SkMatrix& viewMatrix, const SkTextBlob*,
|
|
|
|
SkScalar x, SkScalar y,
|
|
|
|
SkDrawFilter*, const SkIRect& clipBounds);
|
2015-05-26 18:38:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Provides a perfomance hint that the render target's contents are allowed
|
|
|
|
* to become undefined.
|
|
|
|
*/
|
2015-10-15 15:01:48 +00:00
|
|
|
void discard();
|
2015-05-26 18:38:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Clear the entire or rect of the render target, ignoring any clips.
|
|
|
|
* @param rect the rect to clear or the whole thing if rect is NULL.
|
|
|
|
* @param color the color to clear to.
|
|
|
|
* @param canIgnoreRect allows partial clears to be converted to whole
|
|
|
|
* clears on platforms for which that is cheap
|
|
|
|
*/
|
2015-10-15 15:01:48 +00:00
|
|
|
void clear(const SkIRect* rect, GrColor color, bool canIgnoreRect);
|
2015-05-26 18:38:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw everywhere (respecting the clip) with the paint.
|
|
|
|
*/
|
2015-10-15 15:01:48 +00:00
|
|
|
void drawPaint(const GrClip&, const GrPaint&, const SkMatrix& viewMatrix);
|
2015-05-26 18:38:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw the rect using a paint.
|
|
|
|
* @param paint describes how to color pixels.
|
|
|
|
* @param viewMatrix transformation matrix
|
2016-05-10 16:14:17 +00:00
|
|
|
* @param style The style to apply. Null means fill. Currently path effects are not
|
|
|
|
* allowed.
|
2015-05-26 18:38:03 +00:00
|
|
|
* The rects coords are used to access the paint (through texture matrix)
|
|
|
|
*/
|
2015-10-15 15:01:48 +00:00
|
|
|
void drawRect(const GrClip&,
|
2015-05-26 18:38:03 +00:00
|
|
|
const GrPaint& paint,
|
|
|
|
const SkMatrix& viewMatrix,
|
|
|
|
const SkRect&,
|
2016-05-10 16:14:17 +00:00
|
|
|
const GrStyle* style = nullptr);
|
2015-05-26 18:38:03 +00:00
|
|
|
|
|
|
|
/**
|
2015-11-05 18:41:43 +00:00
|
|
|
* Maps a rectangle of shader coordinates to a rectangle and fills that rectangle.
|
2015-05-26 18:38:03 +00:00
|
|
|
*
|
|
|
|
* @param paint describes how to color pixels.
|
|
|
|
* @param viewMatrix transformation matrix which applies to rectToDraw
|
|
|
|
* @param rectToDraw the rectangle to draw
|
|
|
|
* @param localRect the rectangle of shader coordinates applied to rectToDraw
|
|
|
|
*/
|
2015-11-05 18:41:43 +00:00
|
|
|
void fillRectToRect(const GrClip&,
|
|
|
|
const GrPaint& paint,
|
|
|
|
const SkMatrix& viewMatrix,
|
|
|
|
const SkRect& rectToDraw,
|
|
|
|
const SkRect& localRect);
|
2015-05-26 18:38:03 +00:00
|
|
|
|
|
|
|
/**
|
2015-11-05 18:41:43 +00:00
|
|
|
* Fills a rect with a paint and a localMatrix.
|
2015-05-26 18:38:03 +00:00
|
|
|
*/
|
2015-11-05 18:41:43 +00:00
|
|
|
void fillRectWithLocalMatrix(const GrClip& clip,
|
|
|
|
const GrPaint& paint,
|
|
|
|
const SkMatrix& viewMatrix,
|
|
|
|
const SkRect& rect,
|
|
|
|
const SkMatrix& localMatrix);
|
2015-05-26 18:38:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw a roundrect using a paint.
|
|
|
|
*
|
|
|
|
* @param paint describes how to color pixels.
|
|
|
|
* @param viewMatrix transformation matrix
|
|
|
|
* @param rrect the roundrect to draw
|
2016-05-10 16:14:17 +00:00
|
|
|
* @param style style to apply to the rrect. Currently path effects are not allowed.
|
2015-05-26 18:38:03 +00:00
|
|
|
*/
|
2015-10-15 15:01:48 +00:00
|
|
|
void drawRRect(const GrClip&,
|
2015-05-26 18:38:03 +00:00
|
|
|
const GrPaint&,
|
|
|
|
const SkMatrix& viewMatrix,
|
|
|
|
const SkRRect& rrect,
|
2016-05-10 16:14:17 +00:00
|
|
|
const GrStyle& style);
|
2015-05-26 18:38:03 +00:00
|
|
|
|
2016-02-29 21:50:40 +00:00
|
|
|
/**
|
|
|
|
* Shortcut for drawing an SkPath consisting of nested rrects using a paint.
|
|
|
|
* Does not support stroking. The result is undefined if outer does not contain
|
|
|
|
* inner.
|
|
|
|
*
|
|
|
|
* @param paint describes how to color pixels.
|
|
|
|
* @param viewMatrix transformation matrix
|
|
|
|
* @param outer the outer roundrect
|
|
|
|
* @param inner the inner roundrect
|
|
|
|
*/
|
|
|
|
void drawDRRect(const GrClip&,
|
|
|
|
const GrPaint&,
|
|
|
|
const SkMatrix& viewMatrix,
|
|
|
|
const SkRRect& outer,
|
|
|
|
const SkRRect& inner);
|
|
|
|
|
2015-05-26 18:38:03 +00:00
|
|
|
/**
|
|
|
|
* Draws a path.
|
|
|
|
*
|
|
|
|
* @param paint describes how to color pixels.
|
|
|
|
* @param viewMatrix transformation matrix
|
|
|
|
* @param path the path to draw
|
2016-05-10 16:14:17 +00:00
|
|
|
* @param style style to apply to the path.
|
2015-05-26 18:38:03 +00:00
|
|
|
*/
|
2015-10-15 15:01:48 +00:00
|
|
|
void drawPath(const GrClip&,
|
2015-05-26 18:38:03 +00:00
|
|
|
const GrPaint&,
|
|
|
|
const SkMatrix& viewMatrix,
|
|
|
|
const SkPath&,
|
2016-05-10 16:14:17 +00:00
|
|
|
const GrStyle& style);
|
2015-05-26 18:38:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Draws vertices with a paint.
|
|
|
|
*
|
|
|
|
* @param paint describes how to color pixels.
|
|
|
|
* @param viewMatrix transformation matrix
|
|
|
|
* @param primitiveType primitives type to draw.
|
|
|
|
* @param vertexCount number of vertices.
|
|
|
|
* @param positions array of vertex positions, required.
|
|
|
|
* @param texCoords optional array of texture coordinates used
|
|
|
|
* to access the paint.
|
|
|
|
* @param colors optional array of per-vertex colors, supercedes
|
|
|
|
* the paint's color field.
|
|
|
|
* @param indices optional array of indices. If NULL vertices
|
|
|
|
* are drawn non-indexed.
|
|
|
|
* @param indexCount if indices is non-null then this is the
|
|
|
|
* number of indices.
|
|
|
|
*/
|
2015-10-15 15:01:48 +00:00
|
|
|
void drawVertices(const GrClip&,
|
2015-05-26 18:38:03 +00:00
|
|
|
const GrPaint& paint,
|
|
|
|
const SkMatrix& viewMatrix,
|
|
|
|
GrPrimitiveType primitiveType,
|
|
|
|
int vertexCount,
|
|
|
|
const SkPoint positions[],
|
|
|
|
const SkPoint texs[],
|
|
|
|
const GrColor colors[],
|
|
|
|
const uint16_t indices[],
|
|
|
|
int indexCount);
|
|
|
|
|
2015-08-07 17:09:28 +00:00
|
|
|
/**
|
|
|
|
* Draws textured sprites from an atlas with a paint.
|
|
|
|
*
|
|
|
|
* @param paint describes how to color pixels.
|
|
|
|
* @param viewMatrix transformation matrix
|
|
|
|
* @param spriteCount number of sprites.
|
|
|
|
* @param xform array of compressed transformation data, required.
|
|
|
|
* @param texRect array of texture rectangles used to access the paint.
|
|
|
|
* @param colors optional array of per-sprite colors, supercedes
|
|
|
|
* the paint's color field.
|
|
|
|
*/
|
2015-10-15 15:01:48 +00:00
|
|
|
void drawAtlas(const GrClip&,
|
2015-08-07 17:09:28 +00:00
|
|
|
const GrPaint& paint,
|
|
|
|
const SkMatrix& viewMatrix,
|
|
|
|
int spriteCount,
|
|
|
|
const SkRSXform xform[],
|
|
|
|
const SkRect texRect[],
|
|
|
|
const SkColor colors[]);
|
2016-08-26 01:07:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Draws a region.
|
|
|
|
*
|
|
|
|
* @param paint describes how to color pixels
|
|
|
|
* @param viewMatrix transformation matrix
|
|
|
|
* @param region the region to be drawn
|
|
|
|
* @param style style to apply to the region
|
|
|
|
*/
|
|
|
|
void drawRegion(const GrClip&,
|
|
|
|
const GrPaint& paint,
|
|
|
|
const SkMatrix& viewMatrix,
|
|
|
|
const SkRegion& region,
|
|
|
|
const GrStyle& style);
|
|
|
|
|
2015-05-26 18:38:03 +00:00
|
|
|
/**
|
|
|
|
* Draws an oval.
|
|
|
|
*
|
|
|
|
* @param paint describes how to color pixels.
|
|
|
|
* @param viewMatrix transformation matrix
|
|
|
|
* @param oval the bounding rect of the oval.
|
2016-05-10 16:14:17 +00:00
|
|
|
* @param style style to apply to the oval. Currently path effects are not allowed.
|
2015-05-26 18:38:03 +00:00
|
|
|
*/
|
2015-10-15 15:01:48 +00:00
|
|
|
void drawOval(const GrClip&,
|
2015-05-26 18:38:03 +00:00
|
|
|
const GrPaint& paint,
|
|
|
|
const SkMatrix& viewMatrix,
|
|
|
|
const SkRect& oval,
|
2016-05-10 16:14:17 +00:00
|
|
|
const GrStyle& style);
|
2016-08-22 20:14:26 +00:00
|
|
|
/**
|
|
|
|
* Draws a partial arc of an oval.
|
|
|
|
*
|
|
|
|
* @param paint describes how to color pixels.
|
|
|
|
* @param viewMatrix transformation matrix.
|
|
|
|
* @param oval the bounding rect of the oval.
|
|
|
|
* @param startAngle starting angle in degrees.
|
|
|
|
* @param sweepAngle angle to sweep in degrees. Must be in (-360, 360)
|
|
|
|
* @param useCenter true means that the implied path begins at the oval center, connects as a
|
|
|
|
* line to the point indicated by the start contains the arc indicated by
|
|
|
|
* the sweep angle. If false the line beginning at the center point is
|
|
|
|
* omitted.
|
|
|
|
* @param style style to apply to the oval.
|
|
|
|
*/
|
|
|
|
void drawArc(const GrClip&,
|
|
|
|
const GrPaint& paint,
|
|
|
|
const SkMatrix& viewMatrix,
|
|
|
|
const SkRect& oval,
|
|
|
|
SkScalar startAngle,
|
|
|
|
SkScalar sweepAngle,
|
|
|
|
bool useCenter,
|
|
|
|
const GrStyle& style);
|
2015-05-26 18:38:03 +00:00
|
|
|
|
2015-11-18 21:28:51 +00:00
|
|
|
/**
|
2016-08-22 20:14:26 +00:00
|
|
|
* Draw the image as a set of rects, specified by |iter|.
|
2015-11-18 21:28:51 +00:00
|
|
|
*/
|
Batched implementation of drawLattice() for GPU
Bechmarks (Nexus 6P):
Src=100x100, Dst=250x250, NumRects=9
Android 77.7us
Skia (without patch) 57.2us
Skia (with patch) 30.9us
Src=100x100, Dst=500x500, NumRects=9
Android 77.0us
Skia (without patch) 56.9us
Skia (with patch) 31.8us
Src=100x100, Dst=1000x1000, NumRects=9
Android 180us
Skia (without patch) 96.8us
Skia (with patch) 70.5us
Src=100x100, Dst=250x250, NumRects=15
Android 208us
Skia (without patch) 155us
Skia (with patch) 38.2us
Src=100x100, Dst=500x500, NumRects=15
Android 207us
Skia (without patch) 152us
Skia (with patch) 38.4us
Src=100x100, Dst=1000x1000, NumRects=15
Android 233us
Skia (without patch) 156us
Skia (with patch) 99.9us
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2255963002
Committed: https://skia.googlesource.com/skia/+/93242c4ae50dfcc0d922cdb3ba80bbc7b4bbe93d
Review-Url: https://codereview.chromium.org/2255963002
2016-08-18 22:46:03 +00:00
|
|
|
void drawImageLattice(const GrClip&,
|
|
|
|
const GrPaint& paint,
|
|
|
|
const SkMatrix& viewMatrix,
|
|
|
|
int imageWidth,
|
|
|
|
int imageHeight,
|
|
|
|
std::unique_ptr<SkLatticeIter> iter,
|
|
|
|
const SkRect& dst);
|
2015-05-26 18:38:03 +00:00
|
|
|
|
2016-07-26 14:41:00 +00:00
|
|
|
/**
|
|
|
|
* After this returns any pending surface IO will be issued to the backend 3D API and
|
|
|
|
* if the surface has MSAA it will be resolved.
|
|
|
|
*/
|
|
|
|
void prepareForExternalIO();
|
|
|
|
|
2016-08-31 21:54:15 +00:00
|
|
|
/**
|
|
|
|
* Reads a rectangle of pixels from the draw context.
|
|
|
|
* @param dstInfo image info for the destination
|
|
|
|
* @param dstBuffer destination pixels for the read
|
|
|
|
* @param dstRowBytes bytes in a row of 'dstBuffer'
|
|
|
|
* @param x x offset w/in the draw context from which to read
|
|
|
|
* @param y y offset w/in the draw context from which to read
|
|
|
|
*
|
|
|
|
* @return true if the read succeeded, false if not. The read can fail because of an
|
|
|
|
* unsupported pixel config.
|
|
|
|
*/
|
|
|
|
bool readPixels(const SkImageInfo& dstInfo, void* dstBuffer, size_t dstRowBytes, int x, int y);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Writes a rectangle of pixels [srcInfo, srcBuffer, srcRowbytes] into the
|
|
|
|
* drawContext at the specified position.
|
|
|
|
* @param srcInfo image info for the source pixels
|
|
|
|
* @param srcBuffer source for the write
|
|
|
|
* @param srcRowBytes bytes in a row of 'srcBuffer'
|
|
|
|
* @param x x offset w/in the draw context at which to write
|
|
|
|
* @param y y offset w/in the draw context at which to write
|
|
|
|
*
|
|
|
|
* @return true if the write succeeded, false if not. The write can fail because of an
|
|
|
|
* unsupported pixel config.
|
|
|
|
*/
|
|
|
|
bool writePixels(const SkImageInfo& srcInfo, const void* srcBuffer, size_t srcRowBytes,
|
|
|
|
int x, int y);
|
|
|
|
|
2016-06-03 17:59:20 +00:00
|
|
|
bool isStencilBufferMultisampled() const {
|
|
|
|
return fRenderTarget->isStencilBufferMultisampled();
|
|
|
|
}
|
2016-06-06 13:16:20 +00:00
|
|
|
bool isUnifiedMultisampled() const { return fRenderTarget->isUnifiedMultisampled(); }
|
2016-08-10 18:09:07 +00:00
|
|
|
bool hasMixedSamples() const { return fRenderTarget->isMixedSampled(); }
|
2016-05-19 21:01:05 +00:00
|
|
|
|
2016-06-08 17:08:43 +00:00
|
|
|
bool mustUseHWAA(const GrPaint& paint) const {
|
2016-07-22 14:10:19 +00:00
|
|
|
return paint.isAntiAlias() && fRenderTarget->isUnifiedMultisampled();
|
2016-06-08 17:08:43 +00:00
|
|
|
}
|
|
|
|
|
2016-09-16 16:53:27 +00:00
|
|
|
const GrCaps* caps() const { return fContext->caps(); }
|
2016-05-13 18:20:46 +00:00
|
|
|
const GrSurfaceDesc& desc() const { return fRenderTarget->desc(); }
|
2015-12-01 20:51:26 +00:00
|
|
|
int width() const { return fRenderTarget->width(); }
|
|
|
|
int height() const { return fRenderTarget->height(); }
|
2016-05-17 16:57:46 +00:00
|
|
|
GrPixelConfig config() const { return fRenderTarget->config(); }
|
2015-12-01 20:51:26 +00:00
|
|
|
int numColorSamples() const { return fRenderTarget->numColorSamples(); }
|
2016-07-26 17:21:54 +00:00
|
|
|
bool isGammaCorrect() const { return SkToBool(fColorSpace.get()); }
|
2016-07-25 19:31:51 +00:00
|
|
|
SkSourceGammaTreatment sourceGammaTreatment() const {
|
|
|
|
return this->isGammaCorrect() ? SkSourceGammaTreatment::kRespect
|
|
|
|
: SkSourceGammaTreatment::kIgnore;
|
|
|
|
}
|
2016-05-17 16:57:46 +00:00
|
|
|
const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; }
|
2016-07-21 20:28:36 +00:00
|
|
|
SkColorSpace* getColorSpace() const { return fColorSpace.get(); }
|
2016-09-16 18:01:27 +00:00
|
|
|
GrColorSpaceXform* getColorXformFromSRGB() const { return fColorXformFromSRGB.get(); }
|
2016-07-26 18:38:17 +00:00
|
|
|
GrSurfaceOrigin origin() const { return fRenderTarget->origin(); }
|
2015-12-01 20:51:26 +00:00
|
|
|
|
2016-05-16 16:14:53 +00:00
|
|
|
bool wasAbandoned() const;
|
|
|
|
|
2016-04-27 17:47:51 +00:00
|
|
|
GrRenderTarget* accessRenderTarget() { return fRenderTarget.get(); }
|
|
|
|
|
|
|
|
sk_sp<GrTexture> asTexture() { return sk_ref_sp(fRenderTarget->asTexture()); }
|
2015-12-04 14:58:16 +00:00
|
|
|
|
2016-03-02 17:26:36 +00:00
|
|
|
// Provides access to functions that aren't part of the public API.
|
|
|
|
GrDrawContextPriv drawContextPriv();
|
|
|
|
const GrDrawContextPriv drawContextPriv() const;
|
2016-01-13 15:47:38 +00:00
|
|
|
|
2016-06-03 17:59:20 +00:00
|
|
|
GrAuditTrail* auditTrail() { return fAuditTrail; }
|
|
|
|
|
2016-02-16 18:36:53 +00:00
|
|
|
protected:
|
2016-07-21 20:28:36 +00:00
|
|
|
GrDrawContext(GrContext*, GrDrawingManager*, sk_sp<GrRenderTarget>, sk_sp<SkColorSpace>,
|
2016-02-16 18:36:53 +00:00
|
|
|
const SkSurfaceProps* surfaceProps, GrAuditTrail*, GrSingleOwner*);
|
2015-05-26 18:38:03 +00:00
|
|
|
|
2016-02-16 18:36:53 +00:00
|
|
|
GrDrawingManager* drawingManager() { return fDrawingManager; }
|
2016-05-17 16:57:46 +00:00
|
|
|
|
2016-02-16 18:36:53 +00:00
|
|
|
SkDEBUGCODE(GrSingleOwner* singleOwner() { return fSingleOwner; })
|
2015-10-15 15:01:48 +00:00
|
|
|
SkDEBUGCODE(void validate() const;)
|
2015-05-26 18:38:03 +00:00
|
|
|
|
2016-02-16 18:36:53 +00:00
|
|
|
private:
|
|
|
|
friend class GrAtlasTextBlob; // for access to drawBatch
|
2016-05-12 18:52:02 +00:00
|
|
|
friend class GrStencilAndCoverTextContext; // for access to drawBatch
|
2016-06-06 13:16:20 +00:00
|
|
|
|
2016-02-16 18:36:53 +00:00
|
|
|
friend class GrDrawingManager; // for ctor
|
2016-03-02 17:26:36 +00:00
|
|
|
friend class GrDrawContextPriv;
|
2016-05-20 18:14:33 +00:00
|
|
|
friend class GrTestTarget; // for access to getDrawTarget
|
2016-06-03 17:59:20 +00:00
|
|
|
friend class GrSWMaskHelper; // for access to drawBatch
|
|
|
|
|
|
|
|
// All the path renderers currently make their own batches
|
|
|
|
friend class GrSoftwarePathRenderer; // for access to drawBatch
|
|
|
|
friend class GrAAConvexPathRenderer; // for access to drawBatch
|
|
|
|
friend class GrDashLinePathRenderer; // for access to drawBatch
|
|
|
|
friend class GrAAHairLinePathRenderer; // for access to drawBatch
|
|
|
|
friend class GrAALinearizingConvexPathRenderer; // for access to drawBatch
|
|
|
|
friend class GrAADistanceFieldPathRenderer; // for access to drawBatch
|
|
|
|
friend class GrDefaultPathRenderer; // for access to drawBatch
|
|
|
|
friend class GrPLSPathRenderer; // for access to drawBatch
|
|
|
|
friend class GrMSAAPathRenderer; // for access to drawBatch
|
|
|
|
friend class GrStencilAndCoverPathRenderer; // for access to drawBatch
|
|
|
|
friend class GrTessellatingPathRenderer; // for access to drawBatch
|
2015-05-26 18:38:03 +00:00
|
|
|
|
2016-08-31 18:55:52 +00:00
|
|
|
void internalClear(const GrFixedClip&, const GrColor, bool canIgnoreClip);
|
|
|
|
|
2016-02-29 21:50:40 +00:00
|
|
|
bool drawFilledDRRect(const GrClip& clip,
|
|
|
|
const GrPaint& paint,
|
|
|
|
const SkMatrix& viewMatrix,
|
|
|
|
const SkRRect& origOuter,
|
|
|
|
const SkRRect& origInner);
|
|
|
|
|
2016-07-08 21:43:03 +00:00
|
|
|
bool drawFilledRect(const GrClip& clip,
|
|
|
|
const GrPaint& paint,
|
|
|
|
const SkMatrix& viewMatrix,
|
|
|
|
const SkRect& rect,
|
|
|
|
const GrUserStencilSettings* ss);
|
|
|
|
|
|
|
|
void drawNonAAFilledRect(const GrClip&,
|
|
|
|
const GrPaint&,
|
|
|
|
const SkMatrix& viewMatrix,
|
|
|
|
const SkRect& rect,
|
|
|
|
const SkRect* localRect,
|
|
|
|
const SkMatrix* localMatrix,
|
2016-07-27 20:22:27 +00:00
|
|
|
const GrUserStencilSettings* ss,
|
|
|
|
bool useHWAA);
|
2016-03-02 17:26:36 +00:00
|
|
|
|
2016-03-01 20:22:49 +00:00
|
|
|
void internalDrawPath(const GrClip& clip,
|
|
|
|
const GrPaint& paint,
|
2015-05-26 18:38:03 +00:00
|
|
|
const SkMatrix& viewMatrix,
|
2016-03-01 20:22:49 +00:00
|
|
|
const SkPath& path,
|
2016-05-10 16:14:17 +00:00
|
|
|
const GrStyle& style);
|
2015-05-26 18:38:03 +00:00
|
|
|
|
2015-06-17 12:43:33 +00:00
|
|
|
// This entry point allows the GrTextContext-derived classes to add their batches to
|
|
|
|
// the drawTarget.
|
2016-07-22 14:10:19 +00:00
|
|
|
void drawBatch(const GrPipelineBuilder& pipelineBuilder, const GrClip&, GrDrawBatch* batch);
|
2015-06-17 12:43:33 +00:00
|
|
|
|
2015-10-16 16:07:06 +00:00
|
|
|
GrDrawTarget* getDrawTarget();
|
|
|
|
|
2016-09-16 18:01:27 +00:00
|
|
|
GrDrawingManager* fDrawingManager;
|
|
|
|
sk_sp<GrRenderTarget> fRenderTarget;
|
2015-10-16 16:07:06 +00:00
|
|
|
|
|
|
|
// In MDB-mode the drawTarget can be closed by some other drawContext that has picked
|
|
|
|
// it up. For this reason, the drawTarget should only ever be accessed via 'getDrawTarget'.
|
2016-09-16 18:01:27 +00:00
|
|
|
GrDrawTarget* fDrawTarget;
|
|
|
|
GrContext* fContext;
|
|
|
|
GrInstancedPipelineInfo fInstancedPipelineInfo;
|
2015-06-17 12:43:33 +00:00
|
|
|
|
2016-09-16 18:01:27 +00:00
|
|
|
sk_sp<SkColorSpace> fColorSpace;
|
|
|
|
sk_sp<GrColorSpaceXform> fColorXformFromSRGB;
|
|
|
|
SkSurfaceProps fSurfaceProps;
|
|
|
|
GrAuditTrail* fAuditTrail;
|
2016-01-06 16:26:09 +00:00
|
|
|
|
|
|
|
// In debug builds we guard against improper thread handling
|
2016-09-16 18:01:27 +00:00
|
|
|
SkDEBUGCODE(mutable GrSingleOwner* fSingleOwner;)
|
2015-05-26 18:38:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|