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

Side by Side Diff: src/effects/gradients/SkSweepGradient.cpp

Issue 264843006: create struct to hold all the params passed around for shader::context (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: address review comments Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 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 "SkSweepGradient.h" 9 #include "SkSweepGradient.h"
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 void SkSweepGradient::flatten(SkWriteBuffer& buffer) const { 50 void SkSweepGradient::flatten(SkWriteBuffer& buffer) const {
51 this->INHERITED::flatten(buffer); 51 this->INHERITED::flatten(buffer);
52 buffer.writePoint(fCenter); 52 buffer.writePoint(fCenter);
53 } 53 }
54 54
55 size_t SkSweepGradient::contextSize() const { 55 size_t SkSweepGradient::contextSize() const {
56 return sizeof(SweepGradientContext); 56 return sizeof(SweepGradientContext);
57 } 57 }
58 58
59 SkShader::Context* SkSweepGradient::createContext(const SkBitmap& device, const SkPaint& paint, 59 SkShader::Context* SkSweepGradient::createContext(const ContextRec& rec, void* s torage) const {
60 const SkMatrix& matrix, void* storage) const { 60 if (!this->validContext(rec)) {
61 if (!this->validContext(device, paint, matrix)) {
62 return NULL; 61 return NULL;
63 } 62 }
64 63
65 return SkNEW_PLACEMENT_ARGS(storage, SweepGradientContext, (*this, device, p aint, matrix)); 64 return SkNEW_PLACEMENT_ARGS(storage, SweepGradientContext, (*this, rec));
66 } 65 }
67 66
68 SkSweepGradient::SweepGradientContext::SweepGradientContext( 67 SkSweepGradient::SweepGradientContext::SweepGradientContext(
69 const SkSweepGradient& shader, const SkBitmap& device, 68 const SkSweepGradient& shader, const ContextRec& rec)
70 const SkPaint& paint, const SkMatrix& matrix) 69 : INHERITED(shader, rec) {}
71 : INHERITED(shader, device, paint, matrix) {}
72 70
73 // returns angle in a circle [0..2PI) -> [0..255] 71 // returns angle in a circle [0..2PI) -> [0..255]
74 static unsigned SkATan2_255(float y, float x) { 72 static unsigned SkATan2_255(float y, float x) {
75 // static const float g255Over2PI = 255 / (2 * SK_ScalarPI); 73 // static const float g255Over2PI = 255 / (2 * SK_ScalarPI);
76 static const float g255Over2PI = 40.584510488433314f; 74 static const float g255Over2PI = 40.584510488433314f;
77 75
78 float result = sk_float_atan2(y, x); 76 float result = sk_float_atan2(y, x);
79 if (result < 0) { 77 if (result < 0) {
80 result += 2 * SK_ScalarPI; 78 result += 2 * SK_ScalarPI;
81 } 79 }
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 str->appendScalar(fCenter.fX); 309 str->appendScalar(fCenter.fX);
312 str->append(", "); 310 str->append(", ");
313 str->appendScalar(fCenter.fY); 311 str->appendScalar(fCenter.fY);
314 str->append(") "); 312 str->append(") ");
315 313
316 this->INHERITED::toString(str); 314 this->INHERITED::toString(str);
317 315
318 str->append(")"); 316 str->append(")");
319 } 317 }
320 #endif 318 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkSweepGradient.h ('k') | src/effects/gradients/SkTwoPointConicalGradient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698