Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(856)

Unified Diff: src/pipe/SkGPipeWrite.cpp

Issue 203203004: Consolidate SkCanvas matrix virtuals. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Updated per review. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkPictureRecord.cpp ('k') | src/utils/SkDeferredCanvas.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pipe/SkGPipeWrite.cpp
diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp
index 637778500a2097539efe6cde01e0f711f27c2d96..17695ae63f6f082206ef071e6f6316bd21f88096 100644
--- a/src/pipe/SkGPipeWrite.cpp
+++ b/src/pipe/SkGPipeWrite.cpp
@@ -281,10 +281,6 @@ protected:
virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE;
virtual void willRestore() SK_OVERRIDE;
- virtual void didTranslate(SkScalar, SkScalar) SK_OVERRIDE;
- virtual void didScale(SkScalar, SkScalar) SK_OVERRIDE;
- virtual void didRotate(SkScalar) SK_OVERRIDE;
- virtual void didSkew(SkScalar, SkScalar) SK_OVERRIDE;
virtual void didConcat(const SkMatrix&) SK_OVERRIDE;
virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE;
@@ -296,6 +292,10 @@ protected:
virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE;
private:
+ void recordTranslate(const SkMatrix&);
+ void recordScale(const SkMatrix&);
+ void recordConcat(const SkMatrix&);
+
enum {
kNoSaveLayer = -1,
};
@@ -572,61 +572,45 @@ bool SkGPipeCanvas::isDrawingToLayer() const {
return kNoSaveLayer != fFirstSaveLayerStackLevel;
}
-void SkGPipeCanvas::didTranslate(SkScalar dx, SkScalar dy) {
- if (dx || dy) {
- NOTIFY_SETUP(this);
- if (this->needOpBytes(2 * sizeof(SkScalar))) {
- this->writeOp(kTranslate_DrawOp);
- fWriter.writeScalar(dx);
- fWriter.writeScalar(dy);
- }
+void SkGPipeCanvas::recordTranslate(const SkMatrix& m) {
+ if (this->needOpBytes(2 * sizeof(SkScalar))) {
+ this->writeOp(kTranslate_DrawOp);
+ fWriter.writeScalar(m.getTranslateX());
+ fWriter.writeScalar(m.getTranslateY());
}
- this->INHERITED::didTranslate(dx, dy);
}
-void SkGPipeCanvas::didScale(SkScalar sx, SkScalar sy) {
- if (sx || sy) {
- NOTIFY_SETUP(this);
- if (this->needOpBytes(2 * sizeof(SkScalar))) {
- this->writeOp(kScale_DrawOp);
- fWriter.writeScalar(sx);
- fWriter.writeScalar(sy);
- }
+void SkGPipeCanvas::recordScale(const SkMatrix& m) {
+ if (this->needOpBytes(2 * sizeof(SkScalar))) {
+ this->writeOp(kScale_DrawOp);
+ fWriter.writeScalar(m.getScaleX());
+ fWriter.writeScalar(m.getScaleY());
}
- this->INHERITED::didScale(sx, sy);
}
-void SkGPipeCanvas::didRotate(SkScalar degrees) {
- if (degrees) {
- NOTIFY_SETUP(this);
- if (this->needOpBytes(sizeof(SkScalar))) {
- this->writeOp(kRotate_DrawOp);
- fWriter.writeScalar(degrees);
- }
+void SkGPipeCanvas::recordConcat(const SkMatrix& m) {
+ if (this->needOpBytes(m.writeToMemory(NULL))) {
+ this->writeOp(kConcat_DrawOp);
+ fWriter.writeMatrix(m);
}
- this->INHERITED::didRotate(degrees);
-}
-
-void SkGPipeCanvas::didSkew(SkScalar sx, SkScalar sy) {
- if (sx || sy) {
- NOTIFY_SETUP(this);
- if (this->needOpBytes(2 * sizeof(SkScalar))) {
- this->writeOp(kSkew_DrawOp);
- fWriter.writeScalar(sx);
- fWriter.writeScalar(sy);
- }
- }
- this->INHERITED::didSkew(sx, sy);
}
void SkGPipeCanvas::didConcat(const SkMatrix& matrix) {
if (!matrix.isIdentity()) {
NOTIFY_SETUP(this);
- if (this->needOpBytes(matrix.writeToMemory(NULL))) {
- this->writeOp(kConcat_DrawOp);
- fWriter.writeMatrix(matrix);
+ switch (matrix.getType()) {
+ case SkMatrix::kTranslate_Mask:
+ this->recordTranslate(matrix);
+ break;
+ case SkMatrix::kScale_Mask:
+ this->recordScale(matrix);
+ break;
+ default:
+ this->recordConcat(matrix);
+ break;
}
}
+
this->INHERITED::didConcat(matrix);
}
« no previous file with comments | « src/core/SkPictureRecord.cpp ('k') | src/utils/SkDeferredCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698