remove SkScalarCompare type and header
BUG= R=fmalita@chromium.org Review URL: https://codereview.chromium.org/113193004 git-svn-id: http://skia.googlecode.com/svn/trunk@12681 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
a3f882c475
commit
c0784dbd40
@ -279,7 +279,6 @@
|
||||
'<(skia_include_path)/core/SkRegion.h',
|
||||
'<(skia_include_path)/core/SkRRect.h',
|
||||
'<(skia_include_path)/core/SkScalar.h',
|
||||
'<(skia_include_path)/core/SkScalarCompare.h',
|
||||
'<(skia_include_path)/core/SkShader.h',
|
||||
'<(skia_include_path)/core/SkStream.h',
|
||||
'<(skia_include_path)/core/SkString.h',
|
||||
|
@ -218,7 +218,6 @@
|
||||
'core/SkStrokeRec.h',
|
||||
'core/SkImageDecoder.h',
|
||||
'core/SkTime.h',
|
||||
'core/SkScalarCompare.h',
|
||||
'core/SkPathMeasure.h',
|
||||
'core/SkMaskFilter.h',
|
||||
'core/SkBounder.h',
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "SkRefCnt.h"
|
||||
#include "SkPath.h"
|
||||
#include "SkRegion.h"
|
||||
#include "SkScalarCompare.h"
|
||||
#include "SkXfermode.h"
|
||||
|
||||
class SkBounder;
|
||||
@ -455,14 +454,13 @@ public:
|
||||
not intersect the current clip)
|
||||
*/
|
||||
bool quickRejectY(SkScalar top, SkScalar bottom) const {
|
||||
SkASSERT(SkScalarToCompareType(top) <= SkScalarToCompareType(bottom));
|
||||
const SkRectCompareType& clipR = this->getLocalClipBoundsCompareType();
|
||||
SkASSERT(top <= bottom);
|
||||
const SkRect& clipR = this->getLocalClipBounds();
|
||||
// In the case where the clip is empty and we are provided with a
|
||||
// negative top and positive bottom parameter then this test will return
|
||||
// false even though it will be clipped. We have chosen to exclude that
|
||||
// check as it is rare and would result double the comparisons.
|
||||
return SkScalarToCompareType(top) >= clipR.fBottom
|
||||
|| SkScalarToCompareType(bottom) <= clipR.fTop;
|
||||
return top >= clipR.fBottom || bottom <= clipR.fTop;
|
||||
}
|
||||
|
||||
/** Return the bounds of the current clip (in local coordinates) in the
|
||||
@ -1100,20 +1098,20 @@ private:
|
||||
/* These maintain a cache of the clip bounds in local coordinates,
|
||||
(converted to 2s-compliment if floats are slow).
|
||||
*/
|
||||
mutable SkRectCompareType fLocalBoundsCompareType;
|
||||
mutable bool fLocalBoundsCompareTypeDirty;
|
||||
mutable SkRect fCachedLocalClipBounds;
|
||||
mutable bool fCachedLocalClipBoundsDirty;
|
||||
bool fAllowSoftClip;
|
||||
bool fAllowSimplifyClip;
|
||||
|
||||
const SkRectCompareType& getLocalClipBoundsCompareType() const {
|
||||
if (fLocalBoundsCompareTypeDirty) {
|
||||
this->computeLocalClipBoundsCompareType();
|
||||
fLocalBoundsCompareTypeDirty = false;
|
||||
const SkRect& getLocalClipBounds() const {
|
||||
if (fCachedLocalClipBoundsDirty) {
|
||||
if (!this->getClipBounds(&fCachedLocalClipBounds)) {
|
||||
fCachedLocalClipBounds.setEmpty();
|
||||
}
|
||||
fCachedLocalClipBoundsDirty = false;
|
||||
}
|
||||
return fLocalBoundsCompareType;
|
||||
return fCachedLocalClipBounds;
|
||||
}
|
||||
void computeLocalClipBoundsCompareType() const;
|
||||
|
||||
|
||||
class AutoValidateClip : ::SkNoncopyable {
|
||||
public:
|
||||
|
@ -1,38 +0,0 @@
|
||||
|
||||
/*
|
||||
* 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 SkScalarCompare_DEFINED
|
||||
#define SkScalarCompare_DEFINED
|
||||
|
||||
#include "SkFloatBits.h"
|
||||
#include "SkRect.h"
|
||||
|
||||
/** Skia can spend a lot of time just comparing scalars (e.g. quickReject).
|
||||
When scalar==fixed, this is very fast, and when scalar==hardware-float, this
|
||||
is also reasonable, but if scalar==software-float, then each compare can be
|
||||
a function call and take real time. To account for that, we have the flag
|
||||
SK_SCALAR_SLOW_COMPARES.
|
||||
|
||||
If this is defined, we have a special trick where we quickly convert floats
|
||||
to a 2's compliment form, and then treat them as signed 32bit integers. In
|
||||
this form we lose a few subtlties (e.g. NaNs always comparing false) but
|
||||
we gain the speed of integer compares.
|
||||
*/
|
||||
|
||||
#ifdef SK_SCALAR_SLOW_COMPARES
|
||||
typedef int32_t SkScalarCompareType;
|
||||
typedef SkIRect SkRectCompareType;
|
||||
#define SkScalarToCompareType(x) SkScalarAs2sCompliment(x)
|
||||
#else
|
||||
typedef SkScalar SkScalarCompareType;
|
||||
typedef SkRect SkRectCompareType;
|
||||
#define SkScalarToCompareType(x) (x)
|
||||
#endif
|
||||
|
||||
#endif
|
@ -19,7 +19,6 @@
|
||||
#include "SkPicture.h"
|
||||
#include "SkRasterClip.h"
|
||||
#include "SkRRect.h"
|
||||
#include "SkScalarCompare.h"
|
||||
#include "SkSurface_Base.h"
|
||||
#include "SkTemplates.h"
|
||||
#include "SkTextFormatParams.h"
|
||||
@ -485,8 +484,8 @@ private:
|
||||
|
||||
SkBaseDevice* SkCanvas::init(SkBaseDevice* device) {
|
||||
fBounder = NULL;
|
||||
fLocalBoundsCompareType.setEmpty();
|
||||
fLocalBoundsCompareTypeDirty = true;
|
||||
fCachedLocalClipBounds.setEmpty();
|
||||
fCachedLocalClipBoundsDirty = true;
|
||||
fAllowSoftClip = true;
|
||||
fAllowSimplifyClip = false;
|
||||
fDeviceCMDirty = false;
|
||||
@ -897,7 +896,7 @@ void SkCanvas::internalRestore() {
|
||||
SkASSERT(fMCStack.count() != 0);
|
||||
|
||||
fDeviceCMDirty = true;
|
||||
fLocalBoundsCompareTypeDirty = true;
|
||||
fCachedLocalClipBoundsDirty = true;
|
||||
|
||||
if (SkCanvas::kClip_SaveFlag & fMCRec->fFlags) {
|
||||
fClipStack.restore();
|
||||
@ -1056,37 +1055,37 @@ void SkCanvas::drawSprite(const SkBitmap& bitmap, int x, int y,
|
||||
|
||||
bool SkCanvas::translate(SkScalar dx, SkScalar dy) {
|
||||
fDeviceCMDirty = true;
|
||||
fLocalBoundsCompareTypeDirty = true;
|
||||
fCachedLocalClipBoundsDirty = true;
|
||||
return fMCRec->fMatrix->preTranslate(dx, dy);
|
||||
}
|
||||
|
||||
bool SkCanvas::scale(SkScalar sx, SkScalar sy) {
|
||||
fDeviceCMDirty = true;
|
||||
fLocalBoundsCompareTypeDirty = true;
|
||||
fCachedLocalClipBoundsDirty = true;
|
||||
return fMCRec->fMatrix->preScale(sx, sy);
|
||||
}
|
||||
|
||||
bool SkCanvas::rotate(SkScalar degrees) {
|
||||
fDeviceCMDirty = true;
|
||||
fLocalBoundsCompareTypeDirty = true;
|
||||
fCachedLocalClipBoundsDirty = true;
|
||||
return fMCRec->fMatrix->preRotate(degrees);
|
||||
}
|
||||
|
||||
bool SkCanvas::skew(SkScalar sx, SkScalar sy) {
|
||||
fDeviceCMDirty = true;
|
||||
fLocalBoundsCompareTypeDirty = true;
|
||||
fCachedLocalClipBoundsDirty = true;
|
||||
return fMCRec->fMatrix->preSkew(sx, sy);
|
||||
}
|
||||
|
||||
bool SkCanvas::concat(const SkMatrix& matrix) {
|
||||
fDeviceCMDirty = true;
|
||||
fLocalBoundsCompareTypeDirty = true;
|
||||
fCachedLocalClipBoundsDirty = true;
|
||||
return fMCRec->fMatrix->preConcat(matrix);
|
||||
}
|
||||
|
||||
void SkCanvas::setMatrix(const SkMatrix& matrix) {
|
||||
fDeviceCMDirty = true;
|
||||
fLocalBoundsCompareTypeDirty = true;
|
||||
fCachedLocalClipBoundsDirty = true;
|
||||
*fMCRec->fMatrix = matrix;
|
||||
}
|
||||
|
||||
@ -1110,7 +1109,7 @@ bool SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
|
||||
|
||||
if (this->quickReject(rect)) {
|
||||
fDeviceCMDirty = true;
|
||||
fLocalBoundsCompareTypeDirty = true;
|
||||
fCachedLocalClipBoundsDirty = true;
|
||||
|
||||
fClipStack.clipEmpty();
|
||||
return fMCRec->fRasterClip->setEmpty();
|
||||
@ -1121,7 +1120,7 @@ bool SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
|
||||
AutoValidateClip avc(this);
|
||||
|
||||
fDeviceCMDirty = true;
|
||||
fLocalBoundsCompareTypeDirty = true;
|
||||
fCachedLocalClipBoundsDirty = true;
|
||||
doAA &= fAllowSoftClip;
|
||||
|
||||
if (fMCRec->fMatrix->rectStaysRect()) {
|
||||
@ -1206,7 +1205,7 @@ bool SkCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
|
||||
|
||||
if (this->quickReject(path.getBounds())) {
|
||||
fDeviceCMDirty = true;
|
||||
fLocalBoundsCompareTypeDirty = true;
|
||||
fCachedLocalClipBoundsDirty = true;
|
||||
|
||||
fClipStack.clipEmpty();
|
||||
return fMCRec->fRasterClip->setEmpty();
|
||||
@ -1217,7 +1216,7 @@ bool SkCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
|
||||
AutoValidateClip avc(this);
|
||||
|
||||
fDeviceCMDirty = true;
|
||||
fLocalBoundsCompareTypeDirty = true;
|
||||
fCachedLocalClipBoundsDirty = true;
|
||||
doAA &= fAllowSoftClip;
|
||||
|
||||
SkPath devPath;
|
||||
@ -1350,7 +1349,7 @@ bool SkCanvas::clipRegion(const SkRegion& rgn, SkRegion::Op op) {
|
||||
AutoValidateClip avc(this);
|
||||
|
||||
fDeviceCMDirty = true;
|
||||
fLocalBoundsCompareTypeDirty = true;
|
||||
fCachedLocalClipBoundsDirty = true;
|
||||
|
||||
// todo: signal fClipStack that we have a region, and therefore (I guess)
|
||||
// we have to ignore it, and use the region directly?
|
||||
@ -1423,19 +1422,6 @@ void SkCanvas::replayClips(ClipVisitor* visitor) const {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SkCanvas::computeLocalClipBoundsCompareType() const {
|
||||
SkRect r;
|
||||
|
||||
if (!this->getClipBounds(&r)) {
|
||||
fLocalBoundsCompareType.setEmpty();
|
||||
} else {
|
||||
fLocalBoundsCompareType.set(SkScalarToCompareType(r.fLeft),
|
||||
SkScalarToCompareType(r.fTop),
|
||||
SkScalarToCompareType(r.fRight),
|
||||
SkScalarToCompareType(r.fBottom));
|
||||
}
|
||||
}
|
||||
|
||||
bool SkCanvas::quickReject(const SkRect& rect) const {
|
||||
|
||||
if (!rect.isFinite())
|
||||
@ -1452,17 +1438,14 @@ bool SkCanvas::quickReject(const SkRect& rect) const {
|
||||
dst.roundOut(&idst);
|
||||
return !SkIRect::Intersects(idst, fMCRec->fRasterClip->getBounds());
|
||||
} else {
|
||||
const SkRectCompareType& clipR = this->getLocalClipBoundsCompareType();
|
||||
const SkRect& clipR = this->getLocalClipBounds();
|
||||
|
||||
// for speed, do the most likely reject compares first
|
||||
SkScalarCompareType userT = SkScalarToCompareType(rect.fTop);
|
||||
SkScalarCompareType userB = SkScalarToCompareType(rect.fBottom);
|
||||
if (userT >= clipR.fBottom || userB <= clipR.fTop) {
|
||||
// TODO: should we use | instead, or compare all 4 at once?
|
||||
if (rect.fTop >= clipR.fBottom || rect.fBottom <= clipR.fTop) {
|
||||
return true;
|
||||
}
|
||||
SkScalarCompareType userL = SkScalarToCompareType(rect.fLeft);
|
||||
SkScalarCompareType userR = SkScalarToCompareType(rect.fRight);
|
||||
if (userL >= clipR.fRight || userR <= clipR.fLeft) {
|
||||
if (rect.fLeft >= clipR.fRight || rect.fRight <= clipR.fLeft) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "Sk64.h"
|
||||
#include "SkFloatBits.h"
|
||||
#include "SkOnce.h"
|
||||
#include "SkScalarCompare.h"
|
||||
#include "SkString.h"
|
||||
|
||||
#ifdef SK_SCALAR_IS_FLOAT
|
||||
@ -251,7 +250,7 @@ bool SkMatrix::preservesRightAngles(SkScalar tol) const {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SkMatrix::setTranslate(SkScalar dx, SkScalar dy) {
|
||||
if (SkScalarToCompareType(dx) || SkScalarToCompareType(dy)) {
|
||||
if (dx || dy) {
|
||||
fMat[kMTransX] = dx;
|
||||
fMat[kMTransY] = dy;
|
||||
|
||||
@ -273,7 +272,7 @@ bool SkMatrix::preTranslate(SkScalar dx, SkScalar dy) {
|
||||
return this->preConcat(m);
|
||||
}
|
||||
|
||||
if (SkScalarToCompareType(dx) || SkScalarToCompareType(dy)) {
|
||||
if (dx || dy) {
|
||||
fMat[kMTransX] += SkScalarMul(fMat[kMScaleX], dx) +
|
||||
SkScalarMul(fMat[kMSkewX], dy);
|
||||
fMat[kMTransY] += SkScalarMul(fMat[kMSkewY], dx) +
|
||||
@ -291,7 +290,7 @@ bool SkMatrix::postTranslate(SkScalar dx, SkScalar dy) {
|
||||
return this->postConcat(m);
|
||||
}
|
||||
|
||||
if (SkScalarToCompareType(dx) || SkScalarToCompareType(dy)) {
|
||||
if (dx || dy) {
|
||||
fMat[kMTransX] += dx;
|
||||
fMat[kMTransY] += dy;
|
||||
this->setTypeMask(kUnknown_Mask | kOnlyPerspectiveValid_Mask);
|
||||
|
Loading…
Reference in New Issue
Block a user