| OLD | NEW |
| 1 #include "SkRecorder.h" | 1 #include "SkRecorder.h" |
| 2 #include "SkPicture.h" | 2 #include "SkPicture.h" |
| 3 | 3 |
| 4 // SkCanvas will fail in mysterious ways if it doesn't know the real width and h
eight. | 4 // SkCanvas will fail in mysterious ways if it doesn't know the real width and h
eight. |
| 5 SkRecorder::SkRecorder(SkRecord* record, int width, int height) | 5 SkRecorder::SkRecorder(SkRecorder::Mode mode, SkRecord* record, int width, int h
eight) |
| 6 : SkCanvas(width, height), fRecord(record) {} | 6 : SkCanvas(width, height), fMode(mode), fRecord(record) {} |
| 7 | 7 |
| 8 // To make appending to fRecord a little less verbose. | 8 // To make appending to fRecord a little less verbose. |
| 9 #define APPEND(T, ...) \ | 9 #define APPEND(T, ...) \ |
| 10 SkNEW_PLACEMENT_ARGS(fRecord->append<SkRecords::T>(), SkRecords::T, (__V
A_ARGS__)) | 10 SkNEW_PLACEMENT_ARGS(fRecord->append<SkRecords::T>(), SkRecords::T, (__V
A_ARGS__)) |
| 11 | 11 |
| 12 // For methods which must call back into SkCanvas in kReadWrite_Mode. |
| 13 #define INHERITED(method, ...) if (fMode == kReadWrite_Mode) this->SkCanvas::met
hod(__VA_ARGS__) |
| 14 |
| 12 // The structs we're creating all copy their constructor arguments. Given the w
ay the SkRecords | 15 // The structs we're creating all copy their constructor arguments. Given the w
ay the SkRecords |
| 13 // framework works, sometimes they happen to technically be copied twice, which
is fine and elided | 16 // framework works, sometimes they happen to technically be copied twice, which
is fine and elided |
| 14 // into a single copy unless the class has a non-trivial copy constructor. For
classes with | 17 // into a single copy unless the class has a non-trivial copy constructor. For
classes with |
| 15 // non-trivial copy constructors, we skip the first copy (and its destruction) b
y wrapping the value | 18 // non-trivial copy constructors, we skip the first copy (and its destruction) b
y wrapping the value |
| 16 // with delay_copy(), forcing the argument to be passed by const&. | 19 // with delay_copy(), forcing the argument to be passed by const&. |
| 17 // | 20 // |
| 18 // This is used below for SkBitmap, SkPaint, SkPath, and SkRegion, which all hav
e non-trivial copy | 21 // This is used below for SkBitmap, SkPaint, SkPath, and SkRegion, which all hav
e non-trivial copy |
| 19 // constructors and destructors. You'll know you've got a good candidate T if y
ou see ~T() show up | 22 // constructors and destructors. You'll know you've got a good candidate T if y
ou see ~T() show up |
| 20 // unexpectedly on a profile of record time. Otherwise don't bother. | 23 // unexpectedly on a profile of record time. Otherwise don't bother. |
| 21 template <typename T> | 24 template <typename T> |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 } | 90 } |
| 88 | 91 |
| 89 void SkRecorder::drawOval(const SkRect& oval, const SkPaint& paint) { | 92 void SkRecorder::drawOval(const SkRect& oval, const SkPaint& paint) { |
| 90 APPEND(DrawOval, oval, delay_copy(paint)); | 93 APPEND(DrawOval, oval, delay_copy(paint)); |
| 91 } | 94 } |
| 92 | 95 |
| 93 void SkRecorder::drawRRect(const SkRRect& rrect, const SkPaint& paint) { | 96 void SkRecorder::drawRRect(const SkRRect& rrect, const SkPaint& paint) { |
| 94 APPEND(DrawRRect, rrect, delay_copy(paint)); | 97 APPEND(DrawRRect, rrect, delay_copy(paint)); |
| 95 } | 98 } |
| 96 | 99 |
| 100 void SkRecorder::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, const
SkPaint& paint) { |
| 101 APPEND(DrawDRRect, outer, inner, delay_copy(paint)); |
| 102 } |
| 103 |
| 97 void SkRecorder::drawPath(const SkPath& path, const SkPaint& paint) { | 104 void SkRecorder::drawPath(const SkPath& path, const SkPaint& paint) { |
| 98 APPEND(DrawPath, delay_copy(path), delay_copy(paint)); | 105 APPEND(DrawPath, delay_copy(path), delay_copy(paint)); |
| 99 } | 106 } |
| 100 | 107 |
| 101 void SkRecorder::drawBitmap(const SkBitmap& bitmap, | 108 void SkRecorder::drawBitmap(const SkBitmap& bitmap, |
| 102 SkScalar left, | 109 SkScalar left, |
| 103 SkScalar top, | 110 SkScalar top, |
| 104 const SkPaint* paint) { | 111 const SkPaint* paint) { |
| 105 APPEND(DrawBitmap, delay_copy(bitmap), left, top, this->copy(paint)); | 112 APPEND(DrawBitmap, delay_copy(bitmap), left, top, this->copy(paint)); |
| 106 } | 113 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 texs ? this->copy(texs, vertexCount) : NULL, | 182 texs ? this->copy(texs, vertexCount) : NULL, |
| 176 colors ? this->copy(colors, vertexCount) : NULL, | 183 colors ? this->copy(colors, vertexCount) : NULL, |
| 177 xmode, | 184 xmode, |
| 178 this->copy(indices, indexCount), | 185 this->copy(indices, indexCount), |
| 179 indexCount, | 186 indexCount, |
| 180 delay_copy(paint)); | 187 delay_copy(paint)); |
| 181 } | 188 } |
| 182 | 189 |
| 183 void SkRecorder::willSave(SkCanvas::SaveFlags flags) { | 190 void SkRecorder::willSave(SkCanvas::SaveFlags flags) { |
| 184 APPEND(Save, flags); | 191 APPEND(Save, flags); |
| 192 INHERITED(willSave, flags); |
| 185 } | 193 } |
| 186 | 194 |
| 187 SkCanvas::SaveLayerStrategy SkRecorder::willSaveLayer(const SkRect* bounds, | 195 SkCanvas::SaveLayerStrategy SkRecorder::willSaveLayer(const SkRect* bounds, |
| 188 const SkPaint* paint, | 196 const SkPaint* paint, |
| 189 SkCanvas::SaveFlags flags)
{ | 197 SkCanvas::SaveFlags flags)
{ |
| 190 APPEND(SaveLayer, this->copy(bounds), this->copy(paint), flags); | 198 APPEND(SaveLayer, this->copy(bounds), this->copy(paint), flags); |
| 199 INHERITED(willSaveLayer, bounds, paint, flags); |
| 191 return SkCanvas::kNoLayer_SaveLayerStrategy; | 200 return SkCanvas::kNoLayer_SaveLayerStrategy; |
| 192 } | 201 } |
| 193 | 202 |
| 194 void SkRecorder::willRestore() { | 203 void SkRecorder::willRestore() { |
| 195 APPEND(Restore); | 204 APPEND(Restore); |
| 205 INHERITED(willRestore); |
| 196 } | 206 } |
| 197 | 207 |
| 198 void SkRecorder::onPushCull(const SkRect& rect) { | 208 void SkRecorder::onPushCull(const SkRect& rect) { |
| 199 APPEND(PushCull, rect, SkRecords::kUnsetPopOffset); | 209 APPEND(PushCull, rect, SkRecords::kUnsetPopOffset); |
| 200 } | 210 } |
| 201 | 211 |
| 202 void SkRecorder::onPopCull() { | 212 void SkRecorder::onPopCull() { |
| 203 APPEND(PopCull); | 213 APPEND(PopCull); |
| 204 } | 214 } |
| 205 | 215 |
| 206 void SkRecorder::didConcat(const SkMatrix& matrix) { | 216 void SkRecorder::didConcat(const SkMatrix& matrix) { |
| 207 APPEND(Concat, matrix); | 217 APPEND(Concat, matrix); |
| 218 INHERITED(didConcat, matrix); |
| 208 } | 219 } |
| 209 | 220 |
| 210 void SkRecorder::didSetMatrix(const SkMatrix& matrix) { | 221 void SkRecorder::didSetMatrix(const SkMatrix& matrix) { |
| 211 APPEND(SetMatrix, matrix); | 222 APPEND(SetMatrix, matrix); |
| 212 } | 223 INHERITED(didSetMatrix, matrix); |
| 213 | |
| 214 void SkRecorder::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, const
SkPaint& paint) { | |
| 215 APPEND(DrawDRRect, outer, inner, delay_copy(paint)); | |
| 216 } | 224 } |
| 217 | 225 |
| 218 void SkRecorder::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle e
dgeStyle) { | 226 void SkRecorder::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle e
dgeStyle) { |
| 219 APPEND(ClipRect, rect, op, edgeStyle == kSoft_ClipEdgeStyle); | 227 APPEND(ClipRect, rect, op, edgeStyle == kSoft_ClipEdgeStyle); |
| 228 INHERITED(onClipRect, rect, op, edgeStyle); |
| 220 } | 229 } |
| 221 | 230 |
| 222 void SkRecorder::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyl
e edgeStyle) { | 231 void SkRecorder::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyl
e edgeStyle) { |
| 223 APPEND(ClipRRect, rrect, op, edgeStyle == kSoft_ClipEdgeStyle); | 232 APPEND(ClipRRect, rrect, op, edgeStyle == kSoft_ClipEdgeStyle); |
| 233 INHERITED(updateClipConservativelyUsingBounds, rrect.getBounds(), op, false)
; |
| 224 } | 234 } |
| 225 | 235 |
| 226 void SkRecorder::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle e
dgeStyle) { | 236 void SkRecorder::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle e
dgeStyle) { |
| 227 APPEND(ClipPath, delay_copy(path), op, edgeStyle == kSoft_ClipEdgeStyle); | 237 APPEND(ClipPath, delay_copy(path), op, edgeStyle == kSoft_ClipEdgeStyle); |
| 238 INHERITED(updateClipConservativelyUsingBounds, path.getBounds(), op, path.is
InverseFillType()); |
| 228 } | 239 } |
| 229 | 240 |
| 230 void SkRecorder::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { | 241 void SkRecorder::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { |
| 231 APPEND(ClipRegion, delay_copy(deviceRgn), op); | 242 APPEND(ClipRegion, delay_copy(deviceRgn), op); |
| 243 INHERITED(onClipRegion, deviceRgn, op); |
| 232 } | 244 } |
| OLD | NEW |