summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2014-01-07 12:20:14 +0000
committerTorne (Richard Coles) <torne@google.com>2014-01-07 12:20:14 +0000
commit4be2ed583ad99f8eb407e6f4ff8f99f2de868764 (patch)
tree326b35b6866d3ec88a87da405b99314568bfbd62
parent33792060d1b563455862fbae2ebcb4a0a3100109 (diff)
parent4dea14523691a3e2904f6b7614b6a1e01a7b537d (diff)
downloadsrc-4be2ed583ad99f8eb407e6f4ff8f99f2de868764.tar.gz
Merge from Chromium at DEPS revision 33.0.1750.16
This commit was generated by merge_to_master.py. Change-Id: Ic2c2f7b040db93139c4321c5a0f0666792156c15
-rw-r--r--core/SkCanvas.cpp53
-rw-r--r--core/SkDraw.cpp45
-rw-r--r--core/SkMatrix.cpp7
-rw-r--r--pdf/SkPDFDevice.cpp38
4 files changed, 73 insertions, 70 deletions
diff --git a/core/SkCanvas.cpp b/core/SkCanvas.cpp
index 47d3cca8..feeba758 100644
--- a/core/SkCanvas.cpp
+++ b/core/SkCanvas.cpp
@@ -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;
diff --git a/core/SkDraw.cpp b/core/SkDraw.cpp
index 52891ea5..ccab56ca 100644
--- a/core/SkDraw.cpp
+++ b/core/SkDraw.cpp
@@ -1841,19 +1841,16 @@ void SkDraw::drawText(const char text[], size_t byteLength,
// e.g. subpixel doesn't round
typedef void (*AlignProc)(const SkPoint&, const SkGlyph&, SkIPoint*);
-static void leftAlignProc(const SkPoint& loc, const SkGlyph& glyph,
- SkIPoint* dst) {
+static void leftAlignProc(const SkPoint& loc, const SkGlyph& glyph, SkIPoint* dst) {
dst->set(SkScalarToFixed(loc.fX), SkScalarToFixed(loc.fY));
}
-static void centerAlignProc(const SkPoint& loc, const SkGlyph& glyph,
- SkIPoint* dst) {
+static void centerAlignProc(const SkPoint& loc, const SkGlyph& glyph, SkIPoint* dst) {
dst->set(SkScalarToFixed(loc.fX) - (glyph.fAdvanceX >> 1),
SkScalarToFixed(loc.fY) - (glyph.fAdvanceY >> 1));
}
-static void rightAlignProc(const SkPoint& loc, const SkGlyph& glyph,
- SkIPoint* dst) {
+static void rightAlignProc(const SkPoint& loc, const SkGlyph& glyph, SkIPoint* dst) {
dst->set(SkScalarToFixed(loc.fX) - glyph.fAdvanceX,
SkScalarToFixed(loc.fY) - glyph.fAdvanceY);
}
@@ -1868,6 +1865,32 @@ static AlignProc pick_align_proc(SkPaint::Align align) {
return gProcs[align];
}
+typedef void (*AlignProc_scalar)(const SkPoint&, const SkGlyph&, SkPoint*);
+
+static void leftAlignProc_scalar(const SkPoint& loc, const SkGlyph& glyph, SkPoint* dst) {
+ dst->set(loc.fX, loc.fY);
+}
+
+static void centerAlignProc_scalar(const SkPoint& loc, const SkGlyph& glyph, SkPoint* dst) {
+ dst->set(loc.fX - SkFixedToScalar(glyph.fAdvanceX >> 1),
+ loc.fY - SkFixedToScalar(glyph.fAdvanceY >> 1));
+}
+
+static void rightAlignProc_scalar(const SkPoint& loc, const SkGlyph& glyph, SkPoint* dst) {
+ dst->set(loc.fX - SkFixedToScalar(glyph.fAdvanceX),
+ loc.fY - SkFixedToScalar(glyph.fAdvanceY));
+}
+
+static AlignProc_scalar pick_align_proc_scalar(SkPaint::Align align) {
+ static const AlignProc_scalar gProcs[] = {
+ leftAlignProc_scalar, centerAlignProc_scalar, rightAlignProc_scalar
+ };
+
+ SkASSERT((unsigned)align < SK_ARRAY_COUNT(gProcs));
+
+ return gProcs[align];
+}
+
class TextMapState {
public:
mutable SkPoint fLoc;
@@ -1944,7 +1967,7 @@ void SkDraw::drawPosText_asPaths(const char text[], size_t byteLength,
SkGlyphCache* cache = autoCache.getCache();
const char* stop = text + byteLength;
- AlignProc alignProc = pick_align_proc(paint.getTextAlign());
+ AlignProc_scalar alignProc = pick_align_proc_scalar(paint.getTextAlign());
TextMapState tms(SkMatrix::I(), constY);
TextMapState::Proc tmsProc = tms.pickProc(scalarsPerPosition);
@@ -1954,11 +1977,11 @@ void SkDraw::drawPosText_asPaths(const char text[], size_t byteLength,
const SkPath* path = cache->findPath(glyph);
if (path) {
tmsProc(tms, pos);
- SkIPoint fixedLoc;
- alignProc(tms.fLoc, glyph, &fixedLoc);
+ SkPoint loc;
+ alignProc(tms.fLoc, glyph, &loc);
- matrix[SkMatrix::kMTransX] = SkFixedToScalar(fixedLoc.fX);
- matrix[SkMatrix::kMTransY] = SkFixedToScalar(fixedLoc.fY);
+ matrix[SkMatrix::kMTransX] = loc.fX;
+ matrix[SkMatrix::kMTransY] = loc.fY;
if (fDevice) {
fDevice->drawPath(*this, *path, paint, &matrix, false);
} else {
diff --git a/core/SkMatrix.cpp b/core/SkMatrix.cpp
index 474f2722..d9c2677a 100644
--- a/core/SkMatrix.cpp
+++ b/core/SkMatrix.cpp
@@ -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);
diff --git a/pdf/SkPDFDevice.cpp b/pdf/SkPDFDevice.cpp
index cdfec330..6625a8e7 100644
--- a/pdf/SkPDFDevice.cpp
+++ b/pdf/SkPDFDevice.cpp
@@ -1912,8 +1912,10 @@ void SkPDFDevice::finishContentEntry(SkXfermode::Mode xfermode,
ContentEntry* contentEntries = getContentEntries()->get();
SkASSERT(dst);
SkASSERT(!contentEntries->fNext.get());
- // We have to make a copy of these here because changing the current
- // content into a form-xobject will destroy them.
+ // Changing the current content into a form-xobject will destroy the clip
+ // objects which is fine since the xobject will already be clipped. However
+ // if source has shape, we need to clip it too, so a copy of the clip is
+ // saved.
SkClipStack clipStack = contentEntries->fState.fClipStack;
SkRegion clipRegion = contentEntries->fState.fClipRegion;
@@ -1930,7 +1932,8 @@ void SkPDFDevice::finishContentEntry(SkXfermode::Mode xfermode,
// reduces to Dst.
if (shape == NULL || xfermode == SkXfermode::kDstOut_Mode ||
xfermode == SkXfermode::kSrcATop_Mode) {
- ScopedContentEntry content(this, &clipStack, clipRegion, identity,
+ ScopedContentEntry content(this, &fExistingClipStack,
+ fExistingClipRegion, identity,
stockPaint);
SkPDFUtils::DrawFormXObject(this->addXObjectResource(dst),
&content.entry()->fContent);
@@ -1951,7 +1954,7 @@ void SkPDFDevice::finishContentEntry(SkXfermode::Mode xfermode,
// the non-transparent parts of the device and the outlines (shape) of
// all images and devices drawn.
drawFormXObjectWithMask(addXObjectResource(srcFormXObject.get()), dst,
- &clipStack, clipRegion,
+ &fExistingClipStack, fExistingClipRegion,
SkXfermode::kSrcOver_Mode, true);
} else {
SkAutoTUnref<SkPDFFormXObject> dstMaskStorage;
@@ -1970,16 +1973,17 @@ void SkPDFDevice::finishContentEntry(SkXfermode::Mode xfermode,
dstMaskStorage.reset(createFormXObjectFromDevice());
dstMask = dstMaskStorage.get();
}
- drawFormXObjectWithMask(addXObjectResource(dst), dstMask, &clipStack,
- clipRegion, SkXfermode::kSrcOver_Mode, true);
+ drawFormXObjectWithMask(addXObjectResource(dst), dstMask,
+ &fExistingClipStack, fExistingClipRegion,
+ SkXfermode::kSrcOver_Mode, true);
}
if (xfermode == SkXfermode::kClear_Mode) {
return;
} else if (xfermode == SkXfermode::kSrc_Mode ||
xfermode == SkXfermode::kDstATop_Mode) {
- ScopedContentEntry content(this, &clipStack, clipRegion, identity,
- stockPaint);
+ ScopedContentEntry content(this, &fExistingClipStack,
+ fExistingClipRegion, identity, stockPaint);
if (content.entry()) {
SkPDFUtils::DrawFormXObject(
this->addXObjectResource(srcFormXObject.get()),
@@ -1989,8 +1993,8 @@ void SkPDFDevice::finishContentEntry(SkXfermode::Mode xfermode,
return;
}
} else if (xfermode == SkXfermode::kSrcATop_Mode) {
- ScopedContentEntry content(this, &clipStack, clipRegion, identity,
- stockPaint);
+ ScopedContentEntry content(this, &fExistingClipStack,
+ fExistingClipRegion, identity, stockPaint);
if (content.entry()) {
SkPDFUtils::DrawFormXObject(this->addXObjectResource(dst),
&content.entry()->fContent);
@@ -2005,30 +2009,24 @@ void SkPDFDevice::finishContentEntry(SkXfermode::Mode xfermode,
xfermode == SkXfermode::kDstATop_Mode ||
xfermode == SkXfermode::kModulate_Mode);
- ScopedContentEntry inShapeContentEntry(this, &fExistingClipStack,
- fExistingClipRegion, identity,
- stockPaint);
- if (!inShapeContentEntry.entry()) {
- return;
- }
-
if (xfermode == SkXfermode::kSrcIn_Mode ||
xfermode == SkXfermode::kSrcOut_Mode ||
xfermode == SkXfermode::kSrcATop_Mode) {
drawFormXObjectWithMask(addXObjectResource(srcFormXObject.get()), dst,
- &clipStack, clipRegion,
+ &fExistingClipStack, fExistingClipRegion,
SkXfermode::kSrcOver_Mode,
xfermode == SkXfermode::kSrcOut_Mode);
} else {
SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode;
if (xfermode == SkXfermode::kModulate_Mode) {
drawFormXObjectWithMask(addXObjectResource(srcFormXObject.get()),
- dst, &clipStack, clipRegion,
+ dst, &fExistingClipStack,
+ fExistingClipRegion,
SkXfermode::kSrcOver_Mode, false);
mode = SkXfermode::kMultiply_Mode;
}
drawFormXObjectWithMask(addXObjectResource(dst), srcFormXObject.get(),
- &clipStack, clipRegion, mode,
+ &fExistingClipStack, fExistingClipRegion, mode,
xfermode == SkXfermode::kDstOut_Mode);
}
}