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

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

Issue 2041113004: sk_sp for gpu. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Reserve correctly. Created 4 years, 6 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
« no previous file with comments | « src/core/SkBitmapProcShader.cpp ('k') | src/core/SkColorFilterShader.h » ('j') | 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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkColorFilter.h" 8 #include "SkColorFilter.h"
9 #include "SkReadBuffer.h" 9 #include "SkReadBuffer.h"
10 #include "SkRefCnt.h" 10 #include "SkRefCnt.h"
(...skipping 13 matching lines...) Expand all
24 } 24 }
25 25
26 bool SkColorFilter::asColorMatrix(SkScalar matrix[20]) const { 26 bool SkColorFilter::asColorMatrix(SkScalar matrix[20]) const {
27 return false; 27 return false;
28 } 28 }
29 29
30 bool SkColorFilter::asComponentTable(SkBitmap*) const { 30 bool SkColorFilter::asComponentTable(SkBitmap*) const {
31 return false; 31 return false;
32 } 32 }
33 33
34 #if SK_SUPPORT_GPU
35 sk_sp<GrFragmentProcessor> SkColorFilter::asFragmentProcessor(GrContext*) const {
36 return nullptr;
37 }
38 #endif
39
34 void SkColorFilter::filterSpan4f(const SkPM4f[], int count, SkPM4f span[]) const { 40 void SkColorFilter::filterSpan4f(const SkPM4f[], int count, SkPM4f span[]) const {
35 const int N = 128; 41 const int N = 128;
36 SkPMColor tmp[N]; 42 SkPMColor tmp[N];
37 while (count > 0) { 43 while (count > 0) {
38 int n = SkTMin(count, N); 44 int n = SkTMin(count, N);
39 for (int i = 0; i < n; ++i) { 45 for (int i = 0; i < n; ++i) {
40 SkNx_cast<uint8_t>(Sk4f::Load(span[i].fVec) * Sk4f(255) + Sk4f(0.5f) ).store(&tmp[i]); 46 SkNx_cast<uint8_t>(Sk4f::Load(span[i].fVec) * Sk4f(255) + Sk4f(0.5f) ).store(&tmp[i]);
41 } 47 }
42 this->filterSpan(tmp, n, tmp); 48 this->filterSpan(tmp, n, tmp);
43 for (int i = 0; i < n; ++i) { 49 for (int i = 0; i < n; ++i) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 #ifndef SK_IGNORE_TO_STRING 98 #ifndef SK_IGNORE_TO_STRING
93 void toString(SkString* str) const override { 99 void toString(SkString* str) const override {
94 SkString outerS, innerS; 100 SkString outerS, innerS;
95 fOuter->toString(&outerS); 101 fOuter->toString(&outerS);
96 fInner->toString(&innerS); 102 fInner->toString(&innerS);
97 str->appendf("SkComposeColorFilter: outer(%s) inner(%s)", outerS.c_str() , innerS.c_str()); 103 str->appendf("SkComposeColorFilter: outer(%s) inner(%s)", outerS.c_str() , innerS.c_str());
98 } 104 }
99 #endif 105 #endif
100 106
101 #if SK_SUPPORT_GPU 107 #if SK_SUPPORT_GPU
102 const GrFragmentProcessor* asFragmentProcessor(GrContext* context) const ove rride { 108 sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext* context) const ove rride {
103 SkAutoTUnref<const GrFragmentProcessor> innerFP(fInner->asFragmentProces sor(context)); 109 sk_sp<GrFragmentProcessor> innerFP(fInner->asFragmentProcessor(context)) ;
104 SkAutoTUnref<const GrFragmentProcessor> outerFP(fOuter->asFragmentProces sor(context)); 110 sk_sp<GrFragmentProcessor> outerFP(fOuter->asFragmentProcessor(context)) ;
105 if (!innerFP || !outerFP) { 111 if (!innerFP || !outerFP) {
106 return nullptr; 112 return nullptr;
107 } 113 }
108 const GrFragmentProcessor* series[] = { innerFP, outerFP }; 114 sk_sp<GrFragmentProcessor> series[] = { std::move(innerFP), std::move(ou terFP) };
109 return GrFragmentProcessor::RunInSeries(series, 2); 115 return GrFragmentProcessor::RunInSeries(series, 2);
110 } 116 }
111 #endif 117 #endif
112 118
113 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeColorFilter) 119 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeColorFilter)
114 120
115 protected: 121 protected:
116 void flatten(SkWriteBuffer& buffer) const override { 122 void flatten(SkWriteBuffer& buffer) const override {
117 buffer.writeFlattenable(fOuter.get()); 123 buffer.writeFlattenable(fOuter.get());
118 buffer.writeFlattenable(fInner.get()); 124 buffer.writeFlattenable(fInner.get());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 177 }
172 return sk_sp<SkColorFilter>(new SkComposeColorFilter(std::move(outer), std:: move(inner),count)); 178 return sk_sp<SkColorFilter>(new SkComposeColorFilter(std::move(outer), std:: move(inner),count));
173 } 179 }
174 180
175 #include "SkModeColorFilter.h" 181 #include "SkModeColorFilter.h"
176 182
177 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkColorFilter) 183 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkColorFilter)
178 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposeColorFilter) 184 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposeColorFilter)
179 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkModeColorFilter) 185 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkModeColorFilter)
180 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 186 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcShader.cpp ('k') | src/core/SkColorFilterShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698