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

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

Issue 2032263004: Add ability to rotate light direction in drawLitAtlas Sample slide (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | « samplecode/SampleLitAtlas.cpp ('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 "SkBitmapProcState.h" 8 #include "SkBitmapProcState.h"
9 #include "SkColor.h" 9 #include "SkColor.h"
10 #include "SkEmptyShader.h" 10 #include "SkEmptyShader.h"
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 503
504 for (int i = 0; i < n; ++i) { 504 for (int i = 0; i < n; ++i) {
505 SkASSERT(0xFF == SkColorGetA(tmpNormal2[i])); // opaque -> unpremul 505 SkASSERT(0xFF == SkColorGetA(tmpNormal2[i])); // opaque -> unpremul
506 norm.set(SkIntToScalar(SkGetPackedR32(tmpNormal2[i]))-127.0f, 506 norm.set(SkIntToScalar(SkGetPackedR32(tmpNormal2[i]))-127.0f,
507 SkIntToScalar(SkGetPackedG32(tmpNormal2[i]))-127.0f, 507 SkIntToScalar(SkGetPackedG32(tmpNormal2[i]))-127.0f,
508 SkIntToScalar(SkGetPackedB32(tmpNormal2[i]))-127.0f); 508 SkIntToScalar(SkGetPackedB32(tmpNormal2[i]))-127.0f);
509 norm.normalize(); 509 norm.normalize();
510 510
511 xformedNorm.fX = lightShader.fInvNormRotation.fX * norm.fX + 511 xformedNorm.fX = lightShader.fInvNormRotation.fX * norm.fX +
512 lightShader.fInvNormRotation.fY * norm.fY; 512 lightShader.fInvNormRotation.fY * norm.fY;
513 xformedNorm.fY = lightShader.fInvNormRotation.fX * norm.fX - 513 xformedNorm.fY = -lightShader.fInvNormRotation.fY * norm.fX +
514 lightShader.fInvNormRotation.fY * norm.fY; 514 lightShader.fInvNormRotation.fX * norm.fY;
515 xformedNorm.fZ = norm.fZ; 515 xformedNorm.fZ = norm.fZ;
516 516
517 SkColor diffColor = SkUnPreMultiply::PMColorToColor(tmpColor2[i]); 517 SkColor diffColor = SkUnPreMultiply::PMColorToColor(tmpColor2[i]);
518 518
519 SkColor3f accum = SkColor3f::Make(0.0f, 0.0f, 0.0f); 519 SkColor3f accum = SkColor3f::Make(0.0f, 0.0f, 0.0f);
520 // This is all done in linear unpremul color space (each component 0 ..255.0f though) 520 // This is all done in linear unpremul color space (each component 0 ..255.0f though)
521 for (int l = 0; l < lightShader.fLights->numLights(); ++l) { 521 for (int l = 0; l < lightShader.fLights->numLights(); ++l) {
522 const SkLights::Light& light = lightShader.fLights->light(l); 522 const SkLights::Light& light = lightShader.fLights->light(l);
523 523
524 if (SkLights::Light::kAmbient_LightType == light.type()) { 524 if (SkLights::Light::kAmbient_LightType == light.type()) {
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 invNormRotation, diffLocalM, normLoc alM); 722 invNormRotation, diffLocalM, normLoc alM);
723 } 723 }
724 724
725 /////////////////////////////////////////////////////////////////////////////// 725 ///////////////////////////////////////////////////////////////////////////////
726 726
727 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) 727 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader)
728 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) 728 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl)
729 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 729 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
730 730
731 /////////////////////////////////////////////////////////////////////////////// 731 ///////////////////////////////////////////////////////////////////////////////
OLDNEW
« no previous file with comments | « samplecode/SampleLitAtlas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698