Move GrStrokeRectBatch creation to behind factory
BUG=skia: Review URL: https://codereview.chromium.org/1282283002
This commit is contained in:
parent
ecd1a69fbf
commit
7fc2a2610e
@ -20,7 +20,7 @@
|
||||
#include "batches/GrBatch.h"
|
||||
#include "batches/GrDrawAtlasBatch.h"
|
||||
#include "batches/GrDrawVerticesBatch.h"
|
||||
#include "batches/GrStrokeRectBatch.h"
|
||||
#include "batches/GrRectBatchFactory.h"
|
||||
|
||||
#include "SkGr.h"
|
||||
#include "SkRSXform.h"
|
||||
@ -329,15 +329,10 @@ void GrDrawContext::drawRect(GrRenderTarget* rt,
|
||||
}
|
||||
|
||||
if (width >= 0) {
|
||||
GrStrokeRectBatch::Geometry geometry;
|
||||
geometry.fViewMatrix = viewMatrix;
|
||||
geometry.fColor = color;
|
||||
geometry.fRect = rect;
|
||||
geometry.fStrokeWidth = width;
|
||||
|
||||
// Non-AA hairlines are snapped to pixel centers to make which pixels are hit deterministic
|
||||
bool snapToPixelCenters = (0 == width && !rt->isUnifiedMultisampled());
|
||||
SkAutoTUnref<GrBatch> batch(GrStrokeRectBatch::Create(geometry, snapToPixelCenters));
|
||||
SkAutoTUnref<GrBatch> batch(GrRectBatchFactory::CreateStrokeBW(color, viewMatrix, rect,
|
||||
width, snapToPixelCenters));
|
||||
|
||||
// Depending on sub-pixel coordinates and the particular GPU, we may lose a corner of
|
||||
// hairline rects. We jam all the vertices to pixel centers to avoid this, but not when MSAA
|
||||
|
@ -294,8 +294,8 @@ void GrDrawTarget::drawBWRect(const GrPipelineBuilder& pipelineBuilder,
|
||||
const SkRect& rect,
|
||||
const SkRect* localRect,
|
||||
const SkMatrix* localMatrix) {
|
||||
SkAutoTUnref<GrBatch> batch(GrRectBatchFactory::Create(color, viewMatrix, rect, localRect,
|
||||
localMatrix));
|
||||
SkAutoTUnref<GrBatch> batch(GrRectBatchFactory::CreateFillBW(color, viewMatrix, rect, localRect,
|
||||
localMatrix));
|
||||
this->drawBatch(pipelineBuilder, batch);
|
||||
}
|
||||
|
||||
|
@ -8,14 +8,15 @@
|
||||
#include "GrRectBatchFactory.h"
|
||||
|
||||
#include "GrRectBatch.h"
|
||||
#include "GrStrokeRectBatch.h"
|
||||
|
||||
namespace GrRectBatchFactory {
|
||||
|
||||
GrBatch* Create(GrColor color,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& rect,
|
||||
const SkRect* localRect,
|
||||
const SkMatrix* localMatrix) {
|
||||
GrBatch* CreateFillBW(GrColor color,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& rect,
|
||||
const SkRect* localRect,
|
||||
const SkMatrix* localMatrix) {
|
||||
GrRectBatch::Geometry geometry;
|
||||
geometry.fColor = color;
|
||||
geometry.fViewMatrix = viewMatrix;
|
||||
@ -38,4 +39,17 @@ GrBatch* Create(GrColor color,
|
||||
return GrRectBatch::Create(geometry);
|
||||
}
|
||||
|
||||
GrBatch* CreateStrokeBW(GrColor color,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& rect,
|
||||
SkScalar strokeWidth,
|
||||
bool snapToPixelCenters) {
|
||||
GrStrokeRectBatch::Geometry geometry;
|
||||
geometry.fColor = color;
|
||||
geometry.fViewMatrix = viewMatrix;
|
||||
geometry.fRect = rect;
|
||||
geometry.fStrokeWidth = strokeWidth;
|
||||
return GrStrokeRectBatch::Create(geometry, snapToPixelCenters);
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -20,11 +20,17 @@ struct SkRect;
|
||||
*/
|
||||
namespace GrRectBatchFactory {
|
||||
|
||||
GrBatch* Create(GrColor color,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& rect,
|
||||
const SkRect* localRect,
|
||||
const SkMatrix* localMatrix);
|
||||
GrBatch* CreateFillBW(GrColor color,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& rect,
|
||||
const SkRect* localRect,
|
||||
const SkMatrix* localMatrix);
|
||||
|
||||
GrBatch* CreateStrokeBW(GrColor color,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& rect,
|
||||
SkScalar strokeWidth,
|
||||
bool snapToPixelCenters);
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user