Remove GrScalar, replace with SkScalar.
Review URL: https://codereview.appspot.com/6812064 git-svn-id: http://skia.googlecode.com/svn/trunk@6243 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
35ac048e35
commit
8171288341
@ -31,7 +31,6 @@
|
||||
'<(skia_include_path)/gpu/GrRefCnt.h',
|
||||
'<(skia_include_path)/gpu/GrRenderTarget.h',
|
||||
'<(skia_include_path)/gpu/GrResource.h',
|
||||
'<(skia_include_path)/gpu/GrScalar.h',
|
||||
'<(skia_include_path)/gpu/GrSurface.h',
|
||||
'<(skia_include_path)/gpu/GrTBackendEffectFactory.h',
|
||||
'<(skia_include_path)/gpu/GrTextContext.h',
|
||||
|
@ -139,7 +139,7 @@ typedef unsigned __int64 uint64_t;
|
||||
* GR_USER_CONFIG_FILE. It should be defined relative to GrConfig.h
|
||||
*
|
||||
* e.g. it can specify GR_DEBUG/GR_RELEASE as it please, change the BUILD
|
||||
* target, or supply its own defines for anything else (e.g. GR_SCALAR)
|
||||
* target, or supply its own defines for anything else (e.g. GR_DEFAULT_TEXTURE_CACHE_MB_LIMIT)
|
||||
*/
|
||||
#if !defined(GR_USER_CONFIG_FILE)
|
||||
#include "GrUserConfig.h"
|
||||
@ -311,13 +311,6 @@ inline void GrCrash(const char* msg) { GrPrintf(msg); GrAlwaysAssert(false); }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(GR_SCALAR_IS_FLOAT)
|
||||
#define GR_SCALAR_IS_FLOAT 0
|
||||
#endif
|
||||
#if !defined(GR_SCALAR_IS_FIXED)
|
||||
#define GR_SCALAR_IS_FIXED 0
|
||||
#endif
|
||||
|
||||
#if !defined(GR_TEXT_SCALAR_TYPE_IS_USHORT)
|
||||
#define GR_TEXT_SCALAR_TYPE_IS_USHORT 0
|
||||
#endif
|
||||
@ -397,12 +390,6 @@ inline void GrCrash(const char* msg) { GrPrintf(msg); GrAlwaysAssert(false); }
|
||||
#endif
|
||||
|
||||
|
||||
#if !GR_SCALAR_IS_FLOAT && !GR_SCALAR_IS_FIXED
|
||||
#undef GR_SCALAR_IS_FLOAT
|
||||
#define GR_SCALAR_IS_FLOAT 1
|
||||
#pragma message GR_WARN("Scalar type not defined, defaulting to float")
|
||||
#endif
|
||||
|
||||
#if !GR_TEXT_SCALAR_IS_FLOAT && \
|
||||
!GR_TEXT_SCALAR_IS_FIXED && \
|
||||
!GR_TEXT_SCALAR_IS_USHORT
|
||||
|
@ -388,7 +388,7 @@ public:
|
||||
*/
|
||||
void drawRect(const GrPaint& paint,
|
||||
const GrRect&,
|
||||
GrScalar strokeWidth = -1,
|
||||
SkScalar strokeWidth = -1,
|
||||
const GrMatrix* matrix = NULL);
|
||||
|
||||
/**
|
||||
|
@ -12,7 +12,7 @@
|
||||
#define GrPoint_DEFINED
|
||||
|
||||
#include "GrTypes.h"
|
||||
#include "GrScalar.h"
|
||||
#include "SkScalar.h"
|
||||
#include "SkPoint.h"
|
||||
|
||||
#define GrPoint SkPoint
|
||||
|
@ -1,49 +0,0 @@
|
||||
|
||||
/*
|
||||
* Copyright 2010 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef GrScalar_DEFINED
|
||||
#define GrScalar_DEFINED
|
||||
|
||||
#include "GrTypes.h"
|
||||
#include "SkScalar.h"
|
||||
|
||||
#define GR_Int32Min SK_NaN32
|
||||
#define GR_Int32Max SK_MaxS32
|
||||
|
||||
#define GR_Fixed1 SK_Fixed1
|
||||
#define GR_FixedHalf SK_FixedHalf
|
||||
#define GrIntToFixed(a) SkIntToFixed(a)
|
||||
#define GrFixedToFloat(a) SkFixedToFloat(a)
|
||||
#define GrFixedFloorToInt(a) SkFixedFloor(a)
|
||||
|
||||
#define GrScalar SkScalar
|
||||
#define GR_Scalar1 SK_Scalar1
|
||||
#define GR_ScalarHalf SK_ScalarHalf
|
||||
#define GR_ScalarMin SK_ScalarMin
|
||||
#define GR_ScalarMax SK_ScalarMax
|
||||
|
||||
#define GrIntToScalar(a) SkIntToScalar(a)
|
||||
#define GrScalarHalf(a) SkScalarHalf(a)
|
||||
#define GrScalarAve(a,b) SkScalarAve(a,b)
|
||||
#define GrMul(a,b) SkScalarMul(a,b) // deprecated, prefer GrScalarMul
|
||||
#define GrScalarMul(a,b) SkScalarMul(a,b)
|
||||
#define GrScalarDiv(a,b) SkScalarDiv(a, b)
|
||||
#define GrScalarToFloat(a) SkScalarToFloat(a)
|
||||
#define GrFloatToScalar(a) SkFloatToScalar(a)
|
||||
#define GrIntToScalar(a) SkIntToScalar(a)
|
||||
#define GrScalarAbs(a) SkScalarAbs(a)
|
||||
#define GrScalarIsInt(a) SkScalarIsInt(a)
|
||||
#define GrScalarMax(a,b) SkScalarMax(a,b)
|
||||
#define GrScalarFloorToInt(a) SkScalarFloor(a)
|
||||
#define GrScalarCeilToInt(a) SkScalarCeil(a)
|
||||
#define GrFixedToScalar(a) SkFixedToScalar(a)
|
||||
|
||||
#endif
|
||||
|
@ -63,9 +63,6 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Decide Ganesh types
|
||||
|
||||
#define GR_SCALAR_IS_FIXED 0
|
||||
#define GR_SCALAR_IS_FLOAT 1
|
||||
|
||||
#define GR_TEXT_SCALAR_IS_USHORT 0
|
||||
#define GR_TEXT_SCALAR_IS_FIXED 0
|
||||
#define GR_TEXT_SCALAR_IS_FLOAT 1
|
||||
|
@ -677,7 +677,7 @@ SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
|
||||
|
||||
GrGLGradientEffect::GrGLGradientEffect(const GrBackendEffectFactory& factory)
|
||||
: INHERITED(factory)
|
||||
, fCachedYCoord(GR_ScalarMax)
|
||||
, fCachedYCoord(SK_ScalarMax)
|
||||
, fFSYUni(GrGLUniformManager::kInvalidUniformHandle) {
|
||||
fRequiresTextureMatrix = false;
|
||||
}
|
||||
@ -694,7 +694,7 @@ void GrGLGradientEffect::setData(const GrGLUniformManager& uman, const GrEffectS
|
||||
const GrTexture* texture = e.texture(0);
|
||||
fEffectMatrix.setData(uman, e.getMatrix(), stage.getCoordChangeMatrix(), texture);
|
||||
|
||||
GrScalar yCoord = e.getYCoord();
|
||||
SkScalar yCoord = e.getYCoord();
|
||||
if (yCoord != fCachedYCoord) {
|
||||
uman.set1f(fFSYUni, yCoord);
|
||||
fCachedYCoord = yCoord;
|
||||
@ -769,13 +769,13 @@ GrGradientEffect::GrGradientEffect(GrContext* ctx,
|
||||
|
||||
fRow = fAtlas->lockRow(bitmap);
|
||||
if (-1 != fRow) {
|
||||
fYCoord = fAtlas->getYOffset(fRow) + GR_ScalarHalf *
|
||||
fYCoord = fAtlas->getYOffset(fRow) + SK_ScalarHalf *
|
||||
fAtlas->getVerticalScaleFactor();
|
||||
fTextureAccess.reset(fAtlas->getTexture(), params);
|
||||
} else {
|
||||
GrTexture* texture = GrLockCachedBitmapTexture(ctx, bitmap, ¶ms);
|
||||
fTextureAccess.reset(texture, params);
|
||||
fYCoord = GR_ScalarHalf;
|
||||
fYCoord = SK_ScalarHalf;
|
||||
|
||||
// Unlock immediately, this is not great, but we don't have a way of
|
||||
// knowing when else to unlock it currently, so it may get purged from
|
||||
@ -806,7 +806,7 @@ int GrGradientEffect::RandomGradientParams(SkRandom* random,
|
||||
*stops = NULL;
|
||||
}
|
||||
|
||||
GrScalar stop = 0.f;
|
||||
SkScalar stop = 0.f;
|
||||
for (int i = 0; i < outColors; ++i) {
|
||||
colors[i] = random->nextU();
|
||||
if (NULL != *stops) {
|
||||
|
@ -237,7 +237,7 @@ public:
|
||||
virtual const GrTextureAccess& textureAccess(int index) const SK_OVERRIDE;
|
||||
|
||||
bool useAtlas() const { return SkToBool(-1 != fRow); }
|
||||
GrScalar getYCoord() const { return fYCoord; };
|
||||
SkScalar getYCoord() const { return fYCoord; };
|
||||
const SkMatrix& getMatrix() const { return fMatrix;}
|
||||
|
||||
virtual bool isEqual(const GrEffect& effect) const SK_OVERRIDE {
|
||||
@ -263,7 +263,7 @@ protected:
|
||||
|
||||
private:
|
||||
GrTextureAccess fTextureAccess;
|
||||
GrScalar fYCoord;
|
||||
SkScalar fYCoord;
|
||||
GrTextureStripAtlas* fAtlas;
|
||||
int fRow;
|
||||
SkMatrix fMatrix;
|
||||
@ -327,7 +327,7 @@ protected:
|
||||
const GrGLShaderBuilder::TextureSampler&);
|
||||
|
||||
private:
|
||||
GrScalar fCachedYCoord;
|
||||
SkScalar fCachedYCoord;
|
||||
GrGLUniformManager::UniformHandle fFSYUni;
|
||||
GrGLEffectMatrix fEffectMatrix;
|
||||
|
||||
|
@ -352,9 +352,9 @@ protected:
|
||||
// @{
|
||||
/// Values last uploaded as uniforms
|
||||
|
||||
GrScalar fCachedCenter;
|
||||
GrScalar fCachedRadius;
|
||||
GrScalar fCachedDiffRadius;
|
||||
SkScalar fCachedCenter;
|
||||
SkScalar fCachedRadius;
|
||||
SkScalar fCachedDiffRadius;
|
||||
|
||||
// @}
|
||||
|
||||
@ -394,9 +394,9 @@ public:
|
||||
|
||||
// The radial gradient parameters can collapse to a linear (instead of quadratic) equation.
|
||||
bool isDegenerate() const { return SkScalarAbs(fDiffRadius) == SkScalarAbs(fCenterX1); }
|
||||
GrScalar center() const { return fCenterX1; }
|
||||
GrScalar diffRadius() const { return fDiffRadius; }
|
||||
GrScalar radius() const { return fRadius0; }
|
||||
SkScalar center() const { return fCenterX1; }
|
||||
SkScalar diffRadius() const { return fDiffRadius; }
|
||||
SkScalar radius() const { return fRadius0; }
|
||||
|
||||
typedef GrGLConical2Gradient GLEffect;
|
||||
|
||||
@ -407,9 +407,9 @@ private:
|
||||
// Cache of values - these can change arbitrarily, EXCEPT
|
||||
// we shouldn't change between degenerate and non-degenerate?!
|
||||
|
||||
GrScalar fCenterX1;
|
||||
GrScalar fRadius0;
|
||||
GrScalar fDiffRadius;
|
||||
SkScalar fCenterX1;
|
||||
SkScalar fRadius0;
|
||||
SkScalar fDiffRadius;
|
||||
|
||||
// @}
|
||||
|
||||
@ -459,9 +459,9 @@ GrGLConical2Gradient::GrGLConical2Gradient(
|
||||
, fFSParamUni(kInvalidUniformHandle)
|
||||
, fVSVaryingName(NULL)
|
||||
, fFSVaryingName(NULL)
|
||||
, fCachedCenter(GR_ScalarMax)
|
||||
, fCachedRadius(-GR_ScalarMax)
|
||||
, fCachedDiffRadius(-GR_ScalarMax) {
|
||||
, fCachedCenter(SK_ScalarMax)
|
||||
, fCachedRadius(-SK_ScalarMax)
|
||||
, fCachedDiffRadius(-SK_ScalarMax) {
|
||||
|
||||
const GrConical2Gradient& data =
|
||||
static_cast<const GrConical2Gradient&>(baseData);
|
||||
@ -642,15 +642,15 @@ void GrGLConical2Gradient::setData(const GrGLUniformManager& uman, const GrEffec
|
||||
INHERITED::setData(uman, stage);
|
||||
const GrConical2Gradient& data = static_cast<const GrConical2Gradient&>(*stage.getEffect());
|
||||
GrAssert(data.isDegenerate() == fIsDegenerate);
|
||||
GrScalar centerX1 = data.center();
|
||||
GrScalar radius0 = data.radius();
|
||||
GrScalar diffRadius = data.diffRadius();
|
||||
SkScalar centerX1 = data.center();
|
||||
SkScalar radius0 = data.radius();
|
||||
SkScalar diffRadius = data.diffRadius();
|
||||
|
||||
if (fCachedCenter != centerX1 ||
|
||||
fCachedRadius != radius0 ||
|
||||
fCachedDiffRadius != diffRadius) {
|
||||
|
||||
GrScalar a = GrMul(centerX1, centerX1) - diffRadius * diffRadius;
|
||||
SkScalar a = SkScalarMul(centerX1, centerX1) - diffRadius * diffRadius;
|
||||
|
||||
// When we're in the degenerate (linear) case, the second
|
||||
// value will be INF but the program doesn't read it. (We
|
||||
@ -658,12 +658,12 @@ void GrGLConical2Gradient::setData(const GrGLUniformManager& uman, const GrEffec
|
||||
// all in the linear case just to keep the code complexity
|
||||
// down).
|
||||
float values[6] = {
|
||||
GrScalarToFloat(a * 4),
|
||||
1.f / (GrScalarToFloat(a)),
|
||||
GrScalarToFloat(centerX1),
|
||||
GrScalarToFloat(radius0),
|
||||
GrScalarToFloat(SkScalarMul(radius0, radius0)),
|
||||
GrScalarToFloat(diffRadius)
|
||||
SkScalarToFloat(a * 4),
|
||||
1.f / (SkScalarToFloat(a)),
|
||||
SkScalarToFloat(centerX1),
|
||||
SkScalarToFloat(radius0),
|
||||
SkScalarToFloat(SkScalarMul(radius0, radius0)),
|
||||
SkScalarToFloat(diffRadius)
|
||||
};
|
||||
|
||||
uman.set1fv(fVSParamUni, 0, 6, values);
|
||||
|
@ -387,8 +387,8 @@ protected:
|
||||
// @{
|
||||
/// Values last uploaded as uniforms
|
||||
|
||||
GrScalar fCachedCenter;
|
||||
GrScalar fCachedRadius;
|
||||
SkScalar fCachedCenter;
|
||||
SkScalar fCachedRadius;
|
||||
bool fCachedPosRoot;
|
||||
|
||||
// @}
|
||||
@ -427,9 +427,9 @@ public:
|
||||
}
|
||||
|
||||
// The radial gradient parameters can collapse to a linear (instead of quadratic) equation.
|
||||
bool isDegenerate() const { return GR_Scalar1 == fCenterX1; }
|
||||
GrScalar center() const { return fCenterX1; }
|
||||
GrScalar radius() const { return fRadius0; }
|
||||
bool isDegenerate() const { return SK_Scalar1 == fCenterX1; }
|
||||
SkScalar center() const { return fCenterX1; }
|
||||
SkScalar radius() const { return fRadius0; }
|
||||
bool isPosRoot() const { return SkToBool(fPosRoot); }
|
||||
|
||||
typedef GrGLRadial2Gradient GLEffect;
|
||||
@ -441,8 +441,8 @@ private:
|
||||
// Cache of values - these can change arbitrarily, EXCEPT
|
||||
// we shouldn't change between degenerate and non-degenerate?!
|
||||
|
||||
GrScalar fCenterX1;
|
||||
GrScalar fRadius0;
|
||||
SkScalar fCenterX1;
|
||||
SkScalar fRadius0;
|
||||
SkBool8 fPosRoot;
|
||||
|
||||
// @}
|
||||
@ -494,8 +494,8 @@ GrGLRadial2Gradient::GrGLRadial2Gradient(
|
||||
, fFSParamUni(kInvalidUniformHandle)
|
||||
, fVSVaryingName(NULL)
|
||||
, fFSVaryingName(NULL)
|
||||
, fCachedCenter(GR_ScalarMax)
|
||||
, fCachedRadius(-GR_ScalarMax)
|
||||
, fCachedCenter(SK_ScalarMax)
|
||||
, fCachedRadius(-SK_ScalarMax)
|
||||
, fCachedPosRoot(0) {
|
||||
|
||||
const GrRadial2Gradient& data =
|
||||
@ -618,13 +618,13 @@ void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman, const GrEffect
|
||||
INHERITED::setData(uman, stage);
|
||||
const GrRadial2Gradient& data = static_cast<const GrRadial2Gradient&>(*stage.getEffect());
|
||||
GrAssert(data.isDegenerate() == fIsDegenerate);
|
||||
GrScalar centerX1 = data.center();
|
||||
GrScalar radius0 = data.radius();
|
||||
SkScalar centerX1 = data.center();
|
||||
SkScalar radius0 = data.radius();
|
||||
if (fCachedCenter != centerX1 ||
|
||||
fCachedRadius != radius0 ||
|
||||
fCachedPosRoot != data.isPosRoot()) {
|
||||
|
||||
GrScalar a = GrMul(centerX1, centerX1) - GR_Scalar1;
|
||||
SkScalar a = SkScalarMul(centerX1, centerX1) - SK_Scalar1;
|
||||
|
||||
// When we're in the degenerate (linear) case, the second
|
||||
// value will be INF but the program doesn't read it. (We
|
||||
@ -632,11 +632,11 @@ void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman, const GrEffect
|
||||
// all in the linear case just to keep the code complexity
|
||||
// down).
|
||||
float values[6] = {
|
||||
GrScalarToFloat(a),
|
||||
1 / (2.f * GrScalarToFloat(a)),
|
||||
GrScalarToFloat(centerX1),
|
||||
GrScalarToFloat(radius0),
|
||||
GrScalarToFloat(GrMul(radius0, radius0)),
|
||||
SkScalarToFloat(a),
|
||||
1 / (2.f * SkScalarToFloat(a)),
|
||||
SkScalarToFloat(centerX1),
|
||||
SkScalarToFloat(radius0),
|
||||
SkScalarToFloat(SkScalarMul(radius0, radius0)),
|
||||
data.isPosRoot() ? 1.f : -1.f
|
||||
};
|
||||
|
||||
|
@ -52,7 +52,7 @@ struct Segment {
|
||||
typedef SkTArray<Segment, true> SegmentArray;
|
||||
|
||||
void center_of_mass(const SegmentArray& segments, SkPoint* c) {
|
||||
GrScalar area = 0;
|
||||
SkScalar area = 0;
|
||||
SkPoint center = {0, 0};
|
||||
int count = segments.count();
|
||||
SkPoint p0 = {0, 0};
|
||||
@ -71,7 +71,7 @@ void center_of_mass(const SegmentArray& segments, SkPoint* c) {
|
||||
pi = pj;
|
||||
const SkPoint pj = segments[i + 1].endPt() - p0;
|
||||
|
||||
GrScalar t = GrMul(pi.fX, pj.fY) - GrMul(pj.fX, pi.fY);
|
||||
SkScalar t = SkScalarMul(pi.fX, pj.fY) - SkScalarMul(pj.fX, pi.fY);
|
||||
area += t;
|
||||
center.fX += (pi.fX + pj.fX) * t;
|
||||
center.fY += (pi.fY + pj.fY) * t;
|
||||
@ -93,9 +93,9 @@ void center_of_mass(const SegmentArray& segments, SkPoint* c) {
|
||||
*c = avg;
|
||||
} else {
|
||||
area *= 3;
|
||||
area = GrScalarDiv(GR_Scalar1, area);
|
||||
center.fX = GrScalarMul(center.fX, area);
|
||||
center.fY = GrScalarMul(center.fY, area);
|
||||
area = SkScalarDiv(SK_Scalar1, area);
|
||||
center.fX = SkScalarMul(center.fX, area);
|
||||
center.fY = SkScalarMul(center.fY, area);
|
||||
// undo the translate of p0 to the origin.
|
||||
*c = center + p0;
|
||||
}
|
||||
@ -168,7 +168,7 @@ struct DegenerateTestData {
|
||||
} fStage;
|
||||
GrPoint fFirstPoint;
|
||||
GrVec fLineNormal;
|
||||
GrScalar fLineC;
|
||||
SkScalar fLineC;
|
||||
};
|
||||
|
||||
void update_degenerate_test(DegenerateTestData* data, const GrPoint& pt) {
|
||||
@ -206,8 +206,8 @@ inline bool get_direction(const SkPath& path, const GrMatrix& m, SkPath::Directi
|
||||
}
|
||||
// check whether m reverses the orientation
|
||||
GrAssert(!m.hasPerspective());
|
||||
GrScalar det2x2 = GrMul(m.get(SkMatrix::kMScaleX), m.get(SkMatrix::kMScaleY)) -
|
||||
GrMul(m.get(SkMatrix::kMSkewX), m.get(SkMatrix::kMSkewY));
|
||||
SkScalar det2x2 = SkScalarMul(m.get(SkMatrix::kMScaleX), m.get(SkMatrix::kMScaleY)) -
|
||||
SkScalarMul(m.get(SkMatrix::kMSkewX), m.get(SkMatrix::kMSkewY));
|
||||
if (det2x2 < 0) {
|
||||
GR_STATIC_ASSERT(0 == SkPath::kCW_Direction || 1 == SkPath::kCW_Direction);
|
||||
GR_STATIC_ASSERT(0 == SkPath::kCCW_Direction || 1 == SkPath::kCCW_Direction);
|
||||
@ -296,8 +296,8 @@ bool get_segments(const SkPath& path,
|
||||
struct QuadVertex {
|
||||
GrPoint fPos;
|
||||
GrPoint fUV;
|
||||
GrScalar fD0;
|
||||
GrScalar fD1;
|
||||
SkScalar fD0;
|
||||
SkScalar fD1;
|
||||
};
|
||||
|
||||
void create_vertices(const SegmentArray& segments,
|
||||
@ -347,7 +347,7 @@ void create_vertices(const SegmentArray& segments,
|
||||
|
||||
// we draw the line edge as a degenerate quad (u is 0, v is the
|
||||
// signed distance to the edge)
|
||||
GrScalar dist = fanPt.distanceToLineBetween(verts[v + 1].fPos,
|
||||
SkScalar dist = fanPt.distanceToLineBetween(verts[v + 1].fPos,
|
||||
verts[v + 2].fPos);
|
||||
verts[v + 0].fUV.set(0, dist);
|
||||
verts[v + 1].fUV.set(0, 0);
|
||||
@ -388,21 +388,21 @@ void create_vertices(const SegmentArray& segments,
|
||||
verts[v + 4].fPos = qpts[2] + segb.fNorms[1];
|
||||
verts[v + 5].fPos = qpts[1] + midVec;
|
||||
|
||||
GrScalar c = segb.fNorms[0].dot(qpts[0]);
|
||||
SkScalar c = segb.fNorms[0].dot(qpts[0]);
|
||||
verts[v + 0].fD0 = -segb.fNorms[0].dot(fanPt) + c;
|
||||
verts[v + 1].fD0 = 0.f;
|
||||
verts[v + 2].fD0 = -segb.fNorms[0].dot(qpts[2]) + c;
|
||||
verts[v + 3].fD0 = -GR_ScalarMax/100;
|
||||
verts[v + 4].fD0 = -GR_ScalarMax/100;
|
||||
verts[v + 5].fD0 = -GR_ScalarMax/100;
|
||||
verts[v + 3].fD0 = -SK_ScalarMax/100;
|
||||
verts[v + 4].fD0 = -SK_ScalarMax/100;
|
||||
verts[v + 5].fD0 = -SK_ScalarMax/100;
|
||||
|
||||
c = segb.fNorms[1].dot(qpts[2]);
|
||||
verts[v + 0].fD1 = -segb.fNorms[1].dot(fanPt) + c;
|
||||
verts[v + 1].fD1 = -segb.fNorms[1].dot(qpts[0]) + c;
|
||||
verts[v + 2].fD1 = 0.f;
|
||||
verts[v + 3].fD1 = -GR_ScalarMax/100;
|
||||
verts[v + 4].fD1 = -GR_ScalarMax/100;
|
||||
verts[v + 5].fD1 = -GR_ScalarMax/100;
|
||||
verts[v + 3].fD1 = -SK_ScalarMax/100;
|
||||
verts[v + 4].fD1 = -SK_ScalarMax/100;
|
||||
verts[v + 5].fD1 = -SK_ScalarMax/100;
|
||||
|
||||
GrPathUtils::QuadUVMatrix toUV(qpts);
|
||||
toUV.apply<6, sizeof(QuadVertex), sizeof(GrPoint)>(verts + v);
|
||||
|
@ -147,7 +147,7 @@ int num_quad_subdivs(const SkPoint p[3]) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
GrScalar dsqd = p[1].distanceToLineBetweenSqd(p[0], p[2]);
|
||||
SkScalar dsqd = p[1].distanceToLineBetweenSqd(p[0], p[2]);
|
||||
if (dsqd < gDegenerateToLineTolSqd) {
|
||||
return -1;
|
||||
}
|
||||
@ -322,13 +322,13 @@ struct Vertex {
|
||||
GrPoint fPos;
|
||||
union {
|
||||
struct {
|
||||
GrScalar fA;
|
||||
GrScalar fB;
|
||||
GrScalar fC;
|
||||
SkScalar fA;
|
||||
SkScalar fB;
|
||||
SkScalar fC;
|
||||
} fLine;
|
||||
GrVec fQuadCoord;
|
||||
struct {
|
||||
GrScalar fBogus[4];
|
||||
SkScalar fBogus[4];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -25,7 +25,7 @@ static GrVertexLayout aa_rect_layout(const GrDrawTarget* target,
|
||||
}
|
||||
|
||||
static void setInsetFan(GrPoint* pts, size_t stride,
|
||||
const GrRect& r, GrScalar dx, GrScalar dy) {
|
||||
const GrRect& r, SkScalar dx, SkScalar dy) {
|
||||
pts->setRectFan(r.fLeft + dx, r.fTop + dy,
|
||||
r.fRight - dx, r.fBottom - dy, stride);
|
||||
}
|
||||
@ -126,8 +126,8 @@ void GrAARectRenderer::fillAARect(GrGpu* gpu,
|
||||
GrPoint* fan0Pos = reinterpret_cast<GrPoint*>(verts);
|
||||
GrPoint* fan1Pos = reinterpret_cast<GrPoint*>(verts + 4 * vsize);
|
||||
|
||||
setInsetFan(fan0Pos, vsize, devRect, -GR_ScalarHalf, -GR_ScalarHalf);
|
||||
setInsetFan(fan1Pos, vsize, devRect, GR_ScalarHalf, GR_ScalarHalf);
|
||||
setInsetFan(fan0Pos, vsize, devRect, -SK_ScalarHalf, -SK_ScalarHalf);
|
||||
setInsetFan(fan1Pos, vsize, devRect, SK_ScalarHalf, SK_ScalarHalf);
|
||||
|
||||
verts += sizeof(GrPoint);
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
@ -157,15 +157,15 @@ void GrAARectRenderer::strokeAARect(GrGpu* gpu,
|
||||
const GrRect& devRect,
|
||||
const GrVec& devStrokeSize,
|
||||
bool useVertexCoverage) {
|
||||
const GrScalar& dx = devStrokeSize.fX;
|
||||
const GrScalar& dy = devStrokeSize.fY;
|
||||
const GrScalar rx = GrMul(dx, GR_ScalarHalf);
|
||||
const GrScalar ry = GrMul(dy, GR_ScalarHalf);
|
||||
const SkScalar& dx = devStrokeSize.fX;
|
||||
const SkScalar& dy = devStrokeSize.fY;
|
||||
const SkScalar rx = SkScalarMul(dx, SK_ScalarHalf);
|
||||
const SkScalar ry = SkScalarMul(dy, SK_ScalarHalf);
|
||||
|
||||
GrScalar spare;
|
||||
SkScalar spare;
|
||||
{
|
||||
GrScalar w = devRect.width() - dx;
|
||||
GrScalar h = devRect.height() - dy;
|
||||
SkScalar w = devRect.width() - dx;
|
||||
SkScalar h = devRect.height() - dy;
|
||||
spare = GrMin(w, h);
|
||||
}
|
||||
|
||||
@ -200,13 +200,13 @@ void GrAARectRenderer::strokeAARect(GrGpu* gpu,
|
||||
GrPoint* fan3Pos = reinterpret_cast<GrPoint*>(verts + 12 * vsize);
|
||||
|
||||
setInsetFan(fan0Pos, vsize, devRect,
|
||||
-rx - GR_ScalarHalf, -ry - GR_ScalarHalf);
|
||||
-rx - SK_ScalarHalf, -ry - SK_ScalarHalf);
|
||||
setInsetFan(fan1Pos, vsize, devRect,
|
||||
-rx + GR_ScalarHalf, -ry + GR_ScalarHalf);
|
||||
-rx + SK_ScalarHalf, -ry + SK_ScalarHalf);
|
||||
setInsetFan(fan2Pos, vsize, devRect,
|
||||
rx - GR_ScalarHalf, ry - GR_ScalarHalf);
|
||||
rx - SK_ScalarHalf, ry - SK_ScalarHalf);
|
||||
setInsetFan(fan3Pos, vsize, devRect,
|
||||
rx + GR_ScalarHalf, ry + GR_ScalarHalf);
|
||||
rx + SK_ScalarHalf, ry + SK_ScalarHalf);
|
||||
|
||||
// The outermost rect has 0 coverage
|
||||
verts += sizeof(GrPoint);
|
||||
|
@ -575,8 +575,8 @@ void GrContext::drawPaint(const GrPaint& origPaint) {
|
||||
// don't overflow fixed-point implementations
|
||||
GrRect r;
|
||||
r.setLTRB(0, 0,
|
||||
GrIntToScalar(getRenderTarget()->width()),
|
||||
GrIntToScalar(getRenderTarget()->height()));
|
||||
SkIntToScalar(getRenderTarget()->width()),
|
||||
SkIntToScalar(getRenderTarget()->height()));
|
||||
GrMatrix inverse;
|
||||
SkTCopyOnFirstWrite<GrPaint> paint(origPaint);
|
||||
AutoMatrix am;
|
||||
@ -619,8 +619,8 @@ inline bool disable_coverage_aa_for_blend(GrDrawTarget* target) {
|
||||
would be faster.
|
||||
*/
|
||||
static void setStrokeRectStrip(GrPoint verts[10], GrRect rect,
|
||||
GrScalar width) {
|
||||
const GrScalar rad = GrScalarHalf(width);
|
||||
SkScalar width) {
|
||||
const SkScalar rad = SkScalarHalf(width);
|
||||
rect.sort();
|
||||
|
||||
verts[0].set(rect.fLeft + rad, rect.fTop + rad);
|
||||
@ -639,13 +639,13 @@ static void setStrokeRectStrip(GrPoint verts[10], GrRect rect,
|
||||
* Returns true if the rects edges are integer-aligned.
|
||||
*/
|
||||
static bool isIRect(const GrRect& r) {
|
||||
return GrScalarIsInt(r.fLeft) && GrScalarIsInt(r.fTop) &&
|
||||
GrScalarIsInt(r.fRight) && GrScalarIsInt(r.fBottom);
|
||||
return SkScalarIsInt(r.fLeft) && SkScalarIsInt(r.fTop) &&
|
||||
SkScalarIsInt(r.fRight) && SkScalarIsInt(r.fBottom);
|
||||
}
|
||||
|
||||
static bool apply_aa_to_rect(GrDrawTarget* target,
|
||||
const GrRect& rect,
|
||||
GrScalar width,
|
||||
SkScalar width,
|
||||
const GrMatrix* matrix,
|
||||
GrMatrix* combinedMatrix,
|
||||
GrRect* devRect,
|
||||
@ -705,7 +705,7 @@ static bool apply_aa_to_rect(GrDrawTarget* target,
|
||||
|
||||
void GrContext::drawRect(const GrPaint& paint,
|
||||
const GrRect& rect,
|
||||
GrScalar width,
|
||||
SkScalar width,
|
||||
const GrMatrix* matrix) {
|
||||
SK_TRACE_EVENT0("GrContext::drawRect");
|
||||
|
||||
@ -733,7 +733,7 @@ void GrContext::drawRect(const GrPaint& paint,
|
||||
combinedMatrix.mapVectors(&strokeSize, 1);
|
||||
strokeSize.setAbs(strokeSize);
|
||||
} else {
|
||||
strokeSize.set(GR_Scalar1, GR_Scalar1);
|
||||
strokeSize.set(SK_Scalar1, SK_Scalar1);
|
||||
}
|
||||
fAARectRenderer->strokeAARect(this->getGpu(), target, devRect,
|
||||
strokeSize, useVertexCoverage);
|
||||
@ -940,8 +940,8 @@ namespace {
|
||||
struct CircleVertex {
|
||||
GrPoint fPos;
|
||||
GrPoint fCenter;
|
||||
GrScalar fOuterRadius;
|
||||
GrScalar fInnerRadius;
|
||||
SkScalar fOuterRadius;
|
||||
SkScalar fInnerRadius;
|
||||
};
|
||||
|
||||
/* Returns true if will map a circle to another circle. This can be true
|
||||
@ -1014,13 +1014,13 @@ void GrContext::drawOval(const GrPaint& paint,
|
||||
GrAssert(sizeof(CircleVertex) == GrDrawTarget::VertexSize(layout));
|
||||
|
||||
GrPoint center = GrPoint::Make(rect.centerX(), rect.centerY());
|
||||
GrScalar radius = SkScalarHalf(rect.width());
|
||||
SkScalar radius = SkScalarHalf(rect.width());
|
||||
|
||||
vm.mapPoints(¢er, 1);
|
||||
radius = vm.mapRadius(radius);
|
||||
|
||||
GrScalar outerRadius = radius;
|
||||
GrScalar innerRadius = 0;
|
||||
SkScalar outerRadius = radius;
|
||||
SkScalar innerRadius = 0;
|
||||
SkScalar halfWidth = 0;
|
||||
if (strokeWidth == 0) {
|
||||
halfWidth = SkScalarHalf(SK_Scalar1);
|
||||
@ -1313,7 +1313,7 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
|
||||
if (flipY) {
|
||||
textureMatrix.setTranslate(SK_Scalar1 * left,
|
||||
SK_Scalar1 * (top + height));
|
||||
textureMatrix.set(GrMatrix::kMScaleY, -GR_Scalar1);
|
||||
textureMatrix.set(GrMatrix::kMScaleY, -SK_Scalar1);
|
||||
} else {
|
||||
textureMatrix.setTranslate(SK_Scalar1 *left, SK_Scalar1 *top);
|
||||
}
|
||||
@ -1345,7 +1345,7 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
|
||||
*drawState->stage(0) = stage;
|
||||
|
||||
drawState->setRenderTarget(texture->asRenderTarget());
|
||||
GrRect rect = GrRect::MakeWH(GrIntToScalar(width), GrIntToScalar(height));
|
||||
GrRect rect = GrRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
|
||||
fGpu->drawSimpleRect(rect, NULL);
|
||||
// we want to read back from the scratch's origin
|
||||
left = 0;
|
||||
@ -1561,7 +1561,7 @@ void GrContext::writeRenderTargetPixels(GrRenderTarget* target,
|
||||
*drawState->stage(0) = stage;
|
||||
|
||||
GrMatrix matrix;
|
||||
matrix.setTranslate(GrIntToScalar(left), GrIntToScalar(top));
|
||||
matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top));
|
||||
drawState->setViewMatrix(matrix);
|
||||
drawState->setRenderTarget(target);
|
||||
|
||||
|
@ -183,7 +183,7 @@ static inline void append_countour_edge_indices(GrPathFill fillType,
|
||||
|
||||
bool GrDefaultPathRenderer::createGeom(const SkPath& path,
|
||||
GrPathFill fill,
|
||||
GrScalar srcSpaceTol,
|
||||
SkScalar srcSpaceTol,
|
||||
GrDrawTarget* target,
|
||||
GrPrimitiveType* primType,
|
||||
int* vertexCnt,
|
||||
@ -192,7 +192,7 @@ bool GrDefaultPathRenderer::createGeom(const SkPath& path,
|
||||
{
|
||||
SK_TRACE_EVENT0("GrDefaultPathRenderer::createGeom");
|
||||
|
||||
GrScalar srcSpaceTolSqd = GrMul(srcSpaceTol, srcSpaceTol);
|
||||
SkScalar srcSpaceTolSqd = SkScalarMul(srcSpaceTol, srcSpaceTol);
|
||||
int contourCnt;
|
||||
int maxPts = GrPathUtils::worstCasePointCount(path, &contourCnt,
|
||||
srcSpaceTol);
|
||||
@ -321,7 +321,7 @@ bool GrDefaultPathRenderer::internalDrawPath(const SkPath& path,
|
||||
bool stencilOnly) {
|
||||
|
||||
GrMatrix viewM = target->getDrawState().getViewMatrix();
|
||||
GrScalar tol = GR_Scalar1;
|
||||
SkScalar tol = SK_Scalar1;
|
||||
tol = GrPathUtils::scaleToleranceToSrc(tol, viewM, path.getBounds());
|
||||
|
||||
int vertexCnt;
|
||||
@ -455,8 +455,8 @@ bool GrDefaultPathRenderer::internalDrawPath(const SkPath& path,
|
||||
GrAssert(NULL != drawState->getRenderTarget());
|
||||
// draw over the whole world.
|
||||
bounds.setLTRB(0, 0,
|
||||
GrIntToScalar(drawState->getRenderTarget()->width()),
|
||||
GrIntToScalar(drawState->getRenderTarget()->height()));
|
||||
SkIntToScalar(drawState->getRenderTarget()->width()),
|
||||
SkIntToScalar(drawState->getRenderTarget()->height()));
|
||||
GrMatrix vmi;
|
||||
// mapRect through persp matrix may not be correct
|
||||
if (!drawState->getViewMatrix().hasPerspective() &&
|
||||
|
@ -48,7 +48,7 @@ private:
|
||||
|
||||
bool createGeom(const SkPath& path,
|
||||
GrPathFill fill,
|
||||
GrScalar srcSpaceTol,
|
||||
SkScalar srcSpaceTol,
|
||||
GrDrawTarget* target,
|
||||
GrPrimitiveType* primType,
|
||||
int* vertexCnt,
|
||||
|
@ -662,7 +662,7 @@ public:
|
||||
|
||||
/**
|
||||
* When specifying edges as vertex data this enum specifies what type of
|
||||
* edges are in use. The edges are always 4 GrScalars in memory, even when
|
||||
* edges are in use. The edges are always 4 SkScalars in memory, even when
|
||||
* the edge type requires fewer than 4.
|
||||
*
|
||||
* TODO: Fix the fact that HairLine and Circle edge types use y-down coords.
|
||||
|
@ -126,7 +126,7 @@ size_t GrDrawTarget::VertexSize(GrVertexLayout vertexLayout) {
|
||||
size += sizeof(GrColor);
|
||||
}
|
||||
if (vertexLayout & kEdge_VertexLayoutBit) {
|
||||
size += 4 * sizeof(GrScalar);
|
||||
size += 4 * sizeof(SkScalar);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
@ -269,7 +269,7 @@ int GrDrawTarget::VertexSizeAndOffsetsByIdx(
|
||||
if (NULL != edgeOffset) {
|
||||
*edgeOffset = size;
|
||||
}
|
||||
size += 4 * sizeof(GrScalar);
|
||||
size += 4 * sizeof(SkScalar);
|
||||
} else {
|
||||
if (NULL != edgeOffset) {
|
||||
*edgeOffset = -1;
|
||||
|
@ -307,14 +307,14 @@ const GrVertexBuffer* GrGpu::getUnitSquareVertexBuffer() const {
|
||||
|
||||
static const GrPoint DATA[] = {
|
||||
{ 0, 0 },
|
||||
{ GR_Scalar1, 0 },
|
||||
{ GR_Scalar1, GR_Scalar1 },
|
||||
{ 0, GR_Scalar1 }
|
||||
{ SK_Scalar1, 0 },
|
||||
{ SK_Scalar1, SK_Scalar1 },
|
||||
{ 0, SK_Scalar1 }
|
||||
#if 0
|
||||
GrPoint(0, 0),
|
||||
GrPoint(GR_Scalar1,0),
|
||||
GrPoint(GR_Scalar1,GR_Scalar1),
|
||||
GrPoint(0, GR_Scalar1)
|
||||
GrPoint(SK_Scalar1,0),
|
||||
GrPoint(SK_Scalar1,SK_Scalar1),
|
||||
GrPoint(0, SK_Scalar1)
|
||||
#endif
|
||||
};
|
||||
static const size_t SIZE = sizeof(DATA);
|
||||
|
@ -20,12 +20,12 @@
|
||||
#define GrFixedToTextScalar(x) (x)
|
||||
#elif GR_TEXT_SCALAR_IS_FIXED
|
||||
typedef GrFixed GrTextScalar;
|
||||
#define GrIntToTextScalar(x) GrIntToFixed(x)
|
||||
#define GrIntToTextScalar(x) SkIntToFixed(x)
|
||||
#define GrFixedToTextScalar(x) (x)
|
||||
#elif GR_TEXT_SCALAR_IS_FLOAT
|
||||
typedef float GrTextScalar;
|
||||
#define GrIntToTextScalar(x) ((GrTextScalar)x)
|
||||
#define GrFixedToTextScalar(x) GrFixedToFloat(x)
|
||||
#define GrFixedToTextScalar(x) SkFixedToFloat(x)
|
||||
#else
|
||||
#error "Text scalar type not defined"
|
||||
#endif
|
||||
|
@ -182,16 +182,16 @@ void GrInOrderDrawBuffer::drawRect(const GrRect& rect,
|
||||
// conservative test fails.
|
||||
const GrRenderTarget* target = drawState->getRenderTarget();
|
||||
if (0 >= devClipRect.fLeft) {
|
||||
devClipRect.fLeft = GR_ScalarMin;
|
||||
devClipRect.fLeft = SK_ScalarMin;
|
||||
}
|
||||
if (target->width() <= devClipRect.fRight) {
|
||||
devClipRect.fRight = GR_ScalarMax;
|
||||
devClipRect.fRight = SK_ScalarMax;
|
||||
}
|
||||
if (0 >= devClipRect.top()) {
|
||||
devClipRect.fTop = GR_ScalarMin;
|
||||
devClipRect.fTop = SK_ScalarMin;
|
||||
}
|
||||
if (target->height() <= devClipRect.fBottom) {
|
||||
devClipRect.fBottom = GR_ScalarMax;
|
||||
devClipRect.fBottom = SK_ScalarMax;
|
||||
}
|
||||
int stride = VertexSize(layout);
|
||||
bool insideClip = true;
|
||||
|
@ -13,13 +13,13 @@
|
||||
#include <stddef.h>
|
||||
|
||||
#if 0
|
||||
#if GR_SCALAR_IS_FLOAT
|
||||
const GrScalar GrMatrix::gRESCALE(GR_Scalar1);
|
||||
#if SK_SCALAR_IS_FLOAT
|
||||
const SkScalar GrMatrix::gRESCALE(SK_Scalar1);
|
||||
#else
|
||||
GR_STATIC_ASSERT(GR_SCALAR_IS_FIXED);
|
||||
GR_STATIC_ASSERT(SK_SCALAR_IS_FIXED);
|
||||
// fixed point isn't supported right now
|
||||
GR_STATIC_ASSERT(false);
|
||||
const GrScalar GrMatrix::gRESCALE(1 << 30);
|
||||
const SkScalar GrMatrix::gRESCALE(1 << 30);
|
||||
#endif
|
||||
|
||||
const GrMatrix::MapProc GrMatrix::gMapProcs[] = {
|
||||
@ -65,29 +65,29 @@ const GrMatrix::MapProc GrMatrix::gMapProcs[] = {
|
||||
};
|
||||
|
||||
void GrMatrix::setIdentity() {
|
||||
fM[0] = GR_Scalar1; fM[1] = 0; fM[2] = 0;
|
||||
fM[3] = 0; fM[4] = GR_Scalar1; fM[5] = 0;
|
||||
fM[0] = SK_Scalar1; fM[1] = 0; fM[2] = 0;
|
||||
fM[3] = 0; fM[4] = SK_Scalar1; fM[5] = 0;
|
||||
fM[6] = 0; fM[7] = 0; fM[8] = gRESCALE;
|
||||
fTypeMask = 0;
|
||||
}
|
||||
|
||||
void GrMatrix::setTranslate(GrScalar dx, GrScalar dy) {
|
||||
fM[0] = GR_Scalar1; fM[1] = 0; fM[2] = dx;
|
||||
fM[3] = 0; fM[4] = GR_Scalar1; fM[5] = dy;
|
||||
void GrMatrix::setTranslate(SkScalar dx, SkScalar dy) {
|
||||
fM[0] = SK_Scalar1; fM[1] = 0; fM[2] = dx;
|
||||
fM[3] = 0; fM[4] = SK_Scalar1; fM[5] = dy;
|
||||
fM[6] = 0; fM[7] = 0; fM[8] = gRESCALE;
|
||||
fTypeMask = (0 != dx || 0 != dy) ? kTranslate_TypeBit : 0;
|
||||
}
|
||||
|
||||
void GrMatrix::setScale(GrScalar sx, GrScalar sy) {
|
||||
void GrMatrix::setScale(SkScalar sx, SkScalar sy) {
|
||||
fM[0] = sx; fM[1] = 0; fM[2] = 0;
|
||||
fM[3] = 0; fM[4] = sy; fM[5] = 0;
|
||||
fM[6] = 0; fM[7] = 0; fM[8] = gRESCALE;
|
||||
fTypeMask = (GR_Scalar1 != sx || GR_Scalar1 != sy) ? kScale_TypeBit : 0;
|
||||
fTypeMask = (SK_Scalar1 != sx || SK_Scalar1 != sy) ? kScale_TypeBit : 0;
|
||||
}
|
||||
|
||||
void GrMatrix::setSkew(GrScalar skx, GrScalar sky) {
|
||||
fM[0] = GR_Scalar1; fM[1] = skx; fM[2] = 0;
|
||||
fM[3] = sky; fM[4] = GR_Scalar1; fM[5] = 0;
|
||||
void GrMatrix::setSkew(SkScalar skx, SkScalar sky) {
|
||||
fM[0] = SK_Scalar1; fM[1] = skx; fM[2] = 0;
|
||||
fM[3] = sky; fM[4] = SK_Scalar1; fM[5] = 0;
|
||||
fM[6] = 0; fM[7] = 0; fM[8] = gRESCALE;
|
||||
fTypeMask = (0 != skx || 0 != sky) ? kSkew_TypeBit : 0;
|
||||
}
|
||||
@ -204,7 +204,7 @@ bool GrMatrix::invert(GrMatrix* inverted) const {
|
||||
t[8] = ((double)fM[0]*fM[4] - (double)fM[1]*fM[3]);
|
||||
det = 1.0 / det;
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
inverted->fM[i] = (GrScalar)(t[i] * det);
|
||||
inverted->fM[i] = (SkScalar)(t[i] * det);
|
||||
}
|
||||
} else {
|
||||
t[0] = (double)fM[4]*gRESCALE;
|
||||
@ -218,11 +218,11 @@ bool GrMatrix::invert(GrMatrix* inverted) const {
|
||||
t[8] = (double)fM[0]*fM[4] - (double)fM[1]*fM[3];
|
||||
det = 1.0 / det;
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
inverted->fM[i] = (GrScalar)(t[i] * det);
|
||||
inverted->fM[i] = (SkScalar)(t[i] * det);
|
||||
}
|
||||
inverted->fM[6] = 0;
|
||||
inverted->fM[7] = 0;
|
||||
inverted->fM[8] = (GrScalar)(t[8] * det);
|
||||
inverted->fM[8] = (SkScalar)(t[8] * det);
|
||||
}
|
||||
inverted->computeTypeMask();
|
||||
return true;
|
||||
@ -246,8 +246,8 @@ bool GrMatrix::hasPerspective() const {
|
||||
|
||||
bool GrMatrix::isIdentity() const {
|
||||
GrAssert((0 == fTypeMask) ==
|
||||
(GR_Scalar1 == fM[kScaleX] && 0 == fM[kSkewX] && 0 == fM[kTransX] &&
|
||||
0 == fM[kSkewY] && GR_Scalar1 == fM[kScaleY] && 0 == fM[kTransY] &&
|
||||
(SK_Scalar1 == fM[kScaleX] && 0 == fM[kSkewX] && 0 == fM[kTransX] &&
|
||||
0 == fM[kSkewY] && SK_Scalar1 == fM[kScaleY] && 0 == fM[kTransY] &&
|
||||
0 == fM[kPersp0] && 0 == fM[kPersp1] && gRESCALE == fM[kPersp2]));
|
||||
return (0 == fTypeMask);
|
||||
}
|
||||
@ -273,41 +273,41 @@ bool GrMatrix::preservesAxisAlignment() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
GrScalar GrMatrix::getMaxStretch() const {
|
||||
SkScalar GrMatrix::getMaxStretch() const {
|
||||
|
||||
if (fTypeMask & kPerspective_TypeBit) {
|
||||
return -GR_Scalar1;
|
||||
return -SK_Scalar1;
|
||||
}
|
||||
|
||||
GrScalar stretch;
|
||||
SkScalar stretch;
|
||||
|
||||
if (isIdentity()) {
|
||||
stretch = GR_Scalar1;
|
||||
stretch = SK_Scalar1;
|
||||
} else if (!(fTypeMask & kSkew_TypeBit)) {
|
||||
stretch = GrMax(GrScalarAbs(fM[kScaleX]), GrScalarAbs(fM[kScaleY]));
|
||||
stretch = GrMax(SkScalarAbs(fM[kScaleX]), SkScalarAbs(fM[kScaleY]));
|
||||
} else if (fTypeMask & kZeroScale_TypeBit) {
|
||||
stretch = GrMax(GrScalarAbs(fM[kSkewX]), GrScalarAbs(fM[kSkewY]));
|
||||
stretch = GrMax(SkScalarAbs(fM[kSkewX]), SkScalarAbs(fM[kSkewY]));
|
||||
} else {
|
||||
// ignore the translation part of the matrix, just look at 2x2 portion.
|
||||
// compute singular values, take largest abs value.
|
||||
// [a b; b c] = A^T*A
|
||||
GrScalar a = GrMul(fM[kScaleX], fM[kScaleX]) + GrMul(fM[kSkewY], fM[kSkewY]);
|
||||
GrScalar b = GrMul(fM[kScaleX], fM[kSkewX]) + GrMul(fM[kScaleY], fM[kSkewY]);
|
||||
GrScalar c = GrMul(fM[kSkewX], fM[kSkewX]) + GrMul(fM[kScaleY], fM[kScaleY]);
|
||||
SkScalar a = SkScalarMul(fM[kScaleX], fM[kScaleX]) + SkScalarMul(fM[kSkewY], fM[kSkewY]);
|
||||
SkScalar b = SkScalarMul(fM[kScaleX], fM[kSkewX]) + SkScalarMul(fM[kScaleY], fM[kSkewY]);
|
||||
SkScalar c = SkScalarMul(fM[kSkewX], fM[kSkewX]) + SkScalarMul(fM[kScaleY], fM[kScaleY]);
|
||||
// eigenvalues of A^T*A are the squared singular values of A.
|
||||
// characteristic equation is det((A^T*A) - l*I) = 0
|
||||
// l^2 - (a + c)l + (ac-b^2)
|
||||
// solve using quadratic equation (divisor is non-zero since l^2 has 1 coeff
|
||||
// and roots are guaraunteed to be pos and real).
|
||||
GrScalar largerRoot;
|
||||
GrScalar bSqd = GrMul(b,b);
|
||||
SkScalar largerRoot;
|
||||
SkScalar bSqd = SkScalarMul(b,b);
|
||||
// TODO: fixed point tolerance value.
|
||||
if (bSqd < 1e-10) { // will be true if upper left 2x2 is orthogonal, which is common, so save some math
|
||||
largerRoot = GrMax(a, c);
|
||||
} else {
|
||||
GrScalar aminusc = a - c;
|
||||
GrScalar apluscdiv2 = (a + c) / 2;
|
||||
GrScalar x = sqrtf(GrMul(aminusc,aminusc) + GrMul(4,(bSqd))) / 2;
|
||||
SkScalar aminusc = a - c;
|
||||
SkScalar apluscdiv2 = (a + c) / 2;
|
||||
SkScalar x = sqrtf(SkScalarMul(aminusc,aminusc) + SkScalarMul(4,(bSqd))) / 2;
|
||||
largerRoot = apluscdiv2 + x;
|
||||
}
|
||||
|
||||
@ -318,13 +318,13 @@ GrScalar GrMatrix::getMaxStretch() const {
|
||||
// (modulo some error) and we should find a vector that is scaled by almost
|
||||
// stretch.
|
||||
GrPoint pt;
|
||||
GrScalar max = 0;
|
||||
SkScalar max = 0;
|
||||
for (int i = 0; i < 1000; ++i) {
|
||||
GrScalar x = (float)rand() / RAND_MAX;
|
||||
GrScalar y = sqrtf(1 - (x*x));
|
||||
SkScalar x = (float)rand() / RAND_MAX;
|
||||
SkScalar y = sqrtf(1 - (x*x));
|
||||
pt.fX = fM[kScaleX]*x + fM[kSkewX]*y;
|
||||
pt.fY = fM[kSkewY]*x + fM[kScaleY]*y;
|
||||
GrScalar d = pt.distanceToOrigin();
|
||||
SkScalar d = pt.distanceToOrigin();
|
||||
GrAssert(d <= (1.0001 * stretch));
|
||||
max = GrMax(max, pt.distanceToOrigin());
|
||||
}
|
||||
@ -366,8 +366,8 @@ void GrMatrix::mapIdentity(GrPoint* dst, const GrPoint* src, uint32_t count) con
|
||||
|
||||
void GrMatrix::mapScale(GrPoint* dst, const GrPoint* src, uint32_t count) const {
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
dst[i].fX = GrMul(src[i].fX, fM[kScaleX]);
|
||||
dst[i].fY = GrMul(src[i].fY, fM[kScaleY]);
|
||||
dst[i].fX = SkScalarMul(src[i].fX, fM[kScaleX]);
|
||||
dst[i].fY = SkScalarMul(src[i].fY, fM[kScaleY]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -381,21 +381,21 @@ void GrMatrix::mapTranslate(GrPoint* dst, const GrPoint* src, uint32_t count) co
|
||||
|
||||
void GrMatrix::mapScaleAndTranslate(GrPoint* dst, const GrPoint* src, uint32_t count) const {
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
dst[i].fX = GrMul(src[i].fX, fM[kScaleX]) + fM[kTransX];
|
||||
dst[i].fY = GrMul(src[i].fY, fM[kScaleY]) + fM[kTransY];
|
||||
dst[i].fX = SkScalarMul(src[i].fX, fM[kScaleX]) + fM[kTransX];
|
||||
dst[i].fY = SkScalarMul(src[i].fY, fM[kScaleY]) + fM[kTransY];
|
||||
}
|
||||
}
|
||||
|
||||
void GrMatrix::mapSkew(GrPoint* dst, const GrPoint* src, uint32_t count) const {
|
||||
if (src != dst) {
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
dst[i].fX = src[i].fX + GrMul(src[i].fY, fM[kSkewX]);
|
||||
dst[i].fY = src[i].fY + GrMul(src[i].fX, fM[kSkewY]);
|
||||
dst[i].fX = src[i].fX + SkScalarMul(src[i].fY, fM[kSkewX]);
|
||||
dst[i].fY = src[i].fY + SkScalarMul(src[i].fX, fM[kSkewY]);
|
||||
}
|
||||
} else {
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
GrScalar newX = src[i].fX + GrMul(src[i].fY, fM[kSkewX]);
|
||||
dst[i].fY = src[i].fY + GrMul(src[i].fX, fM[kSkewY]);
|
||||
SkScalar newX = src[i].fX + SkScalarMul(src[i].fY, fM[kSkewX]);
|
||||
dst[i].fY = src[i].fY + SkScalarMul(src[i].fX, fM[kSkewY]);
|
||||
dst[i].fX = newX;
|
||||
}
|
||||
}
|
||||
@ -404,13 +404,13 @@ void GrMatrix::mapSkew(GrPoint* dst, const GrPoint* src, uint32_t count) const {
|
||||
void GrMatrix::mapScaleAndSkew(GrPoint* dst, const GrPoint* src, uint32_t count) const {
|
||||
if (src != dst) {
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
dst[i].fX = GrMul(src[i].fX, fM[kScaleX]) + GrMul(src[i].fY, fM[kSkewX]);
|
||||
dst[i].fY = GrMul(src[i].fY, fM[kScaleY]) + GrMul(src[i].fX, fM[kSkewY]);
|
||||
dst[i].fX = SkScalarMul(src[i].fX, fM[kScaleX]) + SkScalarMul(src[i].fY, fM[kSkewX]);
|
||||
dst[i].fY = SkScalarMul(src[i].fY, fM[kScaleY]) + SkScalarMul(src[i].fX, fM[kSkewY]);
|
||||
}
|
||||
} else {
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
GrScalar newX = GrMul(src[i].fX, fM[kScaleX]) + GrMul(src[i].fY, fM[kSkewX]);
|
||||
dst[i].fY = GrMul(src[i].fY, fM[kScaleY]) + GrMul(src[i].fX, fM[kSkewY]);
|
||||
SkScalar newX = SkScalarMul(src[i].fX, fM[kScaleX]) + SkScalarMul(src[i].fY, fM[kSkewX]);
|
||||
dst[i].fY = SkScalarMul(src[i].fY, fM[kScaleY]) + SkScalarMul(src[i].fX, fM[kSkewY]);
|
||||
dst[i].fX = newX;
|
||||
}
|
||||
}
|
||||
@ -419,13 +419,13 @@ void GrMatrix::mapScaleAndSkew(GrPoint* dst, const GrPoint* src, uint32_t count)
|
||||
void GrMatrix::mapSkewAndTranslate(GrPoint* dst, const GrPoint* src, uint32_t count) const {
|
||||
if (src != dst) {
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
dst[i].fX = src[i].fX + GrMul(src[i].fY, fM[kSkewX]) + fM[kTransX];
|
||||
dst[i].fY = src[i].fY + GrMul(src[i].fX, fM[kSkewY]) + fM[kTransY];
|
||||
dst[i].fX = src[i].fX + SkScalarMul(src[i].fY, fM[kSkewX]) + fM[kTransX];
|
||||
dst[i].fY = src[i].fY + SkScalarMul(src[i].fX, fM[kSkewY]) + fM[kTransY];
|
||||
}
|
||||
} else {
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
GrScalar newX = src[i].fX + GrMul(src[i].fY, fM[kSkewX]) + fM[kTransX];
|
||||
dst[i].fY = src[i].fY + GrMul(src[i].fX, fM[kSkewY]) + fM[kTransY];
|
||||
SkScalar newX = src[i].fX + SkScalarMul(src[i].fY, fM[kSkewX]) + fM[kTransX];
|
||||
dst[i].fY = src[i].fY + SkScalarMul(src[i].fX, fM[kSkewY]) + fM[kTransY];
|
||||
dst[i].fX = newX;
|
||||
}
|
||||
}
|
||||
@ -434,13 +434,13 @@ void GrMatrix::mapSkewAndTranslate(GrPoint* dst, const GrPoint* src, uint32_t co
|
||||
void GrMatrix::mapNonPerspective(GrPoint* dst, const GrPoint* src, uint32_t count) const {
|
||||
if (src != dst) {
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
dst[i].fX = GrMul(fM[kScaleX], src[i].fX) + GrMul(fM[kSkewX], src[i].fY) + fM[kTransX];
|
||||
dst[i].fY = GrMul(fM[kSkewY], src[i].fX) + GrMul(fM[kScaleY], src[i].fY) + fM[kTransY];
|
||||
dst[i].fX = SkScalarMul(fM[kScaleX], src[i].fX) + SkScalarMul(fM[kSkewX], src[i].fY) + fM[kTransX];
|
||||
dst[i].fY = SkScalarMul(fM[kSkewY], src[i].fX) + SkScalarMul(fM[kScaleY], src[i].fY) + fM[kTransY];
|
||||
}
|
||||
} else {
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
GrScalar newX = GrMul(fM[kScaleX], src[i].fX) + GrMul(fM[kSkewX], src[i].fY) + fM[kTransX];
|
||||
dst[i].fY = GrMul(fM[kSkewY], src[i].fX) + GrMul(fM[kScaleY], src[i].fY) + fM[kTransY];
|
||||
SkScalar newX = SkScalarMul(fM[kScaleX], src[i].fX) + SkScalarMul(fM[kSkewX], src[i].fY) + fM[kTransX];
|
||||
dst[i].fY = SkScalarMul(fM[kSkewY], src[i].fX) + SkScalarMul(fM[kScaleY], src[i].fY) + fM[kTransY];
|
||||
dst[i].fX = newX;
|
||||
}
|
||||
}
|
||||
@ -448,16 +448,16 @@ void GrMatrix::mapNonPerspective(GrPoint* dst, const GrPoint* src, uint32_t coun
|
||||
|
||||
void GrMatrix::mapPerspective(GrPoint* dst, const GrPoint* src, uint32_t count) const {
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
GrScalar x, y, w;
|
||||
x = GrMul(fM[kScaleX], src[i].fX) + GrMul(fM[kSkewX], src[i].fY) + fM[kTransX];
|
||||
y = GrMul(fM[kSkewY], src[i].fX) + GrMul(fM[kScaleY], src[i].fY) + fM[kTransY];
|
||||
w = GrMul(fM[kPersp0], src[i].fX) + GrMul(fM[kPersp1], src[i].fY) + fM[kPersp2];
|
||||
SkScalar x, y, w;
|
||||
x = SkScalarMul(fM[kScaleX], src[i].fX) + SkScalarMul(fM[kSkewX], src[i].fY) + fM[kTransX];
|
||||
y = SkScalarMul(fM[kSkewY], src[i].fX) + SkScalarMul(fM[kScaleY], src[i].fY) + fM[kTransY];
|
||||
w = SkScalarMul(fM[kPersp0], src[i].fX) + SkScalarMul(fM[kPersp1], src[i].fY) + fM[kPersp2];
|
||||
// TODO need fixed point invert
|
||||
if (w) {
|
||||
w = 1 / w;
|
||||
}
|
||||
dst[i].fX = GrMul(x, w);
|
||||
dst[i].fY = GrMul(y, w);
|
||||
dst[i].fX = SkScalarMul(x, w);
|
||||
dst[i].fY = SkScalarMul(y, w);
|
||||
}
|
||||
}
|
||||
|
||||
@ -479,13 +479,13 @@ void GrMatrix::mapSetToTranslate(GrPoint* dst, const GrPoint* src, uint32_t coun
|
||||
void GrMatrix::mapSwappedScale(GrPoint* dst, const GrPoint* src, uint32_t count) const {
|
||||
if (src != dst) {
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
dst[i].fX = GrMul(src[i].fY, fM[kSkewX]);
|
||||
dst[i].fY = GrMul(src[i].fX, fM[kSkewY]);
|
||||
dst[i].fX = SkScalarMul(src[i].fY, fM[kSkewX]);
|
||||
dst[i].fY = SkScalarMul(src[i].fX, fM[kSkewY]);
|
||||
}
|
||||
} else {
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
GrScalar newX = GrMul(src[i].fY, fM[kSkewX]);
|
||||
dst[i].fY = GrMul(src[i].fX, fM[kSkewY]);
|
||||
SkScalar newX = SkScalarMul(src[i].fY, fM[kSkewX]);
|
||||
dst[i].fY = SkScalarMul(src[i].fX, fM[kSkewY]);
|
||||
dst[i].fX = newX;
|
||||
}
|
||||
}
|
||||
@ -494,13 +494,13 @@ void GrMatrix::mapSwappedScale(GrPoint* dst, const GrPoint* src, uint32_t count)
|
||||
void GrMatrix::mapSwappedScaleAndTranslate(GrPoint* dst, const GrPoint* src, uint32_t count) const {
|
||||
if (src != dst) {
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
dst[i].fX = GrMul(src[i].fY, fM[kSkewX]) + fM[kTransX];
|
||||
dst[i].fY = GrMul(src[i].fX, fM[kSkewY]) + fM[kTransY];
|
||||
dst[i].fX = SkScalarMul(src[i].fY, fM[kSkewX]) + fM[kTransX];
|
||||
dst[i].fY = SkScalarMul(src[i].fX, fM[kSkewY]) + fM[kTransY];
|
||||
}
|
||||
} else {
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
GrScalar newX = GrMul(src[i].fY, fM[kSkewX]) + fM[kTransX];
|
||||
dst[i].fY = GrMul(src[i].fX, fM[kSkewY]) + fM[kTransY];
|
||||
SkScalar newX = SkScalarMul(src[i].fY, fM[kSkewX]) + fM[kTransX];
|
||||
dst[i].fY = SkScalarMul(src[i].fX, fM[kSkewY]) + fM[kTransY];
|
||||
dst[i].fX = newX;
|
||||
}
|
||||
}
|
||||
@ -532,62 +532,62 @@ static void create_matrix(GrMatrix* matrix, GrRandom& rand) {
|
||||
switch (type) {
|
||||
case kRotate_MatrixType: {
|
||||
float angle = rand.nextF() * 2 *3.14159265358979323846f;
|
||||
GrScalar cosa = GrFloatToScalar(cosf(angle));
|
||||
GrScalar sina = GrFloatToScalar(sinf(angle));
|
||||
SkScalar cosa = SkFloatToScalar(cosf(angle));
|
||||
SkScalar sina = SkFloatToScalar(sinf(angle));
|
||||
matrix->setAll(cosa, -sina, 0,
|
||||
sina, cosa, 0,
|
||||
0, 0, GrMatrix::I()[8]);
|
||||
} break;
|
||||
case kScaleX_MatrixType: {
|
||||
GrScalar scale = GrFloatToScalar(rand.nextF(-2, 2));
|
||||
SkScalar scale = SkFloatToScalar(rand.nextF(-2, 2));
|
||||
matrix->setAll(scale, 0, 0,
|
||||
0, GR_Scalar1, 0,
|
||||
0, SK_Scalar1, 0,
|
||||
0, 0, GrMatrix::I()[8]);
|
||||
} break;
|
||||
case kScaleY_MatrixType: {
|
||||
GrScalar scale = GrFloatToScalar(rand.nextF(-2, 2));
|
||||
matrix->setAll(GR_Scalar1, 0, 0,
|
||||
SkScalar scale = SkFloatToScalar(rand.nextF(-2, 2));
|
||||
matrix->setAll(SK_Scalar1, 0, 0,
|
||||
0, scale, 0,
|
||||
0, 0, GrMatrix::I()[8]);
|
||||
} break;
|
||||
case kSkewX_MatrixType: {
|
||||
GrScalar skew = GrFloatToScalar(rand.nextF(-2, 2));
|
||||
matrix->setAll(GR_Scalar1, skew, 0,
|
||||
0, GR_Scalar1, 0,
|
||||
SkScalar skew = SkFloatToScalar(rand.nextF(-2, 2));
|
||||
matrix->setAll(SK_Scalar1, skew, 0,
|
||||
0, SK_Scalar1, 0,
|
||||
0, 0, GrMatrix::I()[8]);
|
||||
} break;
|
||||
case kSkewY_MatrixType: {
|
||||
GrScalar skew = GrFloatToScalar(rand.nextF(-2, 2));
|
||||
matrix->setAll(GR_Scalar1, 0, 0,
|
||||
skew, GR_Scalar1, 0,
|
||||
SkScalar skew = SkFloatToScalar(rand.nextF(-2, 2));
|
||||
matrix->setAll(SK_Scalar1, 0, 0,
|
||||
skew, SK_Scalar1, 0,
|
||||
0, 0, GrMatrix::I()[8]);
|
||||
} break;
|
||||
case kTranslateX_MatrixType: {
|
||||
GrScalar trans = GrFloatToScalar(rand.nextF(-10, 10));
|
||||
matrix->setAll(GR_Scalar1, 0, trans,
|
||||
0, GR_Scalar1, 0,
|
||||
SkScalar trans = SkFloatToScalar(rand.nextF(-10, 10));
|
||||
matrix->setAll(SK_Scalar1, 0, trans,
|
||||
0, SK_Scalar1, 0,
|
||||
0, 0, GrMatrix::I()[8]);
|
||||
} break;
|
||||
case kTranslateY_MatrixType: {
|
||||
GrScalar trans = GrFloatToScalar(rand.nextF(-10, 10));
|
||||
matrix->setAll(GR_Scalar1, 0, 0,
|
||||
0, GR_Scalar1, trans,
|
||||
SkScalar trans = SkFloatToScalar(rand.nextF(-10, 10));
|
||||
matrix->setAll(SK_Scalar1, 0, 0,
|
||||
0, SK_Scalar1, trans,
|
||||
0, 0, GrMatrix::I()[8]);
|
||||
} break;
|
||||
case kSwapScaleXY_MatrixType: {
|
||||
GrScalar xy = GrFloatToScalar(rand.nextF(-2, 2));
|
||||
GrScalar yx = GrFloatToScalar(rand.nextF(-2, 2));
|
||||
SkScalar xy = SkFloatToScalar(rand.nextF(-2, 2));
|
||||
SkScalar yx = SkFloatToScalar(rand.nextF(-2, 2));
|
||||
matrix->setAll(0, xy, 0,
|
||||
yx, 0, 0,
|
||||
0, 0, GrMatrix::I()[8]);
|
||||
} break;
|
||||
case kPersp_MatrixType: {
|
||||
GrScalar p0 = GrFloatToScalar(rand.nextF(-2, 2));
|
||||
GrScalar p1 = GrFloatToScalar(rand.nextF(-2, 2));
|
||||
GrScalar p2 = GrFloatToScalar(rand.nextF(-0.5f, 0.75f));
|
||||
matrix->setAll(GR_Scalar1, 0, 0,
|
||||
0, GR_Scalar1, 0,
|
||||
p0, p1, GrMul(p2,GrMatrix::I()[8]));
|
||||
SkScalar p0 = SkFloatToScalar(rand.nextF(-2, 2));
|
||||
SkScalar p1 = SkFloatToScalar(rand.nextF(-2, 2));
|
||||
SkScalar p2 = SkFloatToScalar(rand.nextF(-0.5f, 0.75f));
|
||||
matrix->setAll(SK_Scalar1, 0, 0,
|
||||
0, SK_Scalar1, 0,
|
||||
p0, p1, SkScalarMul(p2,GrMatrix::I()[8]));
|
||||
} break;
|
||||
default:
|
||||
GrAssert(0);
|
||||
@ -612,8 +612,8 @@ void GrMatrix::UnitTest() {
|
||||
GrAssert(a.isIdentity());
|
||||
} else if (1 == i) {
|
||||
num = 0;
|
||||
a.setAll(0, GR_Scalar1, 0,
|
||||
GR_Scalar1, 0, 0,
|
||||
a.setAll(0, SK_Scalar1, 0,
|
||||
SK_Scalar1, 0, 0,
|
||||
0, 0, I()[8]);
|
||||
}
|
||||
for (int j = 0; j < num; ++j) {
|
||||
@ -621,17 +621,17 @@ void GrMatrix::UnitTest() {
|
||||
a.preConcat(b);
|
||||
}
|
||||
|
||||
GrScalar maxStretch = a.getMaxStretch();
|
||||
SkScalar maxStretch = a.getMaxStretch();
|
||||
if (maxStretch > 0) {
|
||||
maxStretch = GrMul(GR_Scalar1 + GR_Scalar1 / 100, maxStretch);
|
||||
maxStretch = SkScalarMul(SK_Scalar1 + SK_Scalar1 / 100, maxStretch);
|
||||
}
|
||||
GrPoint origin = a.mapPoint(GrPoint::Make(0,0));
|
||||
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
int mask, origMask = a.fTypeMask;
|
||||
GrScalar old = a[j];
|
||||
SkScalar old = a[j];
|
||||
|
||||
a.set(j, GR_Scalar1);
|
||||
a.set(j, SK_Scalar1);
|
||||
mask = a.fTypeMask;
|
||||
a.computeTypeMask();
|
||||
GrAssert(mask == a.fTypeMask);
|
||||
@ -641,7 +641,7 @@ void GrMatrix::UnitTest() {
|
||||
a.computeTypeMask();
|
||||
GrAssert(mask == a.fTypeMask);
|
||||
|
||||
a.set(j, 10 * GR_Scalar1);
|
||||
a.set(j, 10 * SK_Scalar1);
|
||||
mask = a.fTypeMask;
|
||||
a.computeTypeMask();
|
||||
GrAssert(mask == a.fTypeMask);
|
||||
@ -652,8 +652,8 @@ void GrMatrix::UnitTest() {
|
||||
|
||||
for (int j = 0; j < 100; ++j) {
|
||||
GrPoint pt;
|
||||
pt.fX = GrFloatToScalar(rand.nextF(-10, 10));
|
||||
pt.fY = GrFloatToScalar(rand.nextF(-10, 10));
|
||||
pt.fX = SkFloatToScalar(rand.nextF(-10, 10));
|
||||
pt.fY = SkFloatToScalar(rand.nextF(-10, 10));
|
||||
|
||||
GrPoint t0, t1, t2;
|
||||
t0 = a.mapPoint(pt); // map to a new point
|
||||
@ -664,7 +664,7 @@ void GrMatrix::UnitTest() {
|
||||
if (maxStretch >= 0.f) {
|
||||
GrVec vec = origin - t0;
|
||||
// vec.setBetween(t0, origin);
|
||||
GrScalar stretch = vec.length() / pt.distanceToOrigin();
|
||||
SkScalar stretch = vec.length() / pt.distanceToOrigin();
|
||||
GrAssert(stretch <= maxStretch);
|
||||
}
|
||||
}
|
||||
@ -673,8 +673,8 @@ void GrMatrix::UnitTest() {
|
||||
GrMatrix c;
|
||||
c.setConcat(a,b);
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
GrScalar diff = GrScalarAbs(c[i] - I()[i]);
|
||||
GrAssert(diff < (5*GR_Scalar1 / 100));
|
||||
SkScalar diff = SkScalarAbs(c[i] - I()[i]);
|
||||
GrAssert(diff < (5*SK_Scalar1 / 100));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,13 +11,13 @@
|
||||
#include "GrPoint.h"
|
||||
#include "SkGeometry.h"
|
||||
|
||||
GrScalar GrPathUtils::scaleToleranceToSrc(GrScalar devTol,
|
||||
SkScalar GrPathUtils::scaleToleranceToSrc(SkScalar devTol,
|
||||
const GrMatrix& viewM,
|
||||
const GrRect& pathBounds) {
|
||||
// In order to tesselate the path we get a bound on how much the matrix can
|
||||
// stretch when mapping to screen coordinates.
|
||||
GrScalar stretch = viewM.getMaxStretch();
|
||||
GrScalar srcTol = devTol;
|
||||
SkScalar stretch = viewM.getMaxStretch();
|
||||
SkScalar srcTol = devTol;
|
||||
|
||||
if (stretch < 0) {
|
||||
// take worst case mapRadius amoung four corners.
|
||||
@ -30,21 +30,21 @@ GrScalar GrPathUtils::scaleToleranceToSrc(GrScalar devTol,
|
||||
stretch = SkMaxScalar(stretch, mat.mapRadius(SK_Scalar1));
|
||||
}
|
||||
}
|
||||
srcTol = GrScalarDiv(srcTol, stretch);
|
||||
srcTol = SkScalarDiv(srcTol, stretch);
|
||||
return srcTol;
|
||||
}
|
||||
|
||||
static const int MAX_POINTS_PER_CURVE = 1 << 10;
|
||||
static const GrScalar gMinCurveTol = GrFloatToScalar(0.0001f);
|
||||
static const SkScalar gMinCurveTol = SkFloatToScalar(0.0001f);
|
||||
|
||||
uint32_t GrPathUtils::quadraticPointCount(const GrPoint points[],
|
||||
GrScalar tol) {
|
||||
SkScalar tol) {
|
||||
if (tol < gMinCurveTol) {
|
||||
tol = gMinCurveTol;
|
||||
}
|
||||
GrAssert(tol > 0);
|
||||
|
||||
GrScalar d = points[1].distanceToLineSegmentBetween(points[0], points[2]);
|
||||
SkScalar d = points[1].distanceToLineSegmentBetween(points[0], points[2]);
|
||||
if (d <= tol) {
|
||||
return 1;
|
||||
} else {
|
||||
@ -67,7 +67,7 @@ uint32_t GrPathUtils::quadraticPointCount(const GrPoint points[],
|
||||
uint32_t GrPathUtils::generateQuadraticPoints(const GrPoint& p0,
|
||||
const GrPoint& p1,
|
||||
const GrPoint& p2,
|
||||
GrScalar tolSqd,
|
||||
SkScalar tolSqd,
|
||||
GrPoint** points,
|
||||
uint32_t pointsLeft) {
|
||||
if (pointsLeft < 2 ||
|
||||
@ -78,10 +78,10 @@ uint32_t GrPathUtils::generateQuadraticPoints(const GrPoint& p0,
|
||||
}
|
||||
|
||||
GrPoint q[] = {
|
||||
{ GrScalarAve(p0.fX, p1.fX), GrScalarAve(p0.fY, p1.fY) },
|
||||
{ GrScalarAve(p1.fX, p2.fX), GrScalarAve(p1.fY, p2.fY) },
|
||||
{ SkScalarAve(p0.fX, p1.fX), SkScalarAve(p0.fY, p1.fY) },
|
||||
{ SkScalarAve(p1.fX, p2.fX), SkScalarAve(p1.fY, p2.fY) },
|
||||
};
|
||||
GrPoint r = { GrScalarAve(q[0].fX, q[1].fX), GrScalarAve(q[0].fY, q[1].fY) };
|
||||
GrPoint r = { SkScalarAve(q[0].fX, q[1].fX), SkScalarAve(q[0].fY, q[1].fY) };
|
||||
|
||||
pointsLeft >>= 1;
|
||||
uint32_t a = generateQuadraticPoints(p0, q[0], r, tolSqd, points, pointsLeft);
|
||||
@ -90,13 +90,13 @@ uint32_t GrPathUtils::generateQuadraticPoints(const GrPoint& p0,
|
||||
}
|
||||
|
||||
uint32_t GrPathUtils::cubicPointCount(const GrPoint points[],
|
||||
GrScalar tol) {
|
||||
SkScalar tol) {
|
||||
if (tol < gMinCurveTol) {
|
||||
tol = gMinCurveTol;
|
||||
}
|
||||
GrAssert(tol > 0);
|
||||
|
||||
GrScalar d = GrMax(
|
||||
SkScalar d = GrMax(
|
||||
points[1].distanceToLineSegmentBetweenSqd(points[0], points[3]),
|
||||
points[2].distanceToLineSegmentBetweenSqd(points[0], points[3]));
|
||||
d = SkScalarSqrt(d);
|
||||
@ -119,7 +119,7 @@ uint32_t GrPathUtils::generateCubicPoints(const GrPoint& p0,
|
||||
const GrPoint& p1,
|
||||
const GrPoint& p2,
|
||||
const GrPoint& p3,
|
||||
GrScalar tolSqd,
|
||||
SkScalar tolSqd,
|
||||
GrPoint** points,
|
||||
uint32_t pointsLeft) {
|
||||
if (pointsLeft < 2 ||
|
||||
@ -130,15 +130,15 @@ uint32_t GrPathUtils::generateCubicPoints(const GrPoint& p0,
|
||||
return 1;
|
||||
}
|
||||
GrPoint q[] = {
|
||||
{ GrScalarAve(p0.fX, p1.fX), GrScalarAve(p0.fY, p1.fY) },
|
||||
{ GrScalarAve(p1.fX, p2.fX), GrScalarAve(p1.fY, p2.fY) },
|
||||
{ GrScalarAve(p2.fX, p3.fX), GrScalarAve(p2.fY, p3.fY) }
|
||||
{ SkScalarAve(p0.fX, p1.fX), SkScalarAve(p0.fY, p1.fY) },
|
||||
{ SkScalarAve(p1.fX, p2.fX), SkScalarAve(p1.fY, p2.fY) },
|
||||
{ SkScalarAve(p2.fX, p3.fX), SkScalarAve(p2.fY, p3.fY) }
|
||||
};
|
||||
GrPoint r[] = {
|
||||
{ GrScalarAve(q[0].fX, q[1].fX), GrScalarAve(q[0].fY, q[1].fY) },
|
||||
{ GrScalarAve(q[1].fX, q[2].fX), GrScalarAve(q[1].fY, q[2].fY) }
|
||||
{ SkScalarAve(q[0].fX, q[1].fX), SkScalarAve(q[0].fY, q[1].fY) },
|
||||
{ SkScalarAve(q[1].fX, q[2].fX), SkScalarAve(q[1].fY, q[2].fY) }
|
||||
};
|
||||
GrPoint s = { GrScalarAve(r[0].fX, r[1].fX), GrScalarAve(r[0].fY, r[1].fY) };
|
||||
GrPoint s = { SkScalarAve(r[0].fX, r[1].fX), SkScalarAve(r[0].fY, r[1].fY) };
|
||||
pointsLeft >>= 1;
|
||||
uint32_t a = generateCubicPoints(p0, q[0], r[0], s, tolSqd, points, pointsLeft);
|
||||
uint32_t b = generateCubicPoints(s, r[1], q[2], p3, tolSqd, points, pointsLeft);
|
||||
@ -146,7 +146,7 @@ uint32_t GrPathUtils::generateCubicPoints(const GrPoint& p0,
|
||||
}
|
||||
|
||||
int GrPathUtils::worstCasePointCount(const SkPath& path, int* subpaths,
|
||||
GrScalar tol) {
|
||||
SkScalar tol) {
|
||||
if (tol < gMinCurveTol) {
|
||||
tol = gMinCurveTol;
|
||||
}
|
||||
@ -199,16 +199,16 @@ void GrPathUtils::QuadUVMatrix::set(const GrPoint qPts[3]) {
|
||||
// [0 0 1]
|
||||
// [1 1 1]
|
||||
// We invert the control pt matrix and post concat to both sides to get M.
|
||||
UVpts.setAll(0, GR_ScalarHalf, GR_Scalar1,
|
||||
0, 0, GR_Scalar1,
|
||||
SkScalarToPersp(GR_Scalar1),
|
||||
SkScalarToPersp(GR_Scalar1),
|
||||
SkScalarToPersp(GR_Scalar1));
|
||||
UVpts.setAll(0, SK_ScalarHalf, SK_Scalar1,
|
||||
0, 0, SK_Scalar1,
|
||||
SkScalarToPersp(SK_Scalar1),
|
||||
SkScalarToPersp(SK_Scalar1),
|
||||
SkScalarToPersp(SK_Scalar1));
|
||||
m.setAll(qPts[0].fX, qPts[1].fX, qPts[2].fX,
|
||||
qPts[0].fY, qPts[1].fY, qPts[2].fY,
|
||||
SkScalarToPersp(GR_Scalar1),
|
||||
SkScalarToPersp(GR_Scalar1),
|
||||
SkScalarToPersp(GR_Scalar1));
|
||||
SkScalarToPersp(SK_Scalar1),
|
||||
SkScalarToPersp(SK_Scalar1),
|
||||
SkScalarToPersp(SK_Scalar1));
|
||||
if (!m.invert(&m)) {
|
||||
// The quad is degenerate. Hopefully this is rare. Find the pts that are
|
||||
// farthest apart to compute a line (unless it is really a pt).
|
||||
@ -251,9 +251,9 @@ void GrPathUtils::QuadUVMatrix::set(const GrPoint qPts[3]) {
|
||||
m.postConcat(UVpts);
|
||||
|
||||
// The matrix should not have perspective.
|
||||
static const GrScalar gTOL = GrFloatToScalar(1.f / 100.f);
|
||||
GrAssert(GrScalarAbs(m.get(SkMatrix::kMPersp0)) < gTOL);
|
||||
GrAssert(GrScalarAbs(m.get(SkMatrix::kMPersp1)) < gTOL);
|
||||
static const SkScalar gTOL = SkFloatToScalar(1.f / 100.f);
|
||||
GrAssert(SkScalarAbs(m.get(SkMatrix::kMPersp0)) < gTOL);
|
||||
GrAssert(SkScalarAbs(m.get(SkMatrix::kMPersp1)) < gTOL);
|
||||
|
||||
// It may not be normalized to have 1.0 in the bottom right
|
||||
float m33 = m.get(SkMatrix::kMPersp2);
|
||||
|
@ -18,7 +18,7 @@
|
||||
* Utilities for evaluating paths.
|
||||
*/
|
||||
namespace GrPathUtils {
|
||||
GrScalar scaleToleranceToSrc(GrScalar devTol,
|
||||
SkScalar scaleToleranceToSrc(SkScalar devTol,
|
||||
const GrMatrix& viewM,
|
||||
const GrRect& pathBounds);
|
||||
|
||||
@ -26,28 +26,28 @@ namespace GrPathUtils {
|
||||
/// very small tolerances will be increased to gMinCurveTol.
|
||||
int worstCasePointCount(const SkPath&,
|
||||
int* subpaths,
|
||||
GrScalar tol);
|
||||
SkScalar tol);
|
||||
|
||||
/// Since we divide by tol if we're computing exact worst-case bounds,
|
||||
/// very small tolerances will be increased to gMinCurveTol.
|
||||
uint32_t quadraticPointCount(const GrPoint points[], GrScalar tol);
|
||||
uint32_t quadraticPointCount(const GrPoint points[], SkScalar tol);
|
||||
|
||||
uint32_t generateQuadraticPoints(const GrPoint& p0,
|
||||
const GrPoint& p1,
|
||||
const GrPoint& p2,
|
||||
GrScalar tolSqd,
|
||||
SkScalar tolSqd,
|
||||
GrPoint** points,
|
||||
uint32_t pointsLeft);
|
||||
|
||||
/// Since we divide by tol if we're computing exact worst-case bounds,
|
||||
/// very small tolerances will be increased to gMinCurveTol.
|
||||
uint32_t cubicPointCount(const GrPoint points[], GrScalar tol);
|
||||
uint32_t cubicPointCount(const GrPoint points[], SkScalar tol);
|
||||
|
||||
uint32_t generateCubicPoints(const GrPoint& p0,
|
||||
const GrPoint& p1,
|
||||
const GrPoint& p2,
|
||||
const GrPoint& p3,
|
||||
GrScalar tolSqd,
|
||||
SkScalar tolSqd,
|
||||
GrPoint** points,
|
||||
uint32_t pointsLeft);
|
||||
|
||||
|
@ -214,8 +214,8 @@ void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture,
|
||||
GrAssert(!drawState->isStageEnabled(kPathMaskStage));
|
||||
drawState->stage(kPathMaskStage)->reset();
|
||||
drawState->createTextureEffect(kPathMaskStage, texture);
|
||||
GrScalar w = GrIntToScalar(rect.width());
|
||||
GrScalar h = GrIntToScalar(rect.height());
|
||||
SkScalar w = SkIntToScalar(rect.width());
|
||||
SkScalar h = SkIntToScalar(rect.height());
|
||||
GrRect maskRect = GrRect::MakeWH(w / texture->width(),
|
||||
h / texture->height());
|
||||
|
||||
|
@ -75,7 +75,7 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const SkPath& path,
|
||||
|
||||
// fill the path, zero out the stencil
|
||||
GrRect bounds = p->getBounds();
|
||||
GrScalar bloat = drawState->getViewMatrix().getMaxStretch() * GR_ScalarHalf;
|
||||
SkScalar bloat = drawState->getViewMatrix().getMaxStretch() * SK_ScalarHalf;
|
||||
GrDrawState::AutoDeviceCoordDraw adcd;
|
||||
|
||||
if (nonInvertedFill == fill) {
|
||||
@ -100,8 +100,8 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const SkPath& path,
|
||||
0xffff);
|
||||
GrMatrix vmi;
|
||||
bounds.setLTRB(0, 0,
|
||||
GrIntToScalar(drawState->getRenderTarget()->width()),
|
||||
GrIntToScalar(drawState->getRenderTarget()->height()));
|
||||
SkIntToScalar(drawState->getRenderTarget()->width()),
|
||||
SkIntToScalar(drawState->getRenderTarget()->height()));
|
||||
// mapRect through persp matrix may not be correct
|
||||
if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewInverse(&vmi)) {
|
||||
vmi.mapRect(&bounds);
|
||||
|
@ -131,8 +131,8 @@ void GrTextContext::drawPackedGlyph(GrGlyph::PackedID packed,
|
||||
return;
|
||||
}
|
||||
|
||||
vx += GrIntToFixed(glyph->fBounds.fLeft);
|
||||
vy += GrIntToFixed(glyph->fBounds.fTop);
|
||||
vx += SkIntToFixed(glyph->fBounds.fLeft);
|
||||
vy += SkIntToFixed(glyph->fBounds.fTop);
|
||||
|
||||
// keep them as ints until we've done the clip-test
|
||||
GrFixed width = glyph->fBounds.width();
|
||||
@ -175,8 +175,8 @@ void GrTextContext::drawPackedGlyph(GrGlyph::PackedID packed,
|
||||
|
||||
GrContext::AutoMatrix am;
|
||||
GrMatrix translate;
|
||||
translate.setTranslate(GrFixedToScalar(vx - GrIntToFixed(glyph->fBounds.fLeft)),
|
||||
GrFixedToScalar(vy - GrIntToFixed(glyph->fBounds.fTop)));
|
||||
translate.setTranslate(SkFixedToScalar(vx - SkIntToFixed(glyph->fBounds.fLeft)),
|
||||
SkFixedToScalar(vy - SkIntToFixed(glyph->fBounds.fTop)));
|
||||
GrPaint tmpPaint(fPaint);
|
||||
am.setPreConcat(fContext, translate, &tmpPaint);
|
||||
fContext->drawPath(tmpPaint, *glyph->fPath, kWinding_GrPathFill);
|
||||
@ -187,8 +187,8 @@ HAS_ATLAS:
|
||||
GrAssert(glyph->fAtlas);
|
||||
|
||||
// now promote them to fixed
|
||||
width = GrIntToFixed(width);
|
||||
height = GrIntToFixed(height);
|
||||
width = SkIntToFixed(width);
|
||||
height = SkIntToFixed(height);
|
||||
|
||||
GrTexture* texture = glyph->fAtlas->texture();
|
||||
GrAssert(texture);
|
||||
@ -234,8 +234,8 @@ HAS_ATLAS:
|
||||
GrAlwaysAssert(success);
|
||||
}
|
||||
|
||||
GrFixed tx = GrIntToFixed(glyph->fAtlasLocation.fX);
|
||||
GrFixed ty = GrIntToFixed(glyph->fAtlasLocation.fY);
|
||||
GrFixed tx = SkIntToFixed(glyph->fAtlasLocation.fX);
|
||||
GrFixed ty = SkIntToFixed(glyph->fAtlasLocation.fY);
|
||||
|
||||
#if GR_TEXT_SCALAR_IS_USHORT
|
||||
int x = vx >> 16;
|
||||
|
@ -604,8 +604,8 @@ inline bool skPaint2GrPaintShader(SkGpuDevice* dev,
|
||||
}
|
||||
|
||||
if (SkShader::kDefault_BitmapType == bmptype) {
|
||||
GrScalar sx = SkFloatToScalar(1.f / bitmap.width());
|
||||
GrScalar sy = SkFloatToScalar(1.f / bitmap.height());
|
||||
SkScalar sx = SkFloatToScalar(1.f / bitmap.width());
|
||||
SkScalar sy = SkFloatToScalar(1.f / bitmap.height());
|
||||
matrix.postScale(sx, sy);
|
||||
}
|
||||
stage->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (texture, matrix, params)))->unref();
|
||||
@ -964,10 +964,10 @@ bool drawWithMaskFilter(GrContext* context, const SkPath& devPath,
|
||||
|
||||
grp->coverageStage(MASK_IDX)->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (texture, m)))->unref();
|
||||
GrRect d;
|
||||
d.setLTRB(GrIntToScalar(dstM.fBounds.fLeft),
|
||||
GrIntToScalar(dstM.fBounds.fTop),
|
||||
GrIntToScalar(dstM.fBounds.fRight),
|
||||
GrIntToScalar(dstM.fBounds.fBottom));
|
||||
d.setLTRB(SkIntToScalar(dstM.fBounds.fLeft),
|
||||
SkIntToScalar(dstM.fBounds.fTop),
|
||||
SkIntToScalar(dstM.fBounds.fRight),
|
||||
SkIntToScalar(dstM.fBounds.fBottom));
|
||||
|
||||
context->drawRect(*grp, d);
|
||||
return true;
|
||||
@ -1419,20 +1419,20 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
|
||||
SkAutoTUnref<GrEffect> effect;
|
||||
if (needsTextureDomain) {
|
||||
// Use a constrained texture domain to avoid color bleeding
|
||||
GrScalar left, top, right, bottom;
|
||||
if (srcRect.width() > GR_Scalar1) {
|
||||
GrScalar border = GR_ScalarHalf / bitmap.width();
|
||||
SkScalar left, top, right, bottom;
|
||||
if (srcRect.width() > SK_Scalar1) {
|
||||
SkScalar border = SK_ScalarHalf / bitmap.width();
|
||||
left = paintRect.left() + border;
|
||||
right = paintRect.right() - border;
|
||||
} else {
|
||||
left = right = GrScalarHalf(paintRect.left() + paintRect.right());
|
||||
left = right = SkScalarHalf(paintRect.left() + paintRect.right());
|
||||
}
|
||||
if (srcRect.height() > GR_Scalar1) {
|
||||
GrScalar border = GR_ScalarHalf / bitmap.height();
|
||||
if (srcRect.height() > SK_Scalar1) {
|
||||
SkScalar border = SK_ScalarHalf / bitmap.height();
|
||||
top = paintRect.top() + border;
|
||||
bottom = paintRect.bottom() - border;
|
||||
} else {
|
||||
top = bottom = GrScalarHalf(paintRect.top() + paintRect.bottom());
|
||||
top = bottom = SkScalarHalf(paintRect.top() + paintRect.bottom());
|
||||
}
|
||||
textureDomain.setLTRB(left, top, right, bottom);
|
||||
effect.reset(SkNEW_ARGS(GrTextureDomainEffect, (texture, textureDomain, params)));
|
||||
@ -1533,12 +1533,12 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
|
||||
}
|
||||
|
||||
fContext->drawRectToRect(grPaint,
|
||||
GrRect::MakeXYWH(GrIntToScalar(left),
|
||||
GrIntToScalar(top),
|
||||
GrIntToScalar(w),
|
||||
GrIntToScalar(h)),
|
||||
GrRect::MakeWH(GR_Scalar1 * w / texture->width(),
|
||||
GR_Scalar1 * h / texture->height()));
|
||||
GrRect::MakeXYWH(SkIntToScalar(left),
|
||||
SkIntToScalar(top),
|
||||
SkIntToScalar(w),
|
||||
SkIntToScalar(h)),
|
||||
GrRect::MakeWH(SK_Scalar1 * w / texture->width(),
|
||||
SK_Scalar1 * h / texture->height()));
|
||||
}
|
||||
|
||||
void SkGpuDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
|
||||
@ -1611,15 +1611,15 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkDevice* device,
|
||||
int w = bm.width();
|
||||
int h = bm.height();
|
||||
|
||||
GrRect dstRect = GrRect::MakeXYWH(GrIntToScalar(x),
|
||||
GrIntToScalar(y),
|
||||
GrIntToScalar(w),
|
||||
GrIntToScalar(h));
|
||||
GrRect dstRect = GrRect::MakeXYWH(SkIntToScalar(x),
|
||||
SkIntToScalar(y),
|
||||
SkIntToScalar(w),
|
||||
SkIntToScalar(h));
|
||||
|
||||
// The device being drawn may not fill up its texture (saveLayer uses
|
||||
// the approximate ).
|
||||
GrRect srcRect = GrRect::MakeWH(GR_Scalar1 * w / devTex->width(),
|
||||
GR_Scalar1 * h / devTex->height());
|
||||
GrRect srcRect = GrRect::MakeWH(SK_Scalar1 * w / devTex->width(),
|
||||
SK_Scalar1 * h / devTex->height());
|
||||
|
||||
fContext->drawRectToRect(grPaint, dstRect, srcRect);
|
||||
}
|
||||
|
@ -172,8 +172,8 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
|
||||
*pmToUPMRule = kConversionRules[i][0];
|
||||
*upmToPMRule = kConversionRules[i][1];
|
||||
|
||||
static const GrRect kDstRect = GrRect::MakeWH(GrIntToScalar(256), GrIntToScalar(256));
|
||||
static const GrRect kSrcRect = GrRect::MakeWH(GR_Scalar1, GR_Scalar1);
|
||||
static const GrRect kDstRect = GrRect::MakeWH(SkIntToScalar(256), SkIntToScalar(256));
|
||||
static const GrRect kSrcRect = GrRect::MakeWH(SK_Scalar1, SK_Scalar1);
|
||||
// We do a PM->UPM draw from dataTex to readTex and read the data. Then we do a UPM->PM draw
|
||||
// from readTex to tempTex followed by a PM->UPM draw to readTex and finally read the data.
|
||||
// We then verify that two reads produced the same values.
|
||||
|
@ -67,10 +67,10 @@ void GrGLTextureDomainEffect::setData(const GrGLUniformManager& uman, const GrEf
|
||||
const GrRect& domain = effect.domain();
|
||||
|
||||
float values[4] = {
|
||||
GrScalarToFloat(domain.left()),
|
||||
GrScalarToFloat(domain.top()),
|
||||
GrScalarToFloat(domain.right()),
|
||||
GrScalarToFloat(domain.bottom())
|
||||
SkScalarToFloat(domain.left()),
|
||||
SkScalarToFloat(domain.top()),
|
||||
SkScalarToFloat(domain.right()),
|
||||
SkScalarToFloat(domain.bottom())
|
||||
};
|
||||
// vertical flip if necessary
|
||||
if (GrSurface::kBottomLeft_Origin == effect.texture(0)->origin()) {
|
||||
|
@ -66,8 +66,8 @@ public:
|
||||
* atlas and scaleFactor, returned by getVerticalScaleFactor(), is the y-scale of the row,
|
||||
* relative to the height of the overall atlas texture.
|
||||
*/
|
||||
GrScalar getYOffset(int row) const { return SkIntToScalar(row) / fNumRows; }
|
||||
GrScalar getVerticalScaleFactor() const { return SkIntToScalar(fDesc.fRowHeight) / fDesc.fHeight; }
|
||||
SkScalar getYOffset(int row) const { return SkIntToScalar(row) / fNumRows; }
|
||||
SkScalar getVerticalScaleFactor() const { return SkIntToScalar(fDesc.fRowHeight) / fDesc.fHeight; }
|
||||
|
||||
GrContext* getContext() const { return fDesc.fContext; }
|
||||
GrTexture* getTexture() const { return fTexture; }
|
||||
|
@ -979,7 +979,7 @@ GrGLEffect* GrGLProgram::GenStageCode(const GrEffectStage& stage,
|
||||
void GrGLProgram::setData(const GrDrawState& drawState) {
|
||||
int rtHeight = drawState.getRenderTarget()->height();
|
||||
if (GrGLUniformManager::kInvalidUniformHandle != fUniforms.fRTHeight && fRTHeight != rtHeight) {
|
||||
fUniformManager.set1f(fUniforms.fRTHeight, GrIntToScalar(rtHeight));
|
||||
fUniformManager.set1f(fUniforms.fRTHeight, SkIntToScalar(rtHeight));
|
||||
fRTHeight = rtHeight;
|
||||
}
|
||||
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#include "GrGLIRect.h"
|
||||
#include "GrRenderTarget.h"
|
||||
#include "GrScalar.h"
|
||||
#include "SkScalar.h"
|
||||
|
||||
class GrGpuGL;
|
||||
class GrGLTexture;
|
||||
|
@ -97,32 +97,32 @@ void GrGpuGL::flushViewMatrix(DrawType type) {
|
||||
// rescale the coords from skia's "device" coords to GL's normalized coords,
|
||||
// and perform a y-flip.
|
||||
GrMatrix m;
|
||||
m.setScale(GrIntToScalar(2) / rt->width(), GrIntToScalar(-2) / rt->height());
|
||||
m.postTranslate(-GR_Scalar1, GR_Scalar1);
|
||||
m.setScale(SkIntToScalar(2) / rt->width(), SkIntToScalar(-2) / rt->height());
|
||||
m.postTranslate(-SK_Scalar1, SK_Scalar1);
|
||||
m.preConcat(vm);
|
||||
|
||||
// GL wants a column-major 4x4.
|
||||
GrGLfloat mv[] = {
|
||||
// col 0
|
||||
GrScalarToFloat(m[GrMatrix::kMScaleX]),
|
||||
GrScalarToFloat(m[GrMatrix::kMSkewY]),
|
||||
SkScalarToFloat(m[GrMatrix::kMScaleX]),
|
||||
SkScalarToFloat(m[GrMatrix::kMSkewY]),
|
||||
0,
|
||||
GrScalarToFloat(m[GrMatrix::kMPersp0]),
|
||||
SkScalarToFloat(m[GrMatrix::kMPersp0]),
|
||||
|
||||
// col 1
|
||||
GrScalarToFloat(m[GrMatrix::kMSkewX]),
|
||||
GrScalarToFloat(m[GrMatrix::kMScaleY]),
|
||||
SkScalarToFloat(m[GrMatrix::kMSkewX]),
|
||||
SkScalarToFloat(m[GrMatrix::kMScaleY]),
|
||||
0,
|
||||
GrScalarToFloat(m[GrMatrix::kMPersp1]),
|
||||
SkScalarToFloat(m[GrMatrix::kMPersp1]),
|
||||
|
||||
// col 2
|
||||
0, 0, 0, 0,
|
||||
|
||||
// col3
|
||||
GrScalarToFloat(m[GrMatrix::kMTransX]),
|
||||
GrScalarToFloat(m[GrMatrix::kMTransY]),
|
||||
SkScalarToFloat(m[GrMatrix::kMTransX]),
|
||||
SkScalarToFloat(m[GrMatrix::kMTransY]),
|
||||
0.0f,
|
||||
GrScalarToFloat(m[GrMatrix::kMPersp2])
|
||||
SkScalarToFloat(m[GrMatrix::kMPersp2])
|
||||
};
|
||||
GL_CALL(MatrixMode(GR_GL_PROJECTION));
|
||||
GL_CALL(LoadMatrixf(mv));
|
||||
@ -133,23 +133,23 @@ void GrGpuGL::flushViewMatrix(DrawType type) {
|
||||
fCurrentProgram->fViewportSize != viewportSize) {
|
||||
GrMatrix m;
|
||||
m.setAll(
|
||||
GrIntToScalar(2) / viewportSize.fWidth, 0, -GR_Scalar1,
|
||||
0,-GrIntToScalar(2) / viewportSize.fHeight, GR_Scalar1,
|
||||
SkIntToScalar(2) / viewportSize.fWidth, 0, -SK_Scalar1,
|
||||
0,-SkIntToScalar(2) / viewportSize.fHeight, SK_Scalar1,
|
||||
0, 0, GrMatrix::I()[8]);
|
||||
m.setConcat(m, vm);
|
||||
|
||||
// ES doesn't allow you to pass true to the transpose param,
|
||||
// so do our own transpose
|
||||
GrGLfloat mt[] = {
|
||||
GrScalarToFloat(m[GrMatrix::kMScaleX]),
|
||||
GrScalarToFloat(m[GrMatrix::kMSkewY]),
|
||||
GrScalarToFloat(m[GrMatrix::kMPersp0]),
|
||||
GrScalarToFloat(m[GrMatrix::kMSkewX]),
|
||||
GrScalarToFloat(m[GrMatrix::kMScaleY]),
|
||||
GrScalarToFloat(m[GrMatrix::kMPersp1]),
|
||||
GrScalarToFloat(m[GrMatrix::kMTransX]),
|
||||
GrScalarToFloat(m[GrMatrix::kMTransY]),
|
||||
GrScalarToFloat(m[GrMatrix::kMPersp2])
|
||||
SkScalarToFloat(m[GrMatrix::kMScaleX]),
|
||||
SkScalarToFloat(m[GrMatrix::kMSkewY]),
|
||||
SkScalarToFloat(m[GrMatrix::kMPersp0]),
|
||||
SkScalarToFloat(m[GrMatrix::kMSkewX]),
|
||||
SkScalarToFloat(m[GrMatrix::kMScaleY]),
|
||||
SkScalarToFloat(m[GrMatrix::kMPersp1]),
|
||||
SkScalarToFloat(m[GrMatrix::kMTransX]),
|
||||
SkScalarToFloat(m[GrMatrix::kMTransY]),
|
||||
SkScalarToFloat(m[GrMatrix::kMPersp2])
|
||||
};
|
||||
fCurrentProgram->fUniformManager.setMatrix3f(fCurrentProgram->fUniforms.fViewMatrixUni, mt);
|
||||
fCurrentProgram->fViewMatrix = vm;
|
||||
@ -166,8 +166,8 @@ void GrGpuGL::AdjustTextureMatrix(const GrTexture* texture, GrMatrix* matrix) {
|
||||
GrAssert(NULL != matrix);
|
||||
if (GrSurface::kBottomLeft_Origin == texture->origin()) {
|
||||
GrMatrix invY;
|
||||
invY.setAll(GR_Scalar1, 0, 0,
|
||||
0, -GR_Scalar1, GR_Scalar1,
|
||||
invY.setAll(SK_Scalar1, 0, 0,
|
||||
0, -SK_Scalar1, SK_Scalar1,
|
||||
0, 0, GrMatrix::I()[8]);
|
||||
matrix->postConcat(invY);
|
||||
}
|
||||
@ -219,15 +219,15 @@ void GrGpuGL::flushTextureMatrix(int s) {
|
||||
// ES doesn't allow you to pass true to the transpose param,
|
||||
// so do our own transpose
|
||||
GrGLfloat mt[] = {
|
||||
GrScalarToFloat(m[GrMatrix::kMScaleX]),
|
||||
GrScalarToFloat(m[GrMatrix::kMSkewY]),
|
||||
GrScalarToFloat(m[GrMatrix::kMPersp0]),
|
||||
GrScalarToFloat(m[GrMatrix::kMSkewX]),
|
||||
GrScalarToFloat(m[GrMatrix::kMScaleY]),
|
||||
GrScalarToFloat(m[GrMatrix::kMPersp1]),
|
||||
GrScalarToFloat(m[GrMatrix::kMTransX]),
|
||||
GrScalarToFloat(m[GrMatrix::kMTransY]),
|
||||
GrScalarToFloat(m[GrMatrix::kMPersp2])
|
||||
SkScalarToFloat(m[GrMatrix::kMScaleX]),
|
||||
SkScalarToFloat(m[GrMatrix::kMSkewY]),
|
||||
SkScalarToFloat(m[GrMatrix::kMPersp0]),
|
||||
SkScalarToFloat(m[GrMatrix::kMSkewX]),
|
||||
SkScalarToFloat(m[GrMatrix::kMScaleY]),
|
||||
SkScalarToFloat(m[GrMatrix::kMPersp1]),
|
||||
SkScalarToFloat(m[GrMatrix::kMTransX]),
|
||||
SkScalarToFloat(m[GrMatrix::kMTransY]),
|
||||
SkScalarToFloat(m[GrMatrix::kMPersp2])
|
||||
};
|
||||
|
||||
fCurrentProgram->fUniformManager.setMatrix3f(matrixUni, mt);
|
||||
@ -464,7 +464,7 @@ void GrGpuGL::setupGeometry(int* startVertex,
|
||||
scalarType = TEXT_COORDS_GL_TYPE;
|
||||
texCoordNorm = SkToBool(TEXT_COORDS_ARE_NORMALIZED);
|
||||
} else {
|
||||
GR_STATIC_ASSERT(GR_SCALAR_IS_FLOAT);
|
||||
GR_STATIC_ASSERT(SK_SCALAR_IS_FLOAT);
|
||||
scalarType = GR_GL_FLOAT;
|
||||
texCoordNorm = false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user