| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkAnnotation.h" | 8 #include "SkAnnotation.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkColorFilter.h" | 10 #include "SkColorFilter.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 Encoder::CommonIDs fIDs; | 156 Encoder::CommonIDs fIDs; |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 template <typename T> | 159 template <typename T> |
| 160 AutoID id(const T& val) { return AutoID(fEncoder, val); } | 160 AutoID id(const T& val) { return AutoID(fEncoder, val); } |
| 161 | 161 |
| 162 AutoCommonIDs commonIDs(const SkPaint& paint) { return AutoCommonIDs(fEn
coder, paint); } | 162 AutoCommonIDs commonIDs(const SkPaint& paint) { return AutoCommonIDs(fEn
coder, paint); } |
| 163 | 163 |
| 164 void willSave() override { fEncoder-> save(); } | 164 void willSave() override { fEncoder-> save(); } |
| 165 void didRestore() override { fEncoder->restore(); } | 165 void didRestore() override { fEncoder->restore(); } |
| 166 SaveLayerStrategy willSaveLayer(const SkRect* bounds, | 166 SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec& rec) override
{ |
| 167 const SkPaint* paint, | |
| 168 SaveFlags flags) override { | |
| 169 SkPath path; | 167 SkPath path; |
| 170 if (bounds) { | 168 if (rec.fBounds) { |
| 171 path.addRect(*bounds); | 169 path.addRect(*rec.fBounds); |
| 172 } | 170 } |
| 173 const SkPaint defaultPaint; | 171 const SkPaint defaultPaint; |
| 172 const SkPaint* paint = rec.fPaint; |
| 174 if (!paint) { | 173 if (!paint) { |
| 175 paint = &defaultPaint; | 174 paint = &defaultPaint; |
| 176 } | 175 } |
| 177 fEncoder->saveLayer(this->id(path), this->commonIDs(*paint), flags); | 176 fEncoder->saveLayer(this->id(path), this->commonIDs(*paint), rec.fSa
veLayerFlags); |
| 178 return kNoLayer_SaveLayerStrategy; | 177 return kNoLayer_SaveLayerStrategy; |
| 179 } | 178 } |
| 180 | 179 |
| 181 void didConcat(const SkMatrix&) override { this->didSetMatrix(this->g
etTotalMatrix()); } | 180 void didConcat(const SkMatrix&) override { this->didSetMatrix(this->g
etTotalMatrix()); } |
| 182 void didSetMatrix(const SkMatrix& matrix) override { | 181 void didSetMatrix(const SkMatrix& matrix) override { |
| 183 fEncoder->setMatrix(this->id(matrix)); | 182 fEncoder->setMatrix(this->id(matrix)); |
| 184 } | 183 } |
| 185 | 184 |
| 186 void onDrawOval(const SkRect& oval, const SkPaint& paint) override { | 185 void onDrawOval(const SkRect& oval, const SkPaint& paint) override { |
| 187 SkPath path; | 186 SkPath path; |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 paint->setMaskFilter (fMaskFilter .find(common.maskfilter)); | 492 paint->setMaskFilter (fMaskFilter .find(common.maskfilter)); |
| 494 paint->setColorFilter(fColorFilter.find(common.colorfilter)); | 493 paint->setColorFilter(fColorFilter.find(common.colorfilter)); |
| 495 paint->setRasterizer (fRasterizer .find(common.rasterizer)); | 494 paint->setRasterizer (fRasterizer .find(common.rasterizer)); |
| 496 paint->setLooper (fDrawLooper .find(common.looper)); | 495 paint->setLooper (fDrawLooper .find(common.looper)); |
| 497 paint->setImageFilter(fImageFilter.find(common.imagefilter)); | 496 paint->setImageFilter(fImageFilter.find(common.imagefilter)); |
| 498 paint->setAnnotation (fAnnotation .find(common.annotation)); | 497 paint->setAnnotation (fAnnotation .find(common.annotation)); |
| 499 } | 498 } |
| 500 | 499 |
| 501 void save() override { fCanvas->save(); } | 500 void save() override { fCanvas->save(); } |
| 502 void restore() override { fCanvas->restore(); } | 501 void restore() override { fCanvas->restore(); } |
| 503 void saveLayer(ID bounds, CommonIDs common, SkCanvas::SaveFlags flags) o
verride { | 502 void saveLayer(ID bounds, CommonIDs common, SkCanvas::SaveLayerFlags fla
gs) override { |
| 504 SkPaint paint; | 503 SkPaint paint; |
| 505 this->applyCommon(common, &paint); | 504 this->applyCommon(common, &paint); |
| 506 SkRect rect; | 505 SkRect rect; |
| 507 fCanvas->saveLayer(fPath.find(bounds).isRect(&rect) ? &rect : nullpt
r, &paint, flags); | 506 |
| 507 fCanvas->saveLayer({ fPath.find(bounds).isRect(&rect) ? &rect : null
ptr, |
| 508 &paint, flags }); |
| 508 } | 509 } |
| 509 | 510 |
| 510 void setMatrix(ID matrix) override { fCanvas->setMatrix(fMatrix.find(mat
rix)); } | 511 void setMatrix(ID matrix) override { fCanvas->setMatrix(fMatrix.find(mat
rix)); } |
| 511 | 512 |
| 512 void clipPath(ID path, SkRegion::Op op, bool aa) override { | 513 void clipPath(ID path, SkRegion::Op op, bool aa) override { |
| 513 fCanvas->clipPath(fPath.find(path), op, aa); | 514 fCanvas->clipPath(fPath.find(path), op, aa); |
| 514 } | 515 } |
| 515 void fillPath(ID path, CommonIDs common) override { | 516 void fillPath(ID path, CommonIDs common) override { |
| 516 SkPaint paint; | 517 SkPaint paint; |
| 517 paint.setStyle(SkPaint::kFill_Style); | 518 paint.setStyle(SkPaint::kFill_Style); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 ID define(SkColorFilter* v) override { return this->define(&fColorFil
ter, v); } | 678 ID define(SkColorFilter* v) override { return this->define(&fColorFil
ter, v); } |
| 678 ID define(SkRasterizer* v) override { return this->define(&fRasteriz
er , v); } | 679 ID define(SkRasterizer* v) override { return this->define(&fRasteriz
er , v); } |
| 679 ID define(SkDrawLooper* v) override { return this->define(&fDrawLoop
er , v); } | 680 ID define(SkDrawLooper* v) override { return this->define(&fDrawLoop
er , v); } |
| 680 ID define(SkImageFilter* v) override { return this->define(&fImageFil
ter, v); } | 681 ID define(SkImageFilter* v) override { return this->define(&fImageFil
ter, v); } |
| 681 ID define(SkAnnotation* v) override { return this->define(&fAnnotati
on , v); } | 682 ID define(SkAnnotation* v) override { return this->define(&fAnnotati
on , v); } |
| 682 | 683 |
| 683 void undefine(ID) override {} | 684 void undefine(ID) override {} |
| 684 | 685 |
| 685 void save() override { fWrapped-> save(); } | 686 void save() override { fWrapped-> save(); } |
| 686 void restore() override { fWrapped->restore(); } | 687 void restore() override { fWrapped->restore(); } |
| 687 void saveLayer(ID bounds, CommonIDs common, SkCanvas::SaveFlags flags) o
verride { | 688 void saveLayer(ID bounds, CommonIDs common, SkCanvas::SaveLayerFlags fla
gs) override { |
| 688 fWrapped->saveLayer(bounds, common, flags); | 689 fWrapped->saveLayer(bounds, common, flags); |
| 689 } | 690 } |
| 690 | 691 |
| 691 void setMatrix(ID matrix) override { fWrapped->setMatrix(matrix); } | 692 void setMatrix(ID matrix) override { fWrapped->setMatrix(matrix); } |
| 692 | 693 |
| 693 void clipPath(ID path, SkRegion::Op op, bool aa) override { | 694 void clipPath(ID path, SkRegion::Op op, bool aa) override { |
| 694 fWrapped->clipPath(path, op, aa); | 695 fWrapped->clipPath(path, op, aa); |
| 695 } | 696 } |
| 696 void fillPath(ID path, CommonIDs common) override { | 697 void fillPath(ID path, CommonIDs common) override { |
| 697 fWrapped->fillPath(path, common); | 698 fWrapped->fillPath(path, common); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 RefKeyMap<SkDrawLooper , Type::kDrawLooper > fDrawLooper; | 750 RefKeyMap<SkDrawLooper , Type::kDrawLooper > fDrawLooper; |
| 750 RefKeyMap<SkImageFilter , Type::kImageFilter> fImageFilter; | 751 RefKeyMap<SkImageFilter , Type::kImageFilter> fImageFilter; |
| 751 RefKeyMap<SkAnnotation , Type::kAnnotation > fAnnotation; | 752 RefKeyMap<SkAnnotation , Type::kAnnotation > fAnnotation; |
| 752 | 753 |
| 753 Encoder* fWrapped; | 754 Encoder* fWrapped; |
| 754 }; | 755 }; |
| 755 | 756 |
| 756 Encoder* NewCachingEncoder(Encoder* wrapped) { return new CachingEncoder(wra
pped); } | 757 Encoder* NewCachingEncoder(Encoder* wrapped) { return new CachingEncoder(wra
pped); } |
| 757 | 758 |
| 758 } // namespace SkRemote | 759 } // namespace SkRemote |
| OLD | NEW |