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.
|
|
|
|
*/
|
|
|
|
|
2016-10-27 18:47:55 +00:00
|
|
|
#ifndef GrRenderTargetContext_DEFINED
|
|
|
|
#define GrRenderTargetContext_DEFINED
|
2015-05-26 18:38:03 +00:00
|
|
|
|
|
|
|
#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"
|
2016-11-23 14:37:01 +00:00
|
|
|
#include "GrSurfaceContext.h"
|
2015-05-26 18:38:03 +00:00
|
|
|
#include "SkRefCnt.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-10-28 17:25:24 +00:00
|
|
|
#include "../private/GrRenderTargetProxy.h"
|
2015-05-26 18:38:03 +00:00
|
|
|
|
|
|
|
class GrClip;
|
2015-10-17 14:43:27 +00:00
|
|
|
class GrDrawingManager;
|
2016-12-01 15:59:09 +00:00
|
|
|
class GrDrawOp;
|
2016-08-31 18:55:52 +00:00
|
|
|
class GrFixedClip;
|
2015-05-26 18:38:03 +00:00
|
|
|
class GrPipelineBuilder;
|
|
|
|
class GrRenderTarget;
|
2016-11-23 14:37:01 +00:00
|
|
|
class GrRenderTargetContextPriv;
|
2016-10-25 18:20:06 +00:00
|
|
|
class GrRenderTargetOpList;
|
2016-05-10 16:14:17 +00:00
|
|
|
class GrStyle;
|
2015-05-26 18:38:03 +00:00
|
|
|
class GrSurface;
|
2016-11-08 13:49:39 +00:00
|
|
|
class GrTextureProxy;
|
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;
|
2016-11-23 14:37:01 +00:00
|
|
|
class SkRegion;
|
2015-05-26 18:38:03 +00:00
|
|
|
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
|
|
|
|
2016-11-23 14:37:01 +00:00
|
|
|
/**
|
|
|
|
* A helper object to orchestrate commands (draws, etc...) for GrSurfaces that are GrRenderTargets.
|
2015-05-26 18:38:03 +00:00
|
|
|
*/
|
2016-11-23 14:37:01 +00:00
|
|
|
class SK_API GrRenderTargetContext : public GrSurfaceContext {
|
2015-05-26 18:38:03 +00:00
|
|
|
public:
|
2016-10-27 18:47:55 +00:00
|
|
|
~GrRenderTargetContext() override;
|
2015-06-17 12:43:33 +00:00
|
|
|
|
2016-11-23 14:37:01 +00:00
|
|
|
bool copySurface(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint) override;
|
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-11-17 20:27:09 +00:00
|
|
|
/**
|
|
|
|
* Draw a roundrect using a paint and a shadow shader. This is separate from drawRRect
|
|
|
|
* because it uses different underlying geometry and GeometryProcessor
|
|
|
|
*
|
|
|
|
* @param paint describes how to color pixels.
|
|
|
|
* @param viewMatrix transformation matrix
|
|
|
|
* @param rrect the roundrect to draw
|
|
|
|
* @param blurRadius amount of shadow blur to apply (in device space)
|
|
|
|
* @param style style to apply to the rrect. Currently path effects are not allowed.
|
|
|
|
*/
|
|
|
|
void drawShadowRRect(const GrClip&,
|
|
|
|
const GrPaint&,
|
|
|
|
const SkMatrix& viewMatrix,
|
|
|
|
const SkRRect& rrect,
|
|
|
|
SkScalar blurRadius,
|
|
|
|
const GrStyle& style);
|
|
|
|
|
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
|
|
|
/**
|
2016-10-27 18:47:55 +00:00
|
|
|
* Reads a rectangle of pixels from the render target context.
|
2016-08-31 21:54:15 +00:00
|
|
|
* @param dstInfo image info for the destination
|
|
|
|
* @param dstBuffer destination pixels for the read
|
|
|
|
* @param dstRowBytes bytes in a row of 'dstBuffer'
|
2016-10-27 18:47:55 +00:00
|
|
|
* @param x x offset w/in the render target context from which to read
|
|
|
|
* @param y y offset w/in the render target context from which to read
|
2016-08-31 21:54:15 +00:00
|
|
|
*
|
|
|
|
* @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
|
2016-10-27 18:47:55 +00:00
|
|
|
* renderTargetContext at the specified position.
|
2016-08-31 21:54:15 +00:00
|
|
|
* @param srcInfo image info for the source pixels
|
|
|
|
* @param srcBuffer source for the write
|
|
|
|
* @param srcRowBytes bytes in a row of 'srcBuffer'
|
2016-10-27 18:47:55 +00:00
|
|
|
* @param x x offset w/in the render target context at which to write
|
|
|
|
* @param y y offset w/in the render target context at which to write
|
2016-08-31 21:54:15 +00:00
|
|
|
*
|
|
|
|
* @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 {
|
2016-10-28 17:25:24 +00:00
|
|
|
return fRenderTargetProxy->isStencilBufferMultisampled();
|
2016-06-03 17:59:20 +00:00
|
|
|
}
|
2016-10-28 17:25:24 +00:00
|
|
|
bool isUnifiedMultisampled() const { return fRenderTargetProxy->isUnifiedMultisampled(); }
|
|
|
|
bool hasMixedSamples() const { return fRenderTargetProxy->isMixedSampled(); }
|
2016-05-19 21:01:05 +00:00
|
|
|
|
2016-06-08 17:08:43 +00:00
|
|
|
bool mustUseHWAA(const GrPaint& paint) const {
|
2016-10-28 17:25:24 +00:00
|
|
|
return paint.isAntiAlias() && fRenderTargetProxy->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-10-28 17:25:24 +00:00
|
|
|
const GrSurfaceDesc& desc() const { return fRenderTargetProxy->desc(); }
|
|
|
|
int width() const { return fRenderTargetProxy->width(); }
|
|
|
|
int height() const { return fRenderTargetProxy->height(); }
|
|
|
|
GrPixelConfig config() const { return fRenderTargetProxy->config(); }
|
|
|
|
int numColorSamples() const { return fRenderTargetProxy->numColorSamples(); }
|
2016-07-26 17:21:54 +00:00
|
|
|
bool isGammaCorrect() const { return SkToBool(fColorSpace.get()); }
|
2016-11-08 22:08:54 +00:00
|
|
|
SkDestinationSurfaceColorMode colorMode() const {
|
|
|
|
return this->isGammaCorrect() ? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware
|
|
|
|
: SkDestinationSurfaceColorMode::kLegacy;
|
2016-07-25 19:31:51 +00:00
|
|
|
}
|
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-10-28 17:25:24 +00:00
|
|
|
GrSurfaceOrigin origin() const { return fRenderTargetProxy->origin(); }
|
2015-12-01 20:51:26 +00:00
|
|
|
|
2016-05-16 16:14:53 +00:00
|
|
|
bool wasAbandoned() const;
|
|
|
|
|
2016-11-08 13:49:39 +00:00
|
|
|
GrRenderTarget* instantiate();
|
|
|
|
|
2016-10-28 17:25:24 +00:00
|
|
|
GrRenderTarget* accessRenderTarget() {
|
|
|
|
// TODO: usage of this entry point needs to be reduced and potentially eliminated
|
|
|
|
// since it ends the deferral of the GrRenderTarget's allocation
|
|
|
|
return fRenderTargetProxy->instantiate(fContext->textureProvider());
|
|
|
|
}
|
2016-04-27 17:47:51 +00:00
|
|
|
|
2016-11-08 13:49:39 +00:00
|
|
|
GrTextureProxy* asDeferredTexture();
|
|
|
|
|
2016-10-28 17:25:24 +00:00
|
|
|
sk_sp<GrTexture> asTexture() {
|
2016-11-17 15:22:48 +00:00
|
|
|
if (!this->accessRenderTarget()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-10-28 17:25:24 +00:00
|
|
|
// TODO: usage of this entry point needs to be reduced and potentially eliminated
|
|
|
|
// since it ends the deferral of the GrRenderTarget's allocation
|
2016-11-08 13:49:39 +00:00
|
|
|
// It's usage should migrate to asDeferredTexture
|
2016-10-28 17:25:24 +00:00
|
|
|
return sk_ref_sp(this->accessRenderTarget()->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.
|
2016-10-27 19:13:22 +00:00
|
|
|
GrRenderTargetContextPriv priv();
|
|
|
|
const GrRenderTargetContextPriv priv() const;
|
2016-01-13 15:47:38 +00:00
|
|
|
|
2016-11-08 13:49:39 +00:00
|
|
|
bool isWrapped_ForTesting() const;
|
|
|
|
|
2016-11-24 00:37:13 +00:00
|
|
|
// These two methods return the worst case size of the backing GPU resource when it is
|
|
|
|
// finally allocated. In the approx-match case the allocated size could be smaller than
|
|
|
|
// what is reported by these entry points (i.e., Ganesh could, optionally, return an
|
|
|
|
// exact match)
|
|
|
|
int worstCaseWidth() const { return fRenderTargetProxy->worstCaseWidth(); }
|
|
|
|
int worstCaseHeight() const { return fRenderTargetProxy->worstCaseHeight(); }
|
|
|
|
|
2016-02-16 18:36:53 +00:00
|
|
|
protected:
|
2016-10-28 17:25:24 +00:00
|
|
|
GrRenderTargetContext(GrContext*, GrDrawingManager*, sk_sp<GrRenderTargetProxy>,
|
|
|
|
sk_sp<SkColorSpace>, 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
|
|
|
|
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-10-27 18:47:55 +00:00
|
|
|
friend class GrRenderTargetContextPriv;
|
2016-10-25 18:20:06 +00:00
|
|
|
friend class GrTestTarget; // for access to getOpList
|
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
|
2016-10-25 18:20:06 +00:00
|
|
|
// the GrOpList.
|
2016-12-01 15:59:09 +00:00
|
|
|
void drawBatch(const GrPipelineBuilder& pipelineBuilder, const GrClip&, GrDrawOp* batch);
|
2015-06-17 12:43:33 +00:00
|
|
|
|
2016-10-25 18:20:06 +00:00
|
|
|
GrRenderTargetOpList* getOpList();
|
2015-10-16 16:07:06 +00:00
|
|
|
|
2016-09-16 18:01:27 +00:00
|
|
|
GrDrawingManager* fDrawingManager;
|
2016-10-28 17:25:24 +00:00
|
|
|
sk_sp<GrRenderTargetProxy> fRenderTargetProxy;
|
2015-10-16 16:07:06 +00:00
|
|
|
|
2016-10-27 18:47:55 +00:00
|
|
|
// In MDB-mode the GrOpList can be closed by some other renderTargetContext that has picked
|
2016-10-25 18:20:06 +00:00
|
|
|
// it up. For this reason, the GrOpList should only ever be accessed via 'getOpList'.
|
|
|
|
GrRenderTargetOpList* fOpList;
|
2016-09-16 18:01:27 +00:00
|
|
|
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;
|
2015-05-26 18:38:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|