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

Side by Side Diff: src/core/SkDraw.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
« no previous file with comments | « src/core/SkComposeShader.cpp ('k') | src/core/SkFilterShader.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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkDraw.h" 8 #include "SkDraw.h"
9 #include "SkBlitter.h" 9 #include "SkBlitter.h"
10 #include "SkBounder.h" 10 #include "SkBounder.h"
(...skipping 2335 matching lines...) Expand 10 before | Expand all | Expand 10 after
2346 dst[0] = verts[state.f0]; 2346 dst[0] = verts[state.f0];
2347 dst[1] = verts[state.f1]; 2347 dst[1] = verts[state.f1];
2348 dst[2] = verts[state.f2]; 2348 dst[2] = verts[state.f2];
2349 return matrix->setPolyToPoly(src, dst, 3); 2349 return matrix->setPolyToPoly(src, dst, 3);
2350 } 2350 }
2351 2351
2352 class SkTriColorShader : public SkShader { 2352 class SkTriColorShader : public SkShader {
2353 public: 2353 public:
2354 SkTriColorShader() {} 2354 SkTriColorShader() {}
2355 2355
2356 virtual SkShader::Context* createContext( 2356 virtual SkShader::Context* createContext(const ContextRec&, void*) const SK_ OVERRIDE;
2357 const SkBitmap&, const SkPaint&, const SkMatrix&, void*) const SK_OV ERRIDE;
2358 virtual size_t contextSize() const SK_OVERRIDE; 2357 virtual size_t contextSize() const SK_OVERRIDE;
2359 2358
2360 class TriColorShaderContext : public SkShader::Context { 2359 class TriColorShaderContext : public SkShader::Context {
2361 public: 2360 public:
2362 TriColorShaderContext(const SkTriColorShader& shader, const SkBitmap& de vice, 2361 TriColorShaderContext(const SkTriColorShader& shader, const ContextRec&) ;
2363 const SkPaint& paint, const SkMatrix& matrix);
2364 virtual ~TriColorShaderContext(); 2362 virtual ~TriColorShaderContext();
2365 2363
2366 bool setup(const SkPoint pts[], const SkColor colors[], int, int, int); 2364 bool setup(const SkPoint pts[], const SkColor colors[], int, int, int);
2367 2365
2368 virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count) SK_OVE RRIDE; 2366 virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count) SK_OVE RRIDE;
2369 2367
2370 private: 2368 private:
2371 SkMatrix fDstToUnit; 2369 SkMatrix fDstToUnit;
2372 SkPMColor fColors[3]; 2370 SkPMColor fColors[3];
2373 2371
2374 typedef SkShader::Context INHERITED; 2372 typedef SkShader::Context INHERITED;
2375 }; 2373 };
2376 2374
2377 SK_TO_STRING_OVERRIDE() 2375 SK_TO_STRING_OVERRIDE()
2378 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTriColorShader) 2376 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTriColorShader)
2379 2377
2380 protected: 2378 protected:
2381 SkTriColorShader(SkReadBuffer& buffer) : SkShader(buffer) {} 2379 SkTriColorShader(SkReadBuffer& buffer) : SkShader(buffer) {}
2382 2380
2383 private: 2381 private:
2384 typedef SkShader INHERITED; 2382 typedef SkShader INHERITED;
2385 }; 2383 };
2386 2384
2387 SkShader::Context* SkTriColorShader::createContext(const SkBitmap& device, const SkPaint& paint, 2385 SkShader::Context* SkTriColorShader::createContext(const ContextRec& rec, void* storage) const {
2388 const SkMatrix& matrix, void* storage) const { 2386 if (!this->validContext(rec)) {
2389 if (!this->validContext(device, paint, matrix)) {
2390 return NULL; 2387 return NULL;
2391 } 2388 }
2392 2389
2393 return SkNEW_PLACEMENT_ARGS(storage, TriColorShaderContext, (*this, device, paint, matrix)); 2390 return SkNEW_PLACEMENT_ARGS(storage, TriColorShaderContext, (*this, rec));
2394 } 2391 }
2395 2392
2396 bool SkTriColorShader::TriColorShaderContext::setup(const SkPoint pts[], const S kColor colors[], 2393 bool SkTriColorShader::TriColorShaderContext::setup(const SkPoint pts[], const S kColor colors[],
2397 int index0, int index1, int index2) { 2394 int index0, int index1, int index2) {
2398 2395
2399 fColors[0] = SkPreMultiplyColor(colors[index0]); 2396 fColors[0] = SkPreMultiplyColor(colors[index0]);
2400 fColors[1] = SkPreMultiplyColor(colors[index1]); 2397 fColors[1] = SkPreMultiplyColor(colors[index1]);
2401 fColors[2] = SkPreMultiplyColor(colors[index2]); 2398 fColors[2] = SkPreMultiplyColor(colors[index2]);
2402 2399
2403 SkMatrix m, im; 2400 SkMatrix m, im;
(...skipping 19 matching lines...) Expand all
2423 if (scale < 0) { 2420 if (scale < 0) {
2424 scale = 0; 2421 scale = 0;
2425 } 2422 }
2426 if (scale > 255) { 2423 if (scale > 255) {
2427 scale = 255; 2424 scale = 255;
2428 } 2425 }
2429 return SkAlpha255To256(scale); 2426 return SkAlpha255To256(scale);
2430 } 2427 }
2431 2428
2432 2429
2433 SkTriColorShader::TriColorShaderContext::TriColorShaderContext( 2430 SkTriColorShader::TriColorShaderContext::TriColorShaderContext(const SkTriColorS hader& shader,
2434 const SkTriColorShader& shader, const SkBitmap& device, 2431 const ContextRec& rec)
2435 const SkPaint& paint, const SkMatrix& matrix) 2432 : INHERITED(shader, rec) {}
2436 : INHERITED(shader, device, paint, matrix) {}
2437 2433
2438 SkTriColorShader::TriColorShaderContext::~TriColorShaderContext() {} 2434 SkTriColorShader::TriColorShaderContext::~TriColorShaderContext() {}
2439 2435
2440 size_t SkTriColorShader::contextSize() const { 2436 size_t SkTriColorShader::contextSize() const {
2441 return sizeof(TriColorShaderContext); 2437 return sizeof(TriColorShaderContext);
2442 } 2438 }
2443 void SkTriColorShader::TriColorShaderContext::shadeSpan(int x, int y, SkPMColor dstC[], int count) { 2439 void SkTriColorShader::TriColorShaderContext::shadeSpan(int x, int y, SkPMColor dstC[], int count) {
2444 SkPoint src; 2440 SkPoint src;
2445 2441
2446 for (int i = 0; i < count; i++) { 2442 for (int i = 0; i < count; i++) {
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
2833 mask->fImage = SkMask::AllocImage(size); 2829 mask->fImage = SkMask::AllocImage(size);
2834 memset(mask->fImage, 0, mask->computeImageSize()); 2830 memset(mask->fImage, 0, mask->computeImageSize());
2835 } 2831 }
2836 2832
2837 if (SkMask::kJustComputeBounds_CreateMode != mode) { 2833 if (SkMask::kJustComputeBounds_CreateMode != mode) {
2838 draw_into_mask(*mask, devPath, style); 2834 draw_into_mask(*mask, devPath, style);
2839 } 2835 }
2840 2836
2841 return true; 2837 return true;
2842 } 2838 }
OLDNEW
« no previous file with comments | « src/core/SkComposeShader.cpp ('k') | src/core/SkFilterShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698