Expand functionality of GrRectBatchFactory with AARects
BUG=skia: Review URL: https://codereview.chromium.org/1279303002
This commit is contained in:
parent
fb69bb3a5e
commit
14205b114a
@ -65,8 +65,6 @@
|
|||||||
'<(skia_src_path)/gpu/GrAAConvexTessellator.h',
|
'<(skia_src_path)/gpu/GrAAConvexTessellator.h',
|
||||||
'<(skia_src_path)/gpu/GrAADistanceFieldPathRenderer.cpp',
|
'<(skia_src_path)/gpu/GrAADistanceFieldPathRenderer.cpp',
|
||||||
'<(skia_src_path)/gpu/GrAADistanceFieldPathRenderer.h',
|
'<(skia_src_path)/gpu/GrAADistanceFieldPathRenderer.h',
|
||||||
'<(skia_src_path)/gpu/GrAARectRenderer.cpp',
|
|
||||||
'<(skia_src_path)/gpu/GrAARectRenderer.h',
|
|
||||||
'<(skia_src_path)/gpu/GrAddPathRenderers_default.cpp',
|
'<(skia_src_path)/gpu/GrAddPathRenderers_default.cpp',
|
||||||
'<(skia_src_path)/gpu/GrAutoLocaleSetter.h',
|
'<(skia_src_path)/gpu/GrAutoLocaleSetter.h',
|
||||||
'<(skia_src_path)/gpu/GrAllocator.h',
|
'<(skia_src_path)/gpu/GrAllocator.h',
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include "SkPathEffect.h"
|
#include "SkPathEffect.h"
|
||||||
#include "SkTypes.h"
|
#include "SkTypes.h"
|
||||||
|
|
||||||
class GrAARectRenderer;
|
|
||||||
class GrBatchFontCache;
|
class GrBatchFontCache;
|
||||||
class GrCaps;
|
class GrCaps;
|
||||||
struct GrContextOptions;
|
struct GrContextOptions;
|
||||||
|
@ -1,143 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012 Google Inc.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
|
||||||
* found in the LICENSE file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "GrAARectRenderer.h"
|
|
||||||
#include "GrBatchTarget.h"
|
|
||||||
#include "GrBatchTest.h"
|
|
||||||
#include "GrContext.h"
|
|
||||||
#include "GrDrawTarget.h"
|
|
||||||
#include "GrGeometryProcessor.h"
|
|
||||||
#include "GrInvariantOutput.h"
|
|
||||||
#include "GrTestUtils.h"
|
|
||||||
#include "GrVertexBuffer.h"
|
|
||||||
#include "SkColorPriv.h"
|
|
||||||
#include "batches/GrAAFillRectBatch.h"
|
|
||||||
#include "batches/GrAAStrokeRectBatch.h"
|
|
||||||
#include "gl/GrGLProcessor.h"
|
|
||||||
#include "gl/GrGLGeometryProcessor.h"
|
|
||||||
#include "gl/builders/GrGLProgramBuilder.h"
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void GrAARectRenderer::GeometryFillAARect(GrDrawTarget* target,
|
|
||||||
const GrPipelineBuilder& pipelineBuilder,
|
|
||||||
GrColor color,
|
|
||||||
const SkMatrix& viewMatrix,
|
|
||||||
const SkRect& rect,
|
|
||||||
const SkRect& devRect) {
|
|
||||||
GrAAFillRectBatch::Geometry geometry;
|
|
||||||
geometry.fRect = rect;
|
|
||||||
geometry.fViewMatrix = viewMatrix;
|
|
||||||
geometry.fDevRect = devRect;
|
|
||||||
geometry.fColor = color;
|
|
||||||
|
|
||||||
|
|
||||||
SkAutoTUnref<GrBatch> batch(GrAAFillRectBatch::Create(geometry));
|
|
||||||
target->drawBatch(pipelineBuilder, batch);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GrAARectRenderer::StrokeAARect(GrDrawTarget* target,
|
|
||||||
const GrPipelineBuilder& pipelineBuilder,
|
|
||||||
GrColor color,
|
|
||||||
const SkMatrix& viewMatrix,
|
|
||||||
const SkRect& rect,
|
|
||||||
const SkRect& devRect,
|
|
||||||
const SkStrokeRec& stroke) {
|
|
||||||
SkVector devStrokeSize;
|
|
||||||
SkScalar width = stroke.getWidth();
|
|
||||||
if (width > 0) {
|
|
||||||
devStrokeSize.set(width, width);
|
|
||||||
viewMatrix.mapVectors(&devStrokeSize, 1);
|
|
||||||
devStrokeSize.setAbs(devStrokeSize);
|
|
||||||
} else {
|
|
||||||
devStrokeSize.set(SK_Scalar1, SK_Scalar1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const SkScalar dx = devStrokeSize.fX;
|
|
||||||
const SkScalar dy = devStrokeSize.fY;
|
|
||||||
const SkScalar rx = SkScalarMul(dx, SK_ScalarHalf);
|
|
||||||
const SkScalar ry = SkScalarMul(dy, SK_ScalarHalf);
|
|
||||||
|
|
||||||
SkScalar spare;
|
|
||||||
{
|
|
||||||
SkScalar w = devRect.width() - dx;
|
|
||||||
SkScalar h = devRect.height() - dy;
|
|
||||||
spare = SkTMin(w, h);
|
|
||||||
}
|
|
||||||
|
|
||||||
SkRect devOutside(devRect);
|
|
||||||
devOutside.outset(rx, ry);
|
|
||||||
|
|
||||||
bool miterStroke = true;
|
|
||||||
// For hairlines, make bevel and round joins appear the same as mitered ones.
|
|
||||||
// small miter limit means right angles show bevel...
|
|
||||||
if ((width > 0) && (stroke.getJoin() != SkPaint::kMiter_Join ||
|
|
||||||
stroke.getMiter() < SK_ScalarSqrt2)) {
|
|
||||||
miterStroke = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (spare <= 0 && miterStroke) {
|
|
||||||
FillAARect(target, pipelineBuilder, color, viewMatrix, devOutside, devOutside);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SkRect devInside(devRect);
|
|
||||||
devInside.inset(rx, ry);
|
|
||||||
|
|
||||||
SkRect devOutsideAssist(devRect);
|
|
||||||
|
|
||||||
// For bevel-stroke, use 2 SkRect instances(devOutside and devOutsideAssist)
|
|
||||||
// to draw the outer of the rect. Because there are 8 vertices on the outer
|
|
||||||
// edge, while vertex number of inner edge is 4, the same as miter-stroke.
|
|
||||||
if (!miterStroke) {
|
|
||||||
devOutside.inset(0, ry);
|
|
||||||
devOutsideAssist.outset(0, ry);
|
|
||||||
}
|
|
||||||
|
|
||||||
GeometryStrokeAARect(target, pipelineBuilder, color, viewMatrix, devOutside,
|
|
||||||
devOutsideAssist, devInside, miterStroke);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GrAARectRenderer::GeometryStrokeAARect(GrDrawTarget* target,
|
|
||||||
const GrPipelineBuilder& pipelineBuilder,
|
|
||||||
GrColor color,
|
|
||||||
const SkMatrix& viewMatrix,
|
|
||||||
const SkRect& devOutside,
|
|
||||||
const SkRect& devOutsideAssist,
|
|
||||||
const SkRect& devInside,
|
|
||||||
bool miterStroke) {
|
|
||||||
GrAAStrokeRectBatch::Geometry geometry;
|
|
||||||
geometry.fColor = color;
|
|
||||||
geometry.fDevOutside = devOutside;
|
|
||||||
geometry.fDevOutsideAssist = devOutsideAssist;
|
|
||||||
geometry.fDevInside = devInside;
|
|
||||||
geometry.fMiterStroke = miterStroke;
|
|
||||||
|
|
||||||
SkAutoTUnref<GrBatch> batch(GrAAStrokeRectBatch::Create(geometry, viewMatrix));
|
|
||||||
target->drawBatch(pipelineBuilder, batch);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GrAARectRenderer::FillAANestedRects(GrDrawTarget* target,
|
|
||||||
const GrPipelineBuilder& pipelineBuilder,
|
|
||||||
GrColor color,
|
|
||||||
const SkMatrix& viewMatrix,
|
|
||||||
const SkRect rects[2]) {
|
|
||||||
SkASSERT(viewMatrix.rectStaysRect());
|
|
||||||
SkASSERT(!rects[0].isEmpty() && !rects[1].isEmpty());
|
|
||||||
|
|
||||||
SkRect devOutside, devInside;
|
|
||||||
viewMatrix.mapRect(&devOutside, rects[0]);
|
|
||||||
viewMatrix.mapRect(&devInside, rects[1]);
|
|
||||||
|
|
||||||
if (devInside.isEmpty()) {
|
|
||||||
FillAARect(target, pipelineBuilder, color, viewMatrix, devOutside, devOutside);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GeometryStrokeAARect(target, pipelineBuilder, color, viewMatrix, devOutside,
|
|
||||||
devOutside, devInside, true);
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012 Google Inc.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
|
||||||
* found in the LICENSE file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GrAARectRenderer_DEFINED
|
|
||||||
#define GrAARectRenderer_DEFINED
|
|
||||||
|
|
||||||
#include "GrColor.h"
|
|
||||||
#include "SkMatrix.h"
|
|
||||||
#include "SkRect.h"
|
|
||||||
#include "SkStrokeRec.h"
|
|
||||||
|
|
||||||
class GrClip;
|
|
||||||
class GrDrawTarget;
|
|
||||||
class GrIndexBuffer;
|
|
||||||
class GrPipelineBuilder;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This class wraps helper functions that draw AA rects (filled & stroked)
|
|
||||||
*/
|
|
||||||
class GrAARectRenderer {
|
|
||||||
public:
|
|
||||||
// TODO: potentialy fuse the fill & stroke methods and differentiate
|
|
||||||
// between them by passing in stroke (==NULL means fill).
|
|
||||||
|
|
||||||
static void FillAARect(GrDrawTarget* target,
|
|
||||||
const GrPipelineBuilder& pipelineBuilder,
|
|
||||||
GrColor color,
|
|
||||||
const SkMatrix& viewMatrix,
|
|
||||||
const SkRect& rect,
|
|
||||||
const SkRect& devRect) {
|
|
||||||
GeometryFillAARect(target, pipelineBuilder, color, viewMatrix, rect, devRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void StrokeAARect(GrDrawTarget*,
|
|
||||||
const GrPipelineBuilder&,
|
|
||||||
GrColor,
|
|
||||||
const SkMatrix& viewMatrix,
|
|
||||||
const SkRect& rect,
|
|
||||||
const SkRect& devRect,
|
|
||||||
const SkStrokeRec& stroke);
|
|
||||||
|
|
||||||
// First rect is outer; second rect is inner
|
|
||||||
static void FillAANestedRects(GrDrawTarget*,
|
|
||||||
const GrPipelineBuilder&,
|
|
||||||
GrColor,
|
|
||||||
const SkMatrix& viewMatrix,
|
|
||||||
const SkRect rects[2]);
|
|
||||||
|
|
||||||
private:
|
|
||||||
GrAARectRenderer();
|
|
||||||
|
|
||||||
static void GeometryFillAARect(GrDrawTarget*,
|
|
||||||
const GrPipelineBuilder&,
|
|
||||||
GrColor,
|
|
||||||
const SkMatrix& viewMatrix,
|
|
||||||
const SkRect& rect,
|
|
||||||
const SkRect& devRect);
|
|
||||||
|
|
||||||
static void GeometryStrokeAARect(GrDrawTarget*,
|
|
||||||
const GrPipelineBuilder&,
|
|
||||||
GrColor,
|
|
||||||
const SkMatrix& viewMatrix,
|
|
||||||
const SkRect& devOutside,
|
|
||||||
const SkRect& devOutsideAssist,
|
|
||||||
const SkRect& devInside,
|
|
||||||
bool miterStroke);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // GrAARectRenderer_DEFINED
|
|
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
#include "GrContext.h"
|
#include "GrContext.h"
|
||||||
|
|
||||||
#include "GrAARectRenderer.h"
|
|
||||||
#include "GrBatchFontCache.h"
|
#include "GrBatchFontCache.h"
|
||||||
#include "GrBatchTarget.h"
|
#include "GrBatchTarget.h"
|
||||||
#include "GrBatchTest.h"
|
#include "GrBatchTest.h"
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "GrAARectRenderer.h"
|
|
||||||
#include "GrAtlasTextContext.h"
|
#include "GrAtlasTextContext.h"
|
||||||
#include "GrBatchTest.h"
|
#include "GrBatchTest.h"
|
||||||
#include "GrColor.h"
|
#include "GrColor.h"
|
||||||
@ -308,23 +307,14 @@ void GrDrawContext::drawRect(GrRenderTarget* rt,
|
|||||||
width, viewMatrix, color);
|
width, viewMatrix, color);
|
||||||
|
|
||||||
if (doAA) {
|
if (doAA) {
|
||||||
|
SkAutoTUnref<GrBatch> batch;
|
||||||
if (width >= 0) {
|
if (width >= 0) {
|
||||||
GrAARectRenderer::StrokeAARect(fDrawTarget,
|
batch.reset(GrRectBatchFactory::CreateStrokeAA(color, viewMatrix, rect, devBoundRect,
|
||||||
pipelineBuilder,
|
*strokeInfo));
|
||||||
color,
|
|
||||||
viewMatrix,
|
|
||||||
rect,
|
|
||||||
devBoundRect,
|
|
||||||
*strokeInfo);
|
|
||||||
} else {
|
} else {
|
||||||
// filled AA rect
|
batch.reset(GrRectBatchFactory::CreateFillAA(color, viewMatrix, rect, devBoundRect));
|
||||||
GrAARectRenderer::FillAARect(fDrawTarget,
|
|
||||||
pipelineBuilder,
|
|
||||||
color,
|
|
||||||
viewMatrix,
|
|
||||||
rect,
|
|
||||||
devBoundRect);
|
|
||||||
}
|
}
|
||||||
|
fDrawTarget->drawBatch(pipelineBuilder, batch);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -702,8 +692,10 @@ void GrDrawContext::drawPath(GrRenderTarget* rt,
|
|||||||
SkRect rects[2];
|
SkRect rects[2];
|
||||||
|
|
||||||
if (is_nested_rects(viewMatrix, path, strokeInfo, rects)) {
|
if (is_nested_rects(viewMatrix, path, strokeInfo, rects)) {
|
||||||
GrAARectRenderer::FillAANestedRects(fDrawTarget, pipelineBuilder, color,
|
SkAutoTUnref<GrBatch> batch(GrRectBatchFactory::CreateFillNestedRectsAA(color,
|
||||||
viewMatrix, rects);
|
viewMatrix,
|
||||||
|
rects));
|
||||||
|
fDrawTarget->drawBatch(pipelineBuilder, batch);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
#include "GrDrawTarget.h"
|
#include "GrDrawTarget.h"
|
||||||
|
|
||||||
#include "GrAARectRenderer.h"
|
|
||||||
#include "GrCaps.h"
|
#include "GrCaps.h"
|
||||||
#include "GrGpu.h"
|
#include "GrGpu.h"
|
||||||
#include "GrPath.h"
|
#include "GrPath.h"
|
||||||
@ -304,7 +303,8 @@ void GrDrawTarget::drawAARect(const GrPipelineBuilder& pipelineBuilder,
|
|||||||
const SkMatrix& viewMatrix,
|
const SkMatrix& viewMatrix,
|
||||||
const SkRect& rect,
|
const SkRect& rect,
|
||||||
const SkRect& devRect) {
|
const SkRect& devRect) {
|
||||||
GrAARectRenderer::FillAARect(this, pipelineBuilder, color, viewMatrix, rect, devRect);
|
SkAutoTUnref<GrBatch> batch(GrRectBatchFactory::CreateFillAA(color, viewMatrix, rect, devRect));
|
||||||
|
this->drawBatch(pipelineBuilder, batch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrDrawTarget::clear(const SkIRect* rect,
|
void GrDrawTarget::clear(const SkIRect* rect,
|
||||||
|
@ -7,9 +7,29 @@
|
|||||||
|
|
||||||
#include "GrRectBatchFactory.h"
|
#include "GrRectBatchFactory.h"
|
||||||
|
|
||||||
|
#include "GrAAFillRectBatch.h"
|
||||||
|
#include "GrAAStrokeRectBatch.h"
|
||||||
#include "GrRectBatch.h"
|
#include "GrRectBatch.h"
|
||||||
#include "GrStrokeRectBatch.h"
|
#include "GrStrokeRectBatch.h"
|
||||||
|
|
||||||
|
#include "SkStrokeRec.h"
|
||||||
|
|
||||||
|
static GrBatch* create_stroke_aa_batch(GrColor color,
|
||||||
|
const SkMatrix& viewMatrix,
|
||||||
|
const SkRect& devOutside,
|
||||||
|
const SkRect& devOutsideAssist,
|
||||||
|
const SkRect& devInside,
|
||||||
|
bool miterStroke) {
|
||||||
|
GrAAStrokeRectBatch::Geometry geometry;
|
||||||
|
geometry.fColor = color;
|
||||||
|
geometry.fDevOutside = devOutside;
|
||||||
|
geometry.fDevOutsideAssist = devOutsideAssist;
|
||||||
|
geometry.fDevInside = devInside;
|
||||||
|
geometry.fMiterStroke = miterStroke;
|
||||||
|
|
||||||
|
return GrAAStrokeRectBatch::Create(geometry, viewMatrix);
|
||||||
|
}
|
||||||
|
|
||||||
namespace GrRectBatchFactory {
|
namespace GrRectBatchFactory {
|
||||||
|
|
||||||
GrBatch* CreateFillBW(GrColor color,
|
GrBatch* CreateFillBW(GrColor color,
|
||||||
@ -39,6 +59,19 @@ GrBatch* CreateFillBW(GrColor color,
|
|||||||
return GrRectBatch::Create(geometry);
|
return GrRectBatch::Create(geometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GrBatch* CreateFillAA(GrColor color,
|
||||||
|
const SkMatrix& viewMatrix,
|
||||||
|
const SkRect& rect,
|
||||||
|
const SkRect& devRect) {
|
||||||
|
GrAAFillRectBatch::Geometry geometry;
|
||||||
|
geometry.fRect = rect;
|
||||||
|
geometry.fViewMatrix = viewMatrix;
|
||||||
|
geometry.fDevRect = devRect;
|
||||||
|
geometry.fColor = color;
|
||||||
|
|
||||||
|
return GrAAFillRectBatch::Create(geometry);
|
||||||
|
}
|
||||||
|
|
||||||
GrBatch* CreateStrokeBW(GrColor color,
|
GrBatch* CreateStrokeBW(GrColor color,
|
||||||
const SkMatrix& viewMatrix,
|
const SkMatrix& viewMatrix,
|
||||||
const SkRect& rect,
|
const SkRect& rect,
|
||||||
@ -52,4 +85,80 @@ GrBatch* CreateStrokeBW(GrColor color,
|
|||||||
return GrStrokeRectBatch::Create(geometry, snapToPixelCenters);
|
return GrStrokeRectBatch::Create(geometry, snapToPixelCenters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GrBatch* CreateStrokeAA(GrColor color,
|
||||||
|
const SkMatrix& viewMatrix,
|
||||||
|
const SkRect& rect,
|
||||||
|
const SkRect& devRect,
|
||||||
|
const SkStrokeRec& stroke) {
|
||||||
|
SkVector devStrokeSize;
|
||||||
|
SkScalar width = stroke.getWidth();
|
||||||
|
if (width > 0) {
|
||||||
|
devStrokeSize.set(width, width);
|
||||||
|
viewMatrix.mapVectors(&devStrokeSize, 1);
|
||||||
|
devStrokeSize.setAbs(devStrokeSize);
|
||||||
|
} else {
|
||||||
|
devStrokeSize.set(SK_Scalar1, SK_Scalar1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const SkScalar dx = devStrokeSize.fX;
|
||||||
|
const SkScalar dy = devStrokeSize.fY;
|
||||||
|
const SkScalar rx = SkScalarMul(dx, SK_ScalarHalf);
|
||||||
|
const SkScalar ry = SkScalarMul(dy, SK_ScalarHalf);
|
||||||
|
|
||||||
|
SkScalar spare;
|
||||||
|
{
|
||||||
|
SkScalar w = devRect.width() - dx;
|
||||||
|
SkScalar h = devRect.height() - dy;
|
||||||
|
spare = SkTMin(w, h);
|
||||||
|
}
|
||||||
|
|
||||||
|
SkRect devOutside(devRect);
|
||||||
|
devOutside.outset(rx, ry);
|
||||||
|
|
||||||
|
bool miterStroke = true;
|
||||||
|
// For hairlines, make bevel and round joins appear the same as mitered ones.
|
||||||
|
// small miter limit means right angles show bevel...
|
||||||
|
if ((width > 0) && (stroke.getJoin() != SkPaint::kMiter_Join ||
|
||||||
|
stroke.getMiter() < SK_ScalarSqrt2)) {
|
||||||
|
miterStroke = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (spare <= 0 && miterStroke) {
|
||||||
|
return CreateFillAA(color, viewMatrix, devOutside, devOutside);
|
||||||
|
}
|
||||||
|
|
||||||
|
SkRect devInside(devRect);
|
||||||
|
devInside.inset(rx, ry);
|
||||||
|
|
||||||
|
SkRect devOutsideAssist(devRect);
|
||||||
|
|
||||||
|
// For bevel-stroke, use 2 SkRect instances(devOutside and devOutsideAssist)
|
||||||
|
// to draw the outer of the rect. Because there are 8 vertices on the outer
|
||||||
|
// edge, while vertex number of inner edge is 4, the same as miter-stroke.
|
||||||
|
if (!miterStroke) {
|
||||||
|
devOutside.inset(0, ry);
|
||||||
|
devOutsideAssist.outset(0, ry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return create_stroke_aa_batch(color, viewMatrix, devOutside, devOutsideAssist, devInside,
|
||||||
|
miterStroke);
|
||||||
|
}
|
||||||
|
|
||||||
|
GrBatch* CreateFillNestedRectsAA(GrColor color,
|
||||||
|
const SkMatrix& viewMatrix,
|
||||||
|
const SkRect rects[2]) {
|
||||||
|
SkASSERT(viewMatrix.rectStaysRect());
|
||||||
|
SkASSERT(!rects[0].isEmpty() && !rects[1].isEmpty());
|
||||||
|
|
||||||
|
SkRect devOutside, devInside;
|
||||||
|
viewMatrix.mapRect(&devOutside, rects[0]);
|
||||||
|
viewMatrix.mapRect(&devInside, rects[1]);
|
||||||
|
|
||||||
|
if (devInside.isEmpty()) {
|
||||||
|
return CreateFillAA(color, viewMatrix, devOutside, devOutside);
|
||||||
|
}
|
||||||
|
|
||||||
|
return create_stroke_aa_batch(color, viewMatrix, devOutside, devOutside, devInside, true);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -13,10 +13,10 @@
|
|||||||
class GrBatch;
|
class GrBatch;
|
||||||
class SkMatrix;
|
class SkMatrix;
|
||||||
struct SkRect;
|
struct SkRect;
|
||||||
|
class SkStrokeRec;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A factory for returning batches which can draw rectangles. Right now this only handles non-AA
|
* A factory for returning batches which can draw rectangles.
|
||||||
* rects
|
|
||||||
*/
|
*/
|
||||||
namespace GrRectBatchFactory {
|
namespace GrRectBatchFactory {
|
||||||
|
|
||||||
@ -26,12 +26,28 @@ GrBatch* CreateFillBW(GrColor color,
|
|||||||
const SkRect* localRect,
|
const SkRect* localRect,
|
||||||
const SkMatrix* localMatrix);
|
const SkMatrix* localMatrix);
|
||||||
|
|
||||||
|
GrBatch* CreateFillAA(GrColor color,
|
||||||
|
const SkMatrix& viewMatrix,
|
||||||
|
const SkRect& rect,
|
||||||
|
const SkRect& devRect);
|
||||||
|
|
||||||
GrBatch* CreateStrokeBW(GrColor color,
|
GrBatch* CreateStrokeBW(GrColor color,
|
||||||
const SkMatrix& viewMatrix,
|
const SkMatrix& viewMatrix,
|
||||||
const SkRect& rect,
|
const SkRect& rect,
|
||||||
SkScalar strokeWidth,
|
SkScalar strokeWidth,
|
||||||
bool snapToPixelCenters);
|
bool snapToPixelCenters);
|
||||||
|
|
||||||
|
GrBatch* CreateStrokeAA(GrColor,
|
||||||
|
const SkMatrix& viewMatrix,
|
||||||
|
const SkRect& rect,
|
||||||
|
const SkRect& devRect,
|
||||||
|
const SkStrokeRec& stroke);
|
||||||
|
|
||||||
|
// First rect is outer; second rect is inner
|
||||||
|
GrBatch* CreateFillNestedRectsAA(GrColor,
|
||||||
|
const SkMatrix& viewMatrix,
|
||||||
|
const SkRect rects[2]);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user