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

Side by Side Diff: samplecode/SampleLighting.cpp

Issue 1229693009: Add new SkPoint3 class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: More Chromium staging Created 5 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 | « samplecode/SampleFilterFuzz.cpp ('k') | src/effects/SkLightingImageFilter.cpp » ('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 /* 2 /*
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 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 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "Resources.h" 9 #include "Resources.h"
10 10
11 #include "SkCanvas.h" 11 #include "SkCanvas.h"
12 #include "SkErrorInternals.h" 12 #include "SkErrorInternals.h"
13 #include "SkGr.h" 13 #include "SkGr.h"
14 #include "SkPoint3.h"
14 #include "SkReadBuffer.h" 15 #include "SkReadBuffer.h"
15 #include "SkShader.h" 16 #include "SkShader.h"
16 #include "SkWriteBuffer.h" 17 #include "SkWriteBuffer.h"
17 #include "GrFragmentProcessor.h" 18 #include "GrFragmentProcessor.h"
18 #include "GrCoordTransform.h" 19 #include "GrCoordTransform.h"
19 #include "gl/GrGLProcessor.h" 20 #include "gl/GrGLProcessor.h"
20 #include "gl/builders/GrGLProgramBuilder.h" 21 #include "gl/builders/GrGLProgramBuilder.h"
21 22
22 /////////////////////////////////////////////////////////////////////////////// 23 ///////////////////////////////////////////////////////////////////////////////
23 24
24 struct SkVector3 {
25 SkScalar fX, fY, fZ;
26
27 bool operator==(const SkVector3& other) const {
28 return fX == other.fX && fY == other.fY && fZ == other.fZ;
29 }
30
31 bool operator!=(const SkVector3& other) const {
32 return !(*this == other);
33 }
34 };
35
36 class LightingShader : public SkShader { 25 class LightingShader : public SkShader {
37 public: 26 public:
38 struct Light { 27 struct Light {
39 SkVector3 fDirection; 28 SkVector3 fDirection;
40 SkColor fColor; // assumed to be linear color 29 SkColor fColor; // assumed to be linear color
41 }; 30 };
42 31
43 LightingShader(const SkBitmap& diffuse, const SkBitmap& normal, const Light& light, 32 LightingShader(const SkBitmap& diffuse, const SkBitmap& normal, const Light& light,
44 const SkColor ambient) 33 const SkColor ambient)
45 : fDiffuseMap(diffuse) 34 : fDiffuseMap(diffuse)
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 } 409 }
421 410
422 private: 411 private:
423 typedef SampleView INHERITED; 412 typedef SampleView INHERITED;
424 }; 413 };
425 414
426 ////////////////////////////////////////////////////////////////////////////// 415 //////////////////////////////////////////////////////////////////////////////
427 416
428 static SkView* MyFactory() { return new LightingView; } 417 static SkView* MyFactory() { return new LightingView; }
429 static SkViewRegister reg(MyFactory); 418 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleFilterFuzz.cpp ('k') | src/effects/SkLightingImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698