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

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

Issue 2175563003: Bundle SkShader::asFragmentProcessor arguments in a struct (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix indentation to be less arbitrary Created 4 years, 5 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/SkNormalSource.h ('k') | src/core/SkPictureShader.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 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 "SkError.h" 8 #include "SkError.h"
9 #include "SkErrorInternals.h" 9 #include "SkErrorInternals.h"
10 #include "SkLightingShader.h" 10 #include "SkLightingShader.h"
11 #include "SkMatrix.h" 11 #include "SkMatrix.h"
12 #include "SkNormalSource.h" 12 #include "SkNormalSource.h"
13 #include "SkPM4f.h" 13 #include "SkPM4f.h"
14 #include "SkReadBuffer.h" 14 #include "SkReadBuffer.h"
15 #include "SkWriteBuffer.h" 15 #include "SkWriteBuffer.h"
16 16
17 // Genretating vtable 17 // Genretating vtable
18 SkNormalSource::~SkNormalSource() {} 18 SkNormalSource::~SkNormalSource() {}
19 19
20 /////////////////////////////////////////////////////////////////////////////// 20 ///////////////////////////////////////////////////////////////////////////////
21 21
22 class NormalMapSourceImpl : public SkNormalSource { 22 class NormalMapSourceImpl : public SkNormalSource {
23 public: 23 public:
24 NormalMapSourceImpl(sk_sp<SkShader> mapShader, const SkMatrix& invCTM) 24 NormalMapSourceImpl(sk_sp<SkShader> mapShader, const SkMatrix& invCTM)
25 : fMapShader(std::move(mapShader)) 25 : fMapShader(std::move(mapShader))
26 , fInvCTM(invCTM) {} 26 , fInvCTM(invCTM) {}
27 27
28 #if SK_SUPPORT_GPU 28 #if SK_SUPPORT_GPU
29 sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*, 29 sk_sp<GrFragmentProcessor> asFragmentProcessor(const SkShader::AsFPArgs&) co nst override;
30 const SkMatrix& viewM,
31 const SkMatrix* localMatrix,
32 SkFilterQuality,
33 SkSourceGammaTreatment) const override;
34 #endif 30 #endif
35 31
36 SkNormalSource::Provider* asProvider(const SkShader::ContextRec& rec, 32 SkNormalSource::Provider* asProvider(const SkShader::ContextRec& rec,
37 void* storage) const ov erride; 33 void* storage) const ov erride;
38 34
39 size_t providerSize(const SkShader::ContextRec& rec) const override; 35 size_t providerSize(const SkShader::ContextRec& rec) const override;
40 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(NormalMapSourceImpl) 36 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(NormalMapSourceImpl)
41 37
42 protected: 38 protected:
43 void flatten(SkWriteBuffer& buf) const override; 39 void flatten(SkWriteBuffer& buf) const override;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 167
172 bool onIsEqual(const GrFragmentProcessor& proc) const override { 168 bool onIsEqual(const GrFragmentProcessor& proc) const override {
173 const NormalMapFP& normalMapFP = proc.cast<NormalMapFP>(); 169 const NormalMapFP& normalMapFP = proc.cast<NormalMapFP>();
174 return fInvCTM == normalMapFP.fInvCTM; 170 return fInvCTM == normalMapFP.fInvCTM;
175 } 171 }
176 172
177 SkMatrix fInvCTM; 173 SkMatrix fInvCTM;
178 }; 174 };
179 175
180 sk_sp<GrFragmentProcessor> NormalMapSourceImpl::asFragmentProcessor( 176 sk_sp<GrFragmentProcessor> NormalMapSourceImpl::asFragmentProcessor(
181 GrContext *context, 177 const SkShader::AsFPArgs& args) const {
182 const SkMatrix &viewM, 178 sk_sp<GrFragmentProcessor> mapFP = fMapShader->asFragmentProcessor(args);
183 const SkMatrix *localMatrix ,
184 SkFilterQuality filterQuali ty,
185 SkSourceGammaTreatment gamm aTreatment) const {
186 sk_sp<GrFragmentProcessor> mapFP = fMapShader->asFragmentProcessor(context, viewM,
187 localMatrix, filterQuality, gammaTreatment);
188 if (!mapFP) { 179 if (!mapFP) {
189 return nullptr; 180 return nullptr;
190 } 181 }
191 182
192 return sk_make_sp<NormalMapFP>(std::move(mapFP), fInvCTM); 183 return sk_make_sp<NormalMapFP>(std::move(mapFP), fInvCTM);
193 } 184 }
194 185
195 #endif // SK_SUPPORT_GPU 186 #endif // SK_SUPPORT_GPU
196 187
197 //////////////////////////////////////////////////////////////////////////// 188 ////////////////////////////////////////////////////////////////////////////
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 return sk_make_sp<NormalMapSourceImpl>(std::move(map), invCTM); 320 return sk_make_sp<NormalMapSourceImpl>(std::move(map), invCTM);
330 } 321 }
331 322
332 /////////////////////////////////////////////////////////////////////////////// 323 ///////////////////////////////////////////////////////////////////////////////
333 324
334 class SK_API NormalFlatSourceImpl : public SkNormalSource { 325 class SK_API NormalFlatSourceImpl : public SkNormalSource {
335 public: 326 public:
336 NormalFlatSourceImpl(){} 327 NormalFlatSourceImpl(){}
337 328
338 #if SK_SUPPORT_GPU 329 #if SK_SUPPORT_GPU
339 sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*, 330 sk_sp<GrFragmentProcessor> asFragmentProcessor(const SkShader::AsFPArgs&) co nst override;
340 const SkMatrix& viewM,
341 const SkMatrix* localMatrix,
342 SkFilterQuality,
343 SkSourceGammaTreatment) const override;
344 #endif 331 #endif
345 332
346 SkNormalSource::Provider* asProvider(const SkShader::ContextRec& rec, 333 SkNormalSource::Provider* asProvider(const SkShader::ContextRec& rec,
347 void* storage) const override; 334 void* storage) const override;
348 size_t providerSize(const SkShader::ContextRec& rec) const override; 335 size_t providerSize(const SkShader::ContextRec& rec) const override;
349 336
350 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(NormalFlatSourceImpl) 337 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(NormalFlatSourceImpl)
351 338
352 protected: 339 protected:
353 void flatten(SkWriteBuffer& buf) const override; 340 void flatten(SkWriteBuffer& buf) const override;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 398
412 private: 399 private:
413 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override { return new GLSLNormalFlatFP; } 400 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override { return new GLSLNormalFlatFP; }
414 401
415 bool onIsEqual(const GrFragmentProcessor& proc) const override { 402 bool onIsEqual(const GrFragmentProcessor& proc) const override {
416 return true; 403 return true;
417 } 404 }
418 }; 405 };
419 406
420 sk_sp<GrFragmentProcessor> NormalFlatSourceImpl::asFragmentProcessor( 407 sk_sp<GrFragmentProcessor> NormalFlatSourceImpl::asFragmentProcessor(
421 GrContext *context, 408 const SkShader::AsFPArgs&) const {
422 const SkMatrix &viewM,
423 const SkMatrix *localMatrix ,
424 SkFilterQuality filterQuali ty,
425 SkSourceGammaTreatment gamm aTreatment) const {
426 409
427 return sk_make_sp<NormalFlatFP>(); 410 return sk_make_sp<NormalFlatFP>();
428 } 411 }
429 412
430 #endif // SK_SUPPORT_GPU 413 #endif // SK_SUPPORT_GPU
431 414
432 //////////////////////////////////////////////////////////////////////////// 415 ////////////////////////////////////////////////////////////////////////////
433 416
434 NormalFlatSourceImpl::Provider::Provider() {} 417 NormalFlatSourceImpl::Provider::Provider() {}
435 418
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 //////////////////////////////////////////////////////////////////////////// 453 ////////////////////////////////////////////////////////////////////////////
471 454
472 //////////////////////////////////////////////////////////////////////////// 455 ////////////////////////////////////////////////////////////////////////////
473 456
474 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkNormalSource) 457 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkNormalSource)
475 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(NormalMapSourceImpl) 458 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(NormalMapSourceImpl)
476 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(NormalFlatSourceImpl) 459 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(NormalFlatSourceImpl)
477 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 460 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
478 461
479 //////////////////////////////////////////////////////////////////////////// 462 ////////////////////////////////////////////////////////////////////////////
OLDNEW
« no previous file with comments | « src/core/SkNormalSource.h ('k') | src/core/SkPictureShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698