aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-12-12 19:15:31 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-12-12 19:15:31 +0000
commit25c1408c3da9ca90509b84f21a1161ef40052bd1 (patch)
tree4455a49c8761c38b489ab5dd2733d9066ef503de /src/core
parent9b0fd9aa663612c983e4dfa1323cecda6e1e9029 (diff)
revert 6762-6763, since those require new skps to be generated, and we can't
do that immediately right now... will re-submit when we can. git-svn-id: http://skia.googlecode.com/svn/trunk@6766 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkCanvas.cpp79
-rw-r--r--src/core/SkPath.cpp17
-rw-r--r--src/core/SkPictureFlat.h3
-rw-r--r--src/core/SkPicturePlayback.cpp37
-rw-r--r--src/core/SkPicturePlayback.h3
-rw-r--r--src/core/SkPictureRecord.cpp53
-rw-r--r--src/core/SkPictureRecord.h6
-rw-r--r--src/core/SkRRect.cpp24
8 files changed, 38 insertions, 184 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 3efdd22c3c..34310c8248 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -17,7 +17,6 @@
#include "SkMetaData.h"
#include "SkPicture.h"
#include "SkRasterClip.h"
-#include "SkRRect.h"
#include "SkScalarCompare.h"
#include "SkSurface_Base.h"
#include "SkTemplates.h"
@@ -1126,18 +1125,6 @@ static bool clipPathHelper(const SkCanvas* canvas, SkRasterClip* currClip,
}
}
-bool SkCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
- if (rrect.isRect()) {
- // call the non-virtual version
- return this->SkCanvas::clipRect(rrect.getBounds(), op, doAA);
- } else {
- SkPath path;
- path.addRRect(rrect);
- // call the non-virtual version
- return this->SkCanvas::clipPath(path, op, doAA);
- }
-}
-
bool SkCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
#ifdef SK_ENABLE_CLIP_QUICKREJECT
if (SkRegion::kIntersect_Op == op && !path.isInverseFillType()) {
@@ -1479,40 +1466,6 @@ void SkCanvas::drawRect(const SkRect& r, const SkPaint& paint) {
LOOPER_END
}
-void SkCanvas::drawOval(const SkRect& oval, const SkPaint& paint) {
- if (paint.canComputeFastBounds()) {
- SkRect storage;
- if (this->quickReject(paint.computeFastBounds(oval, &storage))) {
- return;
- }
- }
-
- SkPath path;
- path.addOval(oval);
- // call the non-virtual version
- this->SkCanvas::drawPath(path, paint);
-}
-
-void SkCanvas::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
- if (paint.canComputeFastBounds()) {
- SkRect storage;
- if (this->quickReject(paint.computeFastBounds(rrect.getBounds(), &storage))) {
- return;
- }
- }
-
- if (rrect.isRect()) {
- // call the non-virtual version
- this->SkCanvas::drawRect(rrect.getBounds(), paint);
- } else {
- SkPath path;
- path.addRRect(rrect);
- // call the non-virtual version
- this->SkCanvas::drawPath(path, paint);
- }
-}
-
-
void SkCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
if (!path.isFinite()) {
return;
@@ -1945,7 +1898,17 @@ void SkCanvas::drawCircle(SkScalar cx, SkScalar cy, SkScalar radius,
SkRect r;
r.set(cx - radius, cy - radius, cx + radius, cy + radius);
- this->drawOval(r, paint);
+
+ if (paint.canComputeFastBounds()) {
+ SkRect storage;
+ if (this->quickReject(paint.computeFastBounds(r, &storage))) {
+ return;
+ }
+ }
+
+ SkPath path;
+ path.addOval(r);
+ this->drawPath(path, paint);
}
void SkCanvas::drawRoundRect(const SkRect& r, SkScalar rx, SkScalar ry,
@@ -1957,14 +1920,28 @@ void SkCanvas::drawRoundRect(const SkRect& r, SkScalar rx, SkScalar ry,
return;
}
}
- SkRRect rrect;
- rrect.setRectXY(r, rx, ry);
- this->drawRRect(rrect, paint);
+
+ SkPath path;
+ path.addRoundRect(r, rx, ry, SkPath::kCW_Direction);
+ this->drawPath(path, paint);
} else {
this->drawRect(r, paint);
}
}
+void SkCanvas::drawOval(const SkRect& oval, const SkPaint& paint) {
+ if (paint.canComputeFastBounds()) {
+ SkRect storage;
+ if (this->quickReject(paint.computeFastBounds(oval, &storage))) {
+ return;
+ }
+ }
+
+ SkPath path;
+ path.addOval(oval);
+ this->drawPath(path, paint);
+}
+
void SkCanvas::drawArc(const SkRect& oval, SkScalar startAngle,
SkScalar sweepAngle, bool useCenter,
const SkPaint& paint) {
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index ae1d187d0d..fe9551492d 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -11,9 +11,9 @@
#include "SkBuffer.h"
#include "SkMath.h"
#include "SkPathRef.h"
-#include "SkRRect.h"
#include "SkThread.h"
+
////////////////////////////////////////////////////////////////////////////
#if SK_DEBUG_PATH_REF
@@ -1088,21 +1088,6 @@ void SkPath::addRoundRect(const SkRect& rect, const SkScalar rad[],
this->close();
}
-void SkPath::addRRect(const SkRRect& rrect, Direction dir) {
- const SkRect& bounds = rrect.getBounds();
-
- if (rrect.isRect()) {
- this->addRect(bounds, dir);
- } else if (rrect.isOval()) {
- this->addOval(bounds, dir);
- } else if (rrect.isSimple()) {
- const SkVector& rad = rrect.getSimpleRadii();
- this->addRoundRect(bounds, rad.x(), rad.y(), dir);
- } else {
- this->addRoundRect(bounds, (const SkScalar*)&rrect.fRadii[0], dir);
- }
-}
-
bool SkPath::hasOnlyMoveTos() const {
int count = fPathRef->countVerbs();
const uint8_t* verbs = const_cast<const SkPathRef*>(fPathRef.get())->verbsMemBegin();
diff --git a/src/core/SkPictureFlat.h b/src/core/SkPictureFlat.h
index 9594a594dd..429236150b 100644
--- a/src/core/SkPictureFlat.h
+++ b/src/core/SkPictureFlat.h
@@ -29,7 +29,6 @@ enum DrawType {
CLIP_PATH,
CLIP_REGION,
CLIP_RECT,
- CLIP_RRECT,
CONCAT,
DRAW_BITMAP,
DRAW_BITMAP_MATRIX,
@@ -37,7 +36,6 @@ enum DrawType {
DRAW_BITMAP_RECT_TO_RECT,
DRAW_CLEAR,
DRAW_DATA,
- DRAW_OVAL,
DRAW_PAINT,
DRAW_PATH,
DRAW_PICTURE,
@@ -47,7 +45,6 @@ enum DrawType {
DRAW_POS_TEXT_H,
DRAW_POS_TEXT_H_TOP_BOTTOM, // fast variant of DRAW_POS_TEXT_H
DRAW_RECT,
- DRAW_RRECT,
DRAW_SPRITE,
DRAW_TEXT,
DRAW_TEXT_ON_PATH,
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index 31ee3ece3a..9a8f133d8a 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -634,7 +634,7 @@ void SkPicturePlayback::draw(SkCanvas& canvas) {
#endif
#ifdef SPEW_CLIP_SKIPPING
- SkipClipRec skipRect, skipRRect, skipRegion, skipPath;
+ SkipClipRec skipRect, skipRegion, skipPath;
#endif
#ifdef SK_BUILD_FOR_ANDROID
@@ -731,7 +731,7 @@ void SkPicturePlayback::draw(SkCanvas& canvas) {
bool doAA = ClipParams_unpackDoAA(packed);
size_t offsetToRestore = reader.readInt();
SkASSERT(!offsetToRestore || \
- offsetToRestore >= reader.offset());
+ offsetToRestore >= reader.offset());
if (!canvas.clipRect(rect, op, doAA) && offsetToRestore) {
#ifdef SPEW_CLIP_SKIPPING
skipRect.recordSkip(offsetToRestore - reader.offset());
@@ -739,22 +739,6 @@ void SkPicturePlayback::draw(SkCanvas& canvas) {
reader.setOffset(offsetToRestore);
}
} break;
- case CLIP_RRECT: {
- SkRRect rrect;
- reader.readRRect(&rrect);
- uint32_t packed = reader.readInt();
- SkRegion::Op op = ClipParams_unpackRegionOp(packed);
- bool doAA = ClipParams_unpackDoAA(packed);
- size_t offsetToRestore = reader.readInt();
- SkASSERT(!offsetToRestore || \
- offsetToRestore >= reader.offset());
- if (!canvas.clipRRect(rrect, op, doAA) && offsetToRestore) {
-#ifdef SPEW_CLIP_SKIPPING
- skipRRect.recordSkip(offsetToRestore - reader.offset());
-#endif
- reader.setOffset(offsetToRestore);
- }
- } break;
case CONCAT:
canvas.concat(*getMatrix(reader));
break;
@@ -792,10 +776,6 @@ void SkPicturePlayback::draw(SkCanvas& canvas) {
canvas.drawData(reader.skip(length), length);
// skip handles padding the read out to a multiple of 4
} break;
- case DRAW_OVAL: {
- const SkPaint& paint = *getPaint(reader);
- canvas.drawOval(reader.skipT<SkRect>(), paint);
- } break;
case DRAW_PAINT:
canvas.drawPaint(*getPaint(reader));
break;
@@ -857,11 +837,6 @@ void SkPicturePlayback::draw(SkCanvas& canvas) {
const SkPaint& paint = *getPaint(reader);
canvas.drawRect(reader.skipT<SkRect>(), paint);
} break;
- case DRAW_RRECT: {
- const SkPaint& paint = *getPaint(reader);
- SkRRect rrect;
- canvas.drawRRect(*reader.readRRect(&rrect), paint);
- } break;
case DRAW_SPRITE: {
const SkPaint* paint = getPaint(reader);
const SkBitmap& bitmap = getBitmap(reader);
@@ -977,10 +952,10 @@ void SkPicturePlayback::draw(SkCanvas& canvas) {
#ifdef SPEW_CLIP_SKIPPING
{
- size_t size = skipRect.fSize + skipRRect.fSize + skipPath.fSize + skipRegion.fSize;
- SkDebugf("--- Clip skips %d%% rect:%d rrect:%d path:%d rgn:%d\n",
- size * 100 / reader.offset(), skipRect.fCount, skipRRect.fCount,
- skipPath.fCount, skipRegion.fCount);
+ size_t size = skipRect.fSize + skipPath.fSize + skipRegion.fSize;
+ SkDebugf("--- Clip skips %d%% rect:%d path:%d rgn:%d\n",
+ size * 100 / reader.offset(), skipRect.fCount, skipPath.fCount,
+ skipRegion.fCount);
}
#endif
// this->dumpSize();
diff --git a/src/core/SkPicturePlayback.h b/src/core/SkPicturePlayback.h
index 13a685fb92..8f52b19314 100644
--- a/src/core/SkPicturePlayback.h
+++ b/src/core/SkPicturePlayback.h
@@ -19,7 +19,6 @@
#include "SkPath.h"
#include "SkPathHeap.h"
#include "SkRegion.h"
-#include "SkRRect.h"
#include "SkPictureFlat.h"
#include "SkSerializationHelpers.h"
@@ -148,7 +147,7 @@ private:
int index = reader.readInt();
return (*fRegions)[index - 1];
}
-
+
void getText(SkReader32& reader, TextContainer* text) {
size_t length = text->fByteLength = reader.readInt();
text->fText = (const char*)reader.skip(length);
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index 82257c8e57..3c4df53b1e 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -8,7 +8,6 @@
#include "SkPictureRecord.h"
#include "SkTSearch.h"
#include "SkPixelRef.h"
-#include "SkRRect.h"
#include "SkBBoxHierarchy.h"
#include "SkPictureStateTree.h"
@@ -112,7 +111,6 @@ static inline uint32_t getSkipableSize(unsigned drawType) {
4, // CLIP_PATH,
4, // CLIP_REGION,
7, // CLIP_RECT,
- 15, // CLIP_RRECT,
2, // CONCAT,
0, // DRAW_BITMAP,
0, // DRAW_BITMAP_MATRIX,
@@ -120,7 +118,6 @@ static inline uint32_t getSkipableSize(unsigned drawType) {
0, // DRAW_BITMAP_RECT,
0, // DRAW_CLEAR,
0, // DRAW_DATA,
- 0, // DRAW_OVAL,
0, // DRAW_PAINT,
0, // DRAW_PATH,
0, // DRAW_PICTURE,
@@ -130,7 +127,6 @@ static inline uint32_t getSkipableSize(unsigned drawType) {
0, // DRAW_POS_TEXT_H,
0, // DRAW_POS_TEXT_H_TOP_BOTTOM, // fast variant of DRAW_POS_TEXT_H
0, // DRAW_RECT,
- 0, // DRAW_RRECT,
0, // DRAW_SPRITE,
0, // DRAW_TEXT,
0, // DRAW_TEXT_ON_PATH,
@@ -356,28 +352,9 @@ bool SkPictureRecord::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
addRect(rect);
addInt(ClipParams_pack(op, doAA));
recordRestoreOffsetPlaceholder(op);
-
- validate();
- return this->INHERITED::clipRect(rect, op, doAA);
-}
-bool SkPictureRecord::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
- if (rrect.isRect()) {
- return this->SkPictureRecord::clipRect(rrect.getBounds(), op, doAA);
- }
-
- addDraw(CLIP_RRECT);
- addRRect(rrect);
- addInt(ClipParams_pack(op, doAA));
- recordRestoreOffsetPlaceholder(op);
-
validate();
-
- if (fRecordFlags & SkPicture::kUsePathBoundsForClip_RecordingFlag) {
- return this->INHERITED::clipRect(rrect.getBounds(), op, doAA);
- } else {
- return this->INHERITED::clipRRect(rrect, op, doAA);
- }
+ return this->INHERITED::clipRect(rect, op, doAA);
}
bool SkPictureRecord::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
@@ -433,13 +410,6 @@ void SkPictureRecord::drawPoints(PointMode mode, size_t count, const SkPoint pts
validate();
}
-void SkPictureRecord::drawOval(const SkRect& oval, const SkPaint& paint) {
- addDraw(DRAW_OVAL);
- addPaint(paint);
- addRect(oval);
- validate();
-}
-
void SkPictureRecord::drawRect(const SkRect& rect, const SkPaint& paint) {
addDraw(DRAW_RECT);
addPaint(paint);
@@ -447,23 +417,6 @@ void SkPictureRecord::drawRect(const SkRect& rect, const SkPaint& paint) {
validate();
}
-void SkPictureRecord::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
- if (rrect.isRect()) {
- addDraw(DRAW_RECT);
- addPaint(paint);
- addRect(rrect.getBounds());
- } else if (rrect.isOval()) {
- addDraw(DRAW_OVAL);
- addPaint(paint);
- addRect(rrect.getBounds());
- } else {
- addDraw(DRAW_RRECT);
- addPaint(paint);
- addRRect(rrect);
- }
- validate();
-}
-
void SkPictureRecord::drawPath(const SkPath& path, const SkPaint& paint) {
addDraw(DRAW_PATH);
addPaint(paint);
@@ -801,10 +754,6 @@ void SkPictureRecord::addIRectPtr(const SkIRect* rect) {
}
}
-void SkPictureRecord::addRRect(const SkRRect& rrect) {
- fWriter.writeRRect(rrect);
-}
-
void SkPictureRecord::addRegion(const SkRegion& region) {
addInt(fRegions.find(region));
}
diff --git a/src/core/SkPictureRecord.h b/src/core/SkPictureRecord.h
index abaa22dd9d..77a6b04fc7 100644
--- a/src/core/SkPictureRecord.h
+++ b/src/core/SkPictureRecord.h
@@ -36,16 +36,13 @@ public:
virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE;
virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE;
virtual bool clipRect(const SkRect&, SkRegion::Op, bool) SK_OVERRIDE;
- virtual bool clipRRect(const SkRRect&, SkRegion::Op, bool) SK_OVERRIDE;
virtual bool clipPath(const SkPath&, SkRegion::Op, bool) SK_OVERRIDE;
virtual bool clipRegion(const SkRegion& region, SkRegion::Op op) SK_OVERRIDE;
virtual void clear(SkColor) SK_OVERRIDE;
virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE;
virtual void drawPoints(PointMode, size_t count, const SkPoint pts[],
const SkPaint&) SK_OVERRIDE;
- virtual void drawOval(const SkRect&, const SkPaint&) SK_OVERRIDE;
- virtual void drawRect(const SkRect&, const SkPaint&) SK_OVERRIDE;
- virtual void drawRRect(const SkRRect&, const SkPaint&) SK_OVERRIDE;
+ virtual void drawRect(const SkRect& rect, const SkPaint&) SK_OVERRIDE;
virtual void drawPath(const SkPath& path, const SkPaint&) SK_OVERRIDE;
virtual void drawBitmap(const SkBitmap&, SkScalar left, SkScalar top,
const SkPaint*) SK_OVERRIDE;
@@ -132,7 +129,6 @@ private:
void addRectPtr(const SkRect* rect);
void addIRect(const SkIRect& rect);
void addIRectPtr(const SkIRect* rect);
- void addRRect(const SkRRect&);
void addRegion(const SkRegion& region);
void addText(const void* text, size_t byteLength);
diff --git a/src/core/SkRRect.cpp b/src/core/SkRRect.cpp
index c409cd6fd7..5740a19c82 100644
--- a/src/core/SkRRect.cpp
+++ b/src/core/SkRRect.cpp
@@ -227,30 +227,6 @@ void SkRRect::computeType() const {
fType = kComplex_Type;
}
-///////////////////////////////////////////////////////////////////////////////
-
-uint32_t SkRRect::writeToMemory(void* buffer) const {
- SkASSERT(kSizeInMemory == sizeof(SkRect) + sizeof(fRadii));
-
- memcpy(buffer, &fRect, sizeof(SkRect));
- memcpy((char*)buffer + sizeof(SkRect), fRadii, sizeof(fRadii));
- return kSizeInMemory;
-}
-
-uint32_t SkRRect::readFromMemory(const void* buffer) {
- SkScalar storage[12];
- SkASSERT(sizeof(storage) == kSizeInMemory);
-
- // we make a local copy, to ensure alignment before we cast
- memcpy(storage, buffer, kSizeInMemory);
-
- this->setRectRadii(*(const SkRect*)&storage[0],
- (const SkVector*)&storage[4]);
- return kSizeInMemory;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
#ifdef SK_DEBUG
void SkRRect::validate() const {
bool allRadiiZero = (0 == fRadii[0].fX && 0 == fRadii[0].fY);