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

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

Issue 2301173004: added radial lights to SkLights (Closed)
Patch Set: made req comment fix 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
« no previous file with comments | « include/core/SkLights.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 /* 2 /*
3 * Copyright 2016 Google Inc. 3 * Copyright 2016 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkLights.h" 9 #include "SkLights.h"
10 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
(...skipping 24 matching lines...) Expand all
35 } 35 }
36 36
37 sk_sp<SkImage> depthMap; 37 sk_sp<SkImage> depthMap;
38 bool hasShadowMap = buf.readBool(); 38 bool hasShadowMap = buf.readBool();
39 if (hasShadowMap) { 39 if (hasShadowMap) {
40 if (!(depthMap = buf.readImage())) { 40 if (!(depthMap = buf.readImage())) {
41 return nullptr; 41 return nullptr;
42 } 42 }
43 } 43 }
44 44
45 bool isRadial = buf.readBool();
45 if (isPoint) { 46 if (isPoint) {
46 SkScalar intensity = 0.0f; 47 SkScalar intensity;
47 intensity = buf.readScalar(); 48 intensity = buf.readScalar();
48 Light light = Light::MakePoint(color, dirOrPos, intensity); 49 Light light = Light::MakePoint(color, dirOrPos, intensity, isRadial) ;
49 light.setShadowMap(depthMap); 50 light.setShadowMap(depthMap);
50 builder.add(light); 51 builder.add(light);
51 } else { 52 } else {
52 Light light = Light::MakeDirectional(color, dirOrPos); 53 Light light = Light::MakeDirectional(color, dirOrPos, isRadial);
53 light.setShadowMap(depthMap); 54 light.setShadowMap(depthMap);
54 builder.add(light); 55 builder.add(light);
55 } 56 }
56 } 57 }
57 58
58 return builder.finish(); 59 return builder.finish();
59 } 60 }
60 61
61 void SkLights::flatten(SkWriteBuffer& buf) const { 62 void SkLights::flatten(SkWriteBuffer& buf) const {
62 buf.writeScalarArray(&this->ambientLightColor().fX, 3); 63 buf.writeScalarArray(&this->ambientLightColor().fX, 3);
63 64
64 buf.writeInt(this->numLights()); 65 buf.writeInt(this->numLights());
65 for (int l = 0; l < this->numLights(); ++l) { 66 for (int l = 0; l < this->numLights(); ++l) {
66 const Light& light = this->light(l); 67 const Light& light = this->light(l);
67 68
68 bool isPoint = Light::kPoint_LightType == light.type(); 69 bool isPoint = Light::kPoint_LightType == light.type();
69 70
70 buf.writeBool(isPoint); 71 buf.writeBool(isPoint);
71 buf.writeScalarArray(&light.color().fX, 3); 72 buf.writeScalarArray(&light.color().fX, 3);
72 buf.writeScalarArray(&light.dir().fX, 3); 73 buf.writeScalarArray(&light.dir().fX, 3);
74
73 bool hasShadowMap = light.getShadowMap() != nullptr; 75 bool hasShadowMap = light.getShadowMap() != nullptr;
74 buf.writeBool(hasShadowMap); 76 buf.writeBool(hasShadowMap);
77
78 bool isRadial = light.isRadial();
79 buf.writeBool(isRadial);
80
75 if (hasShadowMap) { 81 if (hasShadowMap) {
76 buf.writeImage(light.getShadowMap()); 82 buf.writeImage(light.getShadowMap());
77 } 83 }
78 if (isPoint) { 84 if (isPoint) {
79 buf.writeScalar(light.intensity()); 85 buf.writeScalar(light.intensity());
80 } 86 }
81 } 87 }
82 } 88 }
OLDNEW
« no previous file with comments | « include/core/SkLights.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698