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

Side by Side Diff: src/core/SkRemote.cpp

Issue 1432593002: SkRemote: saveLayer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « src/core/SkRemote.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 template <typename T> 158 template <typename T>
159 AutoID id(const T& val) { return AutoID(fEncoder, val); } 159 AutoID id(const T& val) { return AutoID(fEncoder, val); }
160 160
161 AutoCommonIDs commonIDs(const SkPaint& paint) { return AutoCommonIDs(fEn coder, paint); } 161 AutoCommonIDs commonIDs(const SkPaint& paint) { return AutoCommonIDs(fEn coder, paint); }
162 162
163 void willSave() override { fEncoder-> save(); } 163 void willSave() override { fEncoder-> save(); }
164 void didRestore() override { fEncoder->restore(); } 164 void didRestore() override { fEncoder->restore(); }
165 SaveLayerStrategy willSaveLayer(const SkRect* bounds, 165 SaveLayerStrategy willSaveLayer(const SkRect* bounds,
166 const SkPaint* paint, 166 const SkPaint* paint,
167 SaveFlags flags) override { 167 SaveFlags flags) override {
168 // TODO 168 SkPath path;
169 if (bounds) {
170 path.addRect(*bounds);
171 }
172 const SkPaint defaultPaint;
173 if (!paint) {
174 paint = &defaultPaint;
175 }
176 fEncoder->saveLayer(this->id(path), this->commonIDs(*paint), flags);
169 return kNoLayer_SaveLayerStrategy; 177 return kNoLayer_SaveLayerStrategy;
170 } 178 }
171 179
172 void didConcat(const SkMatrix&) override { this->didSetMatrix(this->g etTotalMatrix()); } 180 void didConcat(const SkMatrix&) override { this->didSetMatrix(this->g etTotalMatrix()); }
173 void didSetMatrix(const SkMatrix& matrix) override { 181 void didSetMatrix(const SkMatrix& matrix) override {
174 fEncoder->setMatrix(this->id(matrix)); 182 fEncoder->setMatrix(this->id(matrix));
175 } 183 }
176 184
177 void onDrawOval(const SkRect& oval, const SkPaint& paint) override { 185 void onDrawOval(const SkRect& oval, const SkPaint& paint) override {
178 SkPath path; 186 SkPath path;
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 paint->setMaskFilter (fMaskFilter .find(common.maskfilter)); 474 paint->setMaskFilter (fMaskFilter .find(common.maskfilter));
467 paint->setColorFilter(fColorFilter.find(common.colorfilter)); 475 paint->setColorFilter(fColorFilter.find(common.colorfilter));
468 paint->setRasterizer (fRasterizer .find(common.rasterizer)); 476 paint->setRasterizer (fRasterizer .find(common.rasterizer));
469 paint->setLooper (fDrawLooper .find(common.looper)); 477 paint->setLooper (fDrawLooper .find(common.looper));
470 paint->setImageFilter(fImageFilter.find(common.imagefilter)); 478 paint->setImageFilter(fImageFilter.find(common.imagefilter));
471 paint->setAnnotation (fAnnotation .find(common.annotation)); 479 paint->setAnnotation (fAnnotation .find(common.annotation));
472 } 480 }
473 481
474 void save() override { fCanvas->save(); } 482 void save() override { fCanvas->save(); }
475 void restore() override { fCanvas->restore(); } 483 void restore() override { fCanvas->restore(); }
484 void saveLayer(ID bounds, CommonIDs common, SkCanvas::SaveFlags flags) o verride {
485 SkPaint paint;
486 this->applyCommon(common, &paint);
487 SkRect rect;
488 fCanvas->saveLayer(fPath.find(bounds).isRect(&rect) ? &rect : nullpt r, &paint, flags);
489 }
476 490
477 void setMatrix(ID matrix) override { fCanvas->setMatrix(fMatrix.find(mat rix)); } 491 void setMatrix(ID matrix) override { fCanvas->setMatrix(fMatrix.find(mat rix)); }
478 492
479 void clipPath(ID path, SkRegion::Op op, bool aa) override { 493 void clipPath(ID path, SkRegion::Op op, bool aa) override {
480 fCanvas->clipPath(fPath.find(path), op, aa); 494 fCanvas->clipPath(fPath.find(path), op, aa);
481 } 495 }
482 void fillPath(ID path, CommonIDs common) override { 496 void fillPath(ID path, CommonIDs common) override {
483 SkPaint paint; 497 SkPaint paint;
484 paint.setStyle(SkPaint::kFill_Style); 498 paint.setStyle(SkPaint::kFill_Style);
485 this->applyCommon(common, &paint); 499 this->applyCommon(common, &paint);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 ID define(SkColorFilter* v) override { return this->define(&fColorFilte r, v); } 643 ID define(SkColorFilter* v) override { return this->define(&fColorFilte r, v); }
630 ID define(SkRasterizer* v) override { return this->define(&fRasterizer , v); } 644 ID define(SkRasterizer* v) override { return this->define(&fRasterizer , v); }
631 ID define(SkDrawLooper* v) override { return this->define(&fDrawLooper , v); } 645 ID define(SkDrawLooper* v) override { return this->define(&fDrawLooper , v); }
632 ID define(SkImageFilter* v) override { return this->define(&fImageFilte r, v); } 646 ID define(SkImageFilter* v) override { return this->define(&fImageFilte r, v); }
633 ID define(SkAnnotation* v) override { return this->define(&fAnnotation , v); } 647 ID define(SkAnnotation* v) override { return this->define(&fAnnotation , v); }
634 648
635 void undefine(ID) override {} 649 void undefine(ID) override {}
636 650
637 void save() override { fWrapped-> save(); } 651 void save() override { fWrapped-> save(); }
638 void restore() override { fWrapped->restore(); } 652 void restore() override { fWrapped->restore(); }
653 void saveLayer(ID bounds, CommonIDs common, SkCanvas::SaveFlags flags) o verride {
654 fWrapped->saveLayer(bounds, common, flags);
655 }
639 656
640 void setMatrix(ID matrix) override { fWrapped->setMatrix(matrix); } 657 void setMatrix(ID matrix) override { fWrapped->setMatrix(matrix); }
641 658
642 void clipPath(ID path, SkRegion::Op op, bool aa) override { 659 void clipPath(ID path, SkRegion::Op op, bool aa) override {
643 fWrapped->clipPath(path, op, aa); 660 fWrapped->clipPath(path, op, aa);
644 } 661 }
645 void fillPath(ID path, CommonIDs common) override { 662 void fillPath(ID path, CommonIDs common) override {
646 fWrapped->fillPath(path, common); 663 fWrapped->fillPath(path, common);
647 } 664 }
648 void strokePath(ID path, CommonIDs common, ID stroke) override { 665 void strokePath(ID path, CommonIDs common, ID stroke) override {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 RefKeyMap<SkDrawLooper , Type::kDrawLooper > fDrawLooper; 708 RefKeyMap<SkDrawLooper , Type::kDrawLooper > fDrawLooper;
692 RefKeyMap<SkImageFilter, Type::kImageFilter> fImageFilter; 709 RefKeyMap<SkImageFilter, Type::kImageFilter> fImageFilter;
693 RefKeyMap<SkAnnotation , Type::kAnnotation > fAnnotation; 710 RefKeyMap<SkAnnotation , Type::kAnnotation > fAnnotation;
694 711
695 Encoder* fWrapped; 712 Encoder* fWrapped;
696 }; 713 };
697 714
698 Encoder* NewCachingEncoder(Encoder* wrapped) { return new CachingEncoder(wra pped); } 715 Encoder* NewCachingEncoder(Encoder* wrapped) { return new CachingEncoder(wra pped); }
699 716
700 } // namespace SkRemote 717 } // namespace SkRemote
OLDNEW
« no previous file with comments | « src/core/SkRemote.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698