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

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

Issue 2315283002: SkLiteDL: drawAsLayer() (Closed)
Patch Set: Created 4 years, 3 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 unified diff | Download patch
« src/core/SkLiteDL.h ('K') | « src/core/SkLiteDL.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 2016 Google Inc. 2 * Copyright 2016 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkColorFilter.h"
9 #include "SkData.h" 10 #include "SkData.h"
10 #include "SkDrawFilter.h" 11 #include "SkDrawFilter.h"
11 #include "SkImageFilter.h" 12 #include "SkImageFilter.h"
12 #include "SkLiteDL.h" 13 #include "SkLiteDL.h"
13 #include "SkMath.h" 14 #include "SkMath.h"
14 #include "SkPicture.h" 15 #include "SkPicture.h"
15 #include "SkRSXform.h" 16 #include "SkRSXform.h"
16 #include "SkTextBlob.h" 17 #include "SkTextBlob.h"
18 #include "SkXfermode.h"
17 19
18 #ifndef SKLITEDL_PAGE 20 #ifndef SKLITEDL_PAGE
19 #define SKLITEDL_PAGE 4096 21 #define SKLITEDL_PAGE 4096
20 #endif 22 #endif
21 23
22 // A stand-in for an optional SkRect which was not set, e.g. bounds for a saveLa yer(). 24 // A stand-in for an optional SkRect which was not set, e.g. bounds for a saveLa yer().
23 static const SkRect kUnset = { SK_ScalarInfinity, 0,0,0}; 25 static const SkRect kUnset = { SK_ScalarInfinity, 0,0,0};
24 static const SkRect* maybe_unset(const SkRect& r) { 26 static const SkRect* maybe_unset(const SkRect& r) {
25 return r.left() == SK_ScalarInfinity ? nullptr : &r; 27 return r.left() == SK_ScalarInfinity ? nullptr : &r;
26 } 28 }
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 } 811 }
810 812
811 void SkLiteDL::reset(SkRect bounds) { 813 void SkLiteDL::reset(SkRect bounds) {
812 SkASSERT(this->unique()); 814 SkASSERT(this->unique());
813 this->map(dtor_fns); 815 this->map(dtor_fns);
814 816
815 // Leave fBytes and fReserved alone. 817 // Leave fBytes and fReserved alone.
816 fUsed = 0; 818 fUsed = 0;
817 fBounds = bounds; 819 fBounds = bounds;
818 } 820 }
821
822 void SkLiteDL::drawAsLayer(SkCanvas* c, const SkMatrix* matrix
823 , SkColorFilter* cf
824 , SkXfermode* xfer
825 , U8CPU alpha) {
826 auto fallback_plan = [&] {
reed1 2016/09/07 15:29:55 cool way to construct this.
827 SkPaint p;
828 p.setColorFilter(sk_ref_sp(cf));
829 p.setXfermode(sk_ref_sp(xfer));
830 p.setAlpha(alpha);
831 SkRect bounds = this->getBounds();
832 c->saveLayer(&bounds, &p);
833 this->draw(c, matrix);
834 c->restore();
835 };
836
837 // TODO: single-draw specializations
838
839 return fallback_plan();
840 }
OLDNEW
« src/core/SkLiteDL.h ('K') | « src/core/SkLiteDL.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698