make point array methods private
Moved method are not used by chromium, google3, or android. SkPoint::setRectIFan isn't used or tested at all. SkPoint::setRectFan and SkPoint::setRectTriStrip are only used internally. These routines pretend that a SkPoint is part of an array of points. Since that's kind of an odd contract to make public, and because they aren't used outside of Skia, relegate them to a priv file. R=bsalomon@google.com,reed@google.com Bug: skia: 6898 Change-Id: I5ec2eb47799f6fd4b2994da962b1fa69ce659931 Reviewed-on: https://skia-review.googlesource.com/68121 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Cary Clark <caryclark@google.com>
This commit is contained in:
parent
b49d7b0118
commit
74f623d161
@ -19,6 +19,7 @@
|
||||
#include "SkColorPriv.h"
|
||||
#include "SkGeometry.h"
|
||||
#include "SkPoint3.h"
|
||||
#include "SkPointPriv.h"
|
||||
#include "effects/GrBezierEffect.h"
|
||||
#include "ops/GrMeshDrawOp.h"
|
||||
|
||||
@ -93,7 +94,7 @@ private:
|
||||
return;
|
||||
}
|
||||
SkRect rect = this->rect();
|
||||
pts[0].setRectTriStrip(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, vertexStride);
|
||||
SkPointPriv::SetRectTriStrip(pts, rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, vertexStride);
|
||||
helper.recordDraw(target, this->gp(), this->makePipeline(target));
|
||||
}
|
||||
|
||||
@ -268,8 +269,8 @@ private:
|
||||
return;
|
||||
}
|
||||
SkRect rect = this->rect();
|
||||
verts[0].fPosition.setRectTriStrip(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom,
|
||||
sizeof(Vertex));
|
||||
SkPointPriv::SetRectTriStrip(&verts[0].fPosition, rect.fLeft, rect.fTop, rect.fRight,
|
||||
rect.fBottom, sizeof(Vertex));
|
||||
for (int v = 0; v < 4; ++v) {
|
||||
SkPoint3 pt3 = {verts[v].fPosition.x(), verts[v].fPosition.y(), 1.f};
|
||||
fKLM.mapHomogeneousPoints((SkPoint3* ) verts[v].fKLM, &pt3, 1);
|
||||
@ -482,8 +483,8 @@ private:
|
||||
return;
|
||||
}
|
||||
SkRect rect = this->rect();
|
||||
verts[0].fPosition.setRectTriStrip(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom,
|
||||
sizeof(Vertex));
|
||||
SkPointPriv::SetRectTriStrip(&verts[0].fPosition, rect.fLeft, rect.fTop, rect.fRight,
|
||||
rect.fBottom, sizeof(Vertex));
|
||||
fDevToUV.apply<4, sizeof(Vertex), sizeof(SkPoint)>(verts);
|
||||
helper.recordDraw(target, this->gp(), this->makePipeline(target));
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "GrTest.h"
|
||||
#include "SkColorPriv.h"
|
||||
#include "SkGeometry.h"
|
||||
#include "SkPointPriv.h"
|
||||
#include "SkTLList.h"
|
||||
#include "effects/GrConvexPolyEffect.h"
|
||||
#include "ops/GrMeshDrawOp.h"
|
||||
@ -85,7 +86,7 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
verts->setRectTriStrip(fRect.fLeft, fRect.fTop, fRect.fRight, fRect.fBottom,
|
||||
SkPointPriv::SetRectTriStrip(verts, fRect.fLeft, fRect.fTop, fRect.fRight, fRect.fBottom,
|
||||
sizeof(SkPoint));
|
||||
|
||||
helper.recordDraw(
|
||||
|
@ -197,36 +197,6 @@ struct SK_API SkPoint {
|
||||
fY = SkScalarAbs(pt.fY);
|
||||
}
|
||||
|
||||
// counter-clockwise fan
|
||||
void setIRectFan(int l, int t, int r, int b) {
|
||||
SkPoint* v = this;
|
||||
v[0].set(SkIntToScalar(l), SkIntToScalar(t));
|
||||
v[1].set(SkIntToScalar(l), SkIntToScalar(b));
|
||||
v[2].set(SkIntToScalar(r), SkIntToScalar(b));
|
||||
v[3].set(SkIntToScalar(r), SkIntToScalar(t));
|
||||
}
|
||||
void setIRectFan(int l, int t, int r, int b, size_t stride);
|
||||
|
||||
// counter-clockwise fan
|
||||
void setRectFan(SkScalar l, SkScalar t, SkScalar r, SkScalar b, size_t stride) {
|
||||
SkASSERT(stride >= sizeof(SkPoint));
|
||||
|
||||
((SkPoint*)((intptr_t)this + 0 * stride))->set(l, t);
|
||||
((SkPoint*)((intptr_t)this + 1 * stride))->set(l, b);
|
||||
((SkPoint*)((intptr_t)this + 2 * stride))->set(r, b);
|
||||
((SkPoint*)((intptr_t)this + 3 * stride))->set(r, t);
|
||||
}
|
||||
|
||||
// tri strip with two counter-clockwise triangles
|
||||
void setRectTriStrip(SkScalar l, SkScalar t, SkScalar r, SkScalar b, size_t stride) {
|
||||
SkASSERT(stride >= sizeof(SkPoint));
|
||||
|
||||
((SkPoint*)((intptr_t)this + 0 * stride))->set(l, t);
|
||||
((SkPoint*)((intptr_t)this + 1 * stride))->set(l, b);
|
||||
((SkPoint*)((intptr_t)this + 2 * stride))->set(r, t);
|
||||
((SkPoint*)((intptr_t)this + 3 * stride))->set(r, b);
|
||||
}
|
||||
|
||||
static void Offset(SkPoint points[], int count, const SkPoint& offset) {
|
||||
Offset(points, count, offset.fX, offset.fY);
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "SkMatrix.h"
|
||||
#include "SkNx.h"
|
||||
#include "SkPointPriv.h"
|
||||
|
||||
class SkMatrixPriv {
|
||||
public:
|
||||
@ -113,9 +114,9 @@ public:
|
||||
r = sx * r + tx;
|
||||
b = sy * b + ty;
|
||||
}
|
||||
quad[0].setRectTriStrip(l, t, r, b, sizeof(SkPoint));
|
||||
SkPointPriv::SetRectTriStrip(quad, l, t, r, b, sizeof(SkPoint));
|
||||
} else {
|
||||
quad[0].setRectTriStrip(l, t, r, b, sizeof(SkPoint));
|
||||
SkPointPriv::SetRectTriStrip(quad, l, t, r, b, sizeof(SkPoint));
|
||||
mx.mapPoints(quad, quad, 4);
|
||||
}
|
||||
}
|
||||
|
@ -29,19 +29,6 @@ void SkIPoint::rotateCCW(SkIPoint* dst) const {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SkPoint::setIRectFan(int l, int t, int r, int b, size_t stride) {
|
||||
SkASSERT(stride >= sizeof(SkPoint));
|
||||
|
||||
((SkPoint*)((intptr_t)this + 0 * stride))->set(SkIntToScalar(l),
|
||||
SkIntToScalar(t));
|
||||
((SkPoint*)((intptr_t)this + 1 * stride))->set(SkIntToScalar(l),
|
||||
SkIntToScalar(b));
|
||||
((SkPoint*)((intptr_t)this + 2 * stride))->set(SkIntToScalar(r),
|
||||
SkIntToScalar(b));
|
||||
((SkPoint*)((intptr_t)this + 3 * stride))->set(SkIntToScalar(r),
|
||||
SkIntToScalar(t));
|
||||
}
|
||||
|
||||
void SkPoint::rotateCW(SkPoint* dst) const {
|
||||
SkASSERT(dst);
|
||||
|
||||
|
38
src/core/SkPointPriv.h
Normal file
38
src/core/SkPointPriv.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkPointPriv_DEFINED
|
||||
#define SkPointPriv_DEFINED
|
||||
|
||||
#include "SkPoint.h"
|
||||
|
||||
class SkPointPriv {
|
||||
public:
|
||||
// counter-clockwise fan
|
||||
static void SetRectFan(SkPoint v[], SkScalar l, SkScalar t, SkScalar r, SkScalar b,
|
||||
size_t stride) {
|
||||
SkASSERT(stride >= sizeof(SkPoint));
|
||||
|
||||
((SkPoint*)((intptr_t)v + 0 * stride))->set(l, t);
|
||||
((SkPoint*)((intptr_t)v + 1 * stride))->set(l, b);
|
||||
((SkPoint*)((intptr_t)v + 2 * stride))->set(r, b);
|
||||
((SkPoint*)((intptr_t)v + 3 * stride))->set(r, t);
|
||||
}
|
||||
|
||||
// tri strip with two counter-clockwise triangles
|
||||
static void SetRectTriStrip(SkPoint v[], SkScalar l, SkScalar t, SkScalar r, SkScalar b,
|
||||
size_t stride) {
|
||||
SkASSERT(stride >= sizeof(SkPoint));
|
||||
|
||||
((SkPoint*)((intptr_t)v + 0 * stride))->set(l, t);
|
||||
((SkPoint*)((intptr_t)v + 1 * stride))->set(l, b);
|
||||
((SkPoint*)((intptr_t)v + 2 * stride))->set(r, t);
|
||||
((SkPoint*)((intptr_t)v + 3 * stride))->set(r, b);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
@ -29,7 +29,8 @@ public:
|
||||
}
|
||||
|
||||
void set(const SkRect& rect) {
|
||||
fPoints->setRectTriStrip(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, sizeof(SkPoint));
|
||||
SkPointPriv::SetRectTriStrip(fPoints, rect.fLeft, rect.fTop, rect.fRight, rect.fBottom,
|
||||
sizeof(SkPoint));
|
||||
}
|
||||
|
||||
void map(const SkMatrix& matrix) {
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "GrTypes.h"
|
||||
#include "SkMatrix.h"
|
||||
#include "SkRect.h"
|
||||
#include "SkPointPriv.h"
|
||||
#include "ops/GrSimpleMeshDrawOpHelper.h"
|
||||
|
||||
GR_DECLARE_STATIC_UNIQUE_KEY(gAAFillRectIndexBufferKey);
|
||||
@ -25,7 +26,7 @@ static inline bool view_matrix_ok_for_aa_fill_rect(const SkMatrix& viewMatrix) {
|
||||
|
||||
static inline void set_inset_fan(SkPoint* pts, size_t stride, const SkRect& r, SkScalar dx,
|
||||
SkScalar dy) {
|
||||
pts->setRectFan(r.fLeft + dx, r.fTop + dy, r.fRight - dx, r.fBottom - dy, stride);
|
||||
SkPointPriv::SetRectFan(pts, r.fLeft + dx, r.fTop + dy, r.fRight - dx, r.fBottom - dy, stride);
|
||||
}
|
||||
|
||||
static const int kNumAAFillRectsInIndexBuffer = 256;
|
||||
@ -84,7 +85,8 @@ static void generate_aa_fill_rect_geometry(intptr_t verts,
|
||||
inset = SK_ScalarHalf * SkMinScalar(inset, len2 * rect.height());
|
||||
|
||||
// create the rotated rect
|
||||
fan0Pos->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, vertexStride);
|
||||
SkPointPriv::SetRectFan(fan0Pos, rect.fLeft, rect.fTop, rect.fRight, rect.fBottom,
|
||||
vertexStride);
|
||||
viewMatrix.mapPointsWithStride(fan0Pos, vertexStride, 4);
|
||||
|
||||
// Now create the inset points and then outset the original
|
||||
|
@ -11,13 +11,14 @@
|
||||
#include "GrResourceKey.h"
|
||||
#include "GrResourceProvider.h"
|
||||
#include "GrSimpleMeshDrawOpHelper.h"
|
||||
#include "SkPointPriv.h"
|
||||
#include "SkStrokeRec.h"
|
||||
|
||||
GR_DECLARE_STATIC_UNIQUE_KEY(gMiterIndexBufferKey);
|
||||
GR_DECLARE_STATIC_UNIQUE_KEY(gBevelIndexBufferKey);
|
||||
|
||||
static void set_inset_fan(SkPoint* pts, size_t stride, const SkRect& r, SkScalar dx, SkScalar dy) {
|
||||
pts->setRectFan(r.fLeft + dx, r.fTop + dy, r.fRight - dx, r.fBottom - dy, stride);
|
||||
SkPointPriv::SetRectFan(pts, r.fLeft + dx, r.fTop + dy, r.fRight - dx, r.fBottom - dy, stride);
|
||||
}
|
||||
|
||||
// We support all hairlines, bevels, and miters, but not round joins. Also, check whether the miter
|
||||
@ -494,9 +495,9 @@ void AAStrokeRectOp::generateAAStrokeRectGeometry(void* vertices,
|
||||
} else {
|
||||
// When the interior rect has become degenerate we smoosh to a single point
|
||||
SkASSERT(devInside.fLeft == devInside.fRight && devInside.fTop == devInside.fBottom);
|
||||
fan2Pos->setRectFan(devInside.fLeft, devInside.fTop, devInside.fRight,
|
||||
SkPointPriv::SetRectFan(fan2Pos, devInside.fLeft, devInside.fTop, devInside.fRight,
|
||||
devInside.fBottom, vertexStride);
|
||||
fan3Pos->setRectFan(devInside.fLeft, devInside.fTop, devInside.fRight,
|
||||
SkPointPriv::SetRectFan(fan3Pos, devInside.fLeft, devInside.fTop, devInside.fRight,
|
||||
devInside.fBottom, vertexStride);
|
||||
}
|
||||
} else {
|
||||
@ -518,9 +519,9 @@ void AAStrokeRectOp::generateAAStrokeRectGeometry(void* vertices,
|
||||
} else {
|
||||
// When the interior rect has become degenerate we smoosh to a single point
|
||||
SkASSERT(devInside.fLeft == devInside.fRight && devInside.fTop == devInside.fBottom);
|
||||
fan2Pos->setRectFan(devInside.fLeft, devInside.fTop, devInside.fRight,
|
||||
SkPointPriv::SetRectFan(fan2Pos, devInside.fLeft, devInside.fTop, devInside.fRight,
|
||||
devInside.fBottom, vertexStride);
|
||||
fan3Pos->setRectFan(devInside.fLeft, devInside.fTop, devInside.fRight,
|
||||
SkPointPriv::SetRectFan(fan3Pos, devInside.fLeft, devInside.fTop, devInside.fRight,
|
||||
devInside.fBottom, vertexStride);
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "GrSimpleMeshDrawOpHelper.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkLatticeIter.h"
|
||||
#include "SkPointPriv.h"
|
||||
#include "SkRect.h"
|
||||
|
||||
static sk_sp<GrGeometryProcessor> create_gp() {
|
||||
@ -130,14 +131,14 @@ private:
|
||||
intptr_t patchVerts = verts;
|
||||
while (patch.fIter->next(&srcR, &dstR)) {
|
||||
SkPoint* positions = reinterpret_cast<SkPoint*>(verts);
|
||||
positions->setRectTriStrip(dstR.fLeft, dstR.fTop, dstR.fRight, dstR.fBottom,
|
||||
vertexStride);
|
||||
SkPointPriv::SetRectTriStrip(positions, dstR.fLeft, dstR.fTop, dstR.fRight,
|
||||
dstR.fBottom, vertexStride);
|
||||
|
||||
// Setup local coords
|
||||
static const int kLocalOffset = sizeof(SkPoint) + sizeof(GrColor);
|
||||
SkPoint* coords = reinterpret_cast<SkPoint*>(verts + kLocalOffset);
|
||||
coords->setRectTriStrip(srcR.fLeft, srcR.fTop, srcR.fRight, srcR.fBottom,
|
||||
vertexStride);
|
||||
SkPointPriv::SetRectTriStrip(coords, srcR.fLeft, srcR.fTop, srcR.fRight,
|
||||
srcR.fBottom, vertexStride);
|
||||
|
||||
static const int kColorOffset = sizeof(SkPoint);
|
||||
GrColor* vertColor = reinterpret_cast<GrColor*>(verts + kColorOffset);
|
||||
|
@ -72,7 +72,8 @@ static void tesselate(intptr_t vertices,
|
||||
const GrQuad* localQuad) {
|
||||
SkPoint* positions = reinterpret_cast<SkPoint*>(vertices);
|
||||
|
||||
positions->setRectTriStrip(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, vertexStride);
|
||||
SkPointPriv::SetRectTriStrip(positions, rect.fLeft, rect.fTop, rect.fRight, rect.fBottom,
|
||||
vertexStride);
|
||||
|
||||
if (viewMatrix) {
|
||||
SkMatrixPriv::MapPointsWithStride(*viewMatrix, positions, vertexStride, kVertsPerRect);
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "GrResourceProvider.h"
|
||||
#include "GrSimpleMeshDrawOpHelper.h"
|
||||
#include "SkMatrixPriv.h"
|
||||
#include "SkPointPriv.h"
|
||||
#include "SkRegion.h"
|
||||
|
||||
static const int kVertsPerInstance = 4;
|
||||
@ -34,7 +35,8 @@ static void tesselate_region(intptr_t vertices,
|
||||
while (!iter.done()) {
|
||||
SkRect rect = SkRect::Make(iter.rect());
|
||||
SkPoint* position = (SkPoint*)verts;
|
||||
position->setRectTriStrip(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, vertexStride);
|
||||
SkPointPriv::SetRectTriStrip(position, rect.fLeft, rect.fTop, rect.fRight, rect.fBottom,
|
||||
vertexStride);
|
||||
|
||||
static const int kColorOffset = sizeof(SkPoint);
|
||||
GrColor* vertColor = reinterpret_cast<GrColor*>(verts + kColorOffset);
|
||||
|
@ -656,7 +656,7 @@ private:
|
||||
position = (SkPoint*)positionOffset;
|
||||
*position = quad.point(3);
|
||||
} else {
|
||||
positions->setRectTriStrip(translatedBounds.left(),
|
||||
SkPointPriv::SetRectTriStrip(positions, translatedBounds.left(),
|
||||
translatedBounds.top(),
|
||||
translatedBounds.right(),
|
||||
translatedBounds.bottom(),
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "GrRenderTargetContextPriv.h"
|
||||
#include "GrResourceProvider.h"
|
||||
#include "GrQuad.h"
|
||||
#include "SkPointPriv.h"
|
||||
#include "effects/GrSimpleTextureEffect.h"
|
||||
#include "ops/GrSimpleMeshDrawOpHelper.h"
|
||||
|
||||
@ -134,7 +135,7 @@ private:
|
||||
|
||||
// Setup positions
|
||||
SkPoint* position = (SkPoint*) vertices;
|
||||
position->setRectTriStrip(fRect.fLeft, fRect.fTop, fRect.fRight, fRect.fBottom,
|
||||
SkPointPriv::SetRectTriStrip(position, fRect.fLeft, fRect.fTop, fRect.fRight, fRect.fBottom,
|
||||
vertexStride);
|
||||
|
||||
// Setup vertex colors
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "GrOpFlushState.h"
|
||||
#include "GrRenderTargetContext.h"
|
||||
#include "GrRenderTargetContextPriv.h"
|
||||
#include "SkPointPriv.h"
|
||||
#include "SkString.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLGeometryProcessor.h"
|
||||
@ -96,7 +97,7 @@ private:
|
||||
QuadHelper helper;
|
||||
size_t vertexStride = gp->getVertexStride();
|
||||
SkPoint* vertices = reinterpret_cast<SkPoint*>(helper.init(target, vertexStride, 1));
|
||||
vertices->setRectTriStrip(0.f, 0.f, 1.f, 1.f, vertexStride);
|
||||
SkPointPriv::SetRectTriStrip(vertices, 0.f, 0.f, 1.f, 1.f, vertexStride);
|
||||
helper.recordDraw(target, gp.get(),
|
||||
target->makePipeline(0, GrProcessorSet::MakeEmptySet(),
|
||||
target->detachAppliedClip()));
|
||||
|
Loading…
Reference in New Issue
Block a user