Chromium Code Reviews| Index: src/gpu/GrDrawContext.h |
| diff --git a/src/gpu/GrDrawContext.h b/src/gpu/GrDrawContext.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d421afdf6e7f6a5d39559b882cfac698ca0c4222 |
| --- /dev/null |
| +++ b/src/gpu/GrDrawContext.h |
| @@ -0,0 +1,254 @@ |
| +/* |
|
bsalomon
2015/05/22 20:33:58
does this file need to be in include/gpu for imple
robertphillips
2015/05/26 16:12:59
Done. :(
|
| + * 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 GrDawContext_DEFINED |
| +#define GrDrawContext_DEFINED |
| + |
| +#include "GrColor.h" |
| +#include "SkRefCnt.h" |
| +#include "GrDrawTarget.h" // TODO: remove this |
| + |
| +class GrAARectRenderer; |
|
bsalomon
2015/05/22 20:33:58
need all this?
robertphillips
2015/05/26 16:12:59
Done.
|
| +class GrBatch; |
| +class GrContext; |
| +class GrClip; |
| +class GrDrawTarget; |
| +class GrOvalRenderer; |
|
bsalomon
2015/05/22 20:33:58
or this?
robertphillips
2015/05/26 16:12:59
Done.
|
| +class GrPaint; |
| +class GrPathProcessor; |
| +class GrPathRange; |
| +class GrPipelineBuilder; |
| +class GrRenderTarget; |
| +class GrStrokeInfo; |
| +class GrSurface; |
| +struct SkIPoint; |
| +struct SkIRect; |
| +class SkMatrix; |
| +class SkPath; |
| +struct SkPoint; |
| +struct SkRect; |
| +class SkRRect; |
| + |
| +/* |
| + * A helper object to orchestrate draws |
| + */ |
| +class GrDrawContext : public SkRefCnt { |
| +public: |
| + SK_DECLARE_INST_COUNT(GrDrawContext) |
| + |
| + void copySurface(GrRenderTarget* dst, GrSurface* src, |
| + const SkIRect& srcRect, const SkIPoint& dstPoint); |
| + |
| + // drawText and drawPaths are thanks to the GrAtlasTextContext and the |
| + // GrStencilAndCoverTextContext respectively |
| + // TODO: remove these two |
| + void drawText(GrPipelineBuilder* pipelineBuilder, GrBatch* batch); |
|
bsalomon
2015/05/22 20:33:58
e-gads! pipelinebuilders have escaped the zoo!
robertphillips
2015/05/26 16:12:59
Short term only.
|
| + |
| + void drawPaths(GrPipelineBuilder* pipelineBuilder, |
| + const GrPathProcessor* pathProc, |
| + const GrPathRange* pathRange, |
| + const void* indices, |
| + GrDrawTarget::PathIndexType indexType, |
| + const float transformValues[], |
| + GrDrawTarget::PathTransformType transformType, |
| + int count, |
| + GrPathRendering::FillType fill); |
| + |
| + /** |
| + * Provides a perfomance hint that the render target's contents are allowed |
| + * to become undefined. |
| + */ |
| + void discard(GrRenderTarget*); |
| + |
| + /** |
| + * Clear the entire or rect of the render target, ignoring any clips. |
| + * @param target The render target to clear. |
| + * @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 |
| + */ |
| + void clear(GrRenderTarget*, const SkIRect* rect, GrColor color, bool canIgnoreRect); |
| + |
| + /** |
| + * Draw everywhere (respecting the clip) with the paint. |
| + */ |
| + void drawPaint(GrRenderTarget*, const GrClip&, const GrPaint&, const SkMatrix& viewMatrix); |
| + |
| + /** |
| + * Draw the rect using a paint. |
| + * @param paint describes how to color pixels. |
| + * @param viewMatrix transformation matrix |
| + * @param strokeInfo the stroke information (width, join, cap), and. |
| + * the dash information (intervals, count, phase). |
| + * If strokeInfo == NULL, then the rect is filled. |
| + * Otherwise, if stroke width == 0, then the stroke |
| + * is always a single pixel thick, else the rect is |
| + * mitered/beveled stroked based on stroke width. |
| + * The rects coords are used to access the paint (through texture matrix) |
| + */ |
| + void drawRect(GrRenderTarget*, |
| + const GrClip&, |
| + const GrPaint& paint, |
| + const SkMatrix& viewMatrix, |
| + const SkRect&, |
| + const GrStrokeInfo* strokeInfo = NULL); |
| + |
| + /** |
| + * Maps a rectangle of shader coordinates to a rectangle and draws that rectangle |
| + * |
| + * @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 |
| + * @param localMatrix an optional matrix to transform the shader coordinates before applying |
| + * to rectToDraw |
| + */ |
| + void drawNonAARectToRect(GrRenderTarget*, |
| + const GrClip&, |
| + const GrPaint& paint, |
| + const SkMatrix& viewMatrix, |
| + const SkRect& rectToDraw, |
| + const SkRect& localRect, |
| + const SkMatrix* localMatrix = NULL); |
| + |
| + /** |
| + * Draws a non-AA rect with paint and a localMatrix |
| + */ |
| + void drawNonAARectWithLocalMatrix(GrRenderTarget* rt, |
| + const GrClip& clip, |
| + const GrPaint& paint, |
| + const SkMatrix& viewMatrix, |
| + const SkRect& rect, |
| + const SkMatrix& localMatrix) { |
| + this->drawNonAARectToRect(rt, clip, paint, viewMatrix, rect, rect, &localMatrix); |
| + } |
| + |
| + /** |
| + * Draw a roundrect using a paint. |
| + * |
| + * @param paint describes how to color pixels. |
| + * @param viewMatrix transformation matrix |
| + * @param rrect the roundrect to draw |
| + * @param strokeInfo the stroke information (width, join, cap) and |
| + * the dash information (intervals, count, phase). |
| + */ |
| + void drawRRect(GrRenderTarget*, |
| + const GrClip&, |
| + const GrPaint&, |
| + const SkMatrix& viewMatrix, |
| + const SkRRect& rrect, |
| + const GrStrokeInfo&); |
| + |
| + /** |
| + * 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(GrRenderTarget*, |
| + const GrClip&, |
| + const GrPaint&, |
| + const SkMatrix& viewMatrix, |
| + const SkRRect& outer, |
| + const SkRRect& inner); |
| + |
| + |
| + /** |
| + * Draws a path. |
| + * |
| + * @param paint describes how to color pixels. |
| + * @param viewMatrix transformation matrix |
| + * @param path the path to draw |
| + * @param strokeInfo the stroke information (width, join, cap) and |
| + * the dash information (intervals, count, phase). |
| + */ |
| + void drawPath(GrRenderTarget*, |
| + const GrClip&, |
| + const GrPaint&, |
| + const SkMatrix& viewMatrix, |
| + const SkPath&, |
| + const GrStrokeInfo&); |
| + |
| + /** |
| + * 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. |
| + */ |
| + void drawVertices(GrRenderTarget*, |
| + const GrClip&, |
| + 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); |
| + |
| + /** |
| + * Draws an oval. |
| + * |
| + * @param paint describes how to color pixels. |
| + * @param viewMatrix transformation matrix |
| + * @param oval the bounding rect of the oval. |
| + * @param strokeInfo the stroke information (width, join, cap) and |
| + * the dash information (intervals, count, phase). |
| + */ |
| + void drawOval(GrRenderTarget*, |
| + const GrClip&, |
| + const GrPaint& paint, |
| + const SkMatrix& viewMatrix, |
| + const SkRect& oval, |
| + const GrStrokeInfo& strokeInfo); |
| + |
| + |
| +private: |
| + friend class GrContext; // for ctor |
| + |
| + GrDrawContext(GrContext* context, GrDrawTarget* drawTarget); |
| + |
| + // Sets the paint. Returns true on success; false on failure. |
| + bool prepareToDraw(GrPipelineBuilder*, |
| + GrRenderTarget* rt, |
| + const GrClip&, |
| + const GrPaint* paint); |
| + |
| + // A simpler version of the above which just returns true on success; false on failure. |
| + // Clip is *NOT* set |
| + bool prepareToDraw(GrRenderTarget* rt); |
| + |
| + void internalDrawPath(GrDrawTarget*, |
| + GrPipelineBuilder*, |
| + const SkMatrix& viewMatrix, |
| + GrColor, |
| + bool useAA, |
| + const SkPath&, |
| + const GrStrokeInfo&); |
| + |
| + GrContext* fContext; // owning context -> no ref |
| + SkAutoTUnref<GrDrawTarget> fDrawTarget; |
| +}; |
| + |
| +#endif |