OLD | NEW |
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 Loading... |
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(const ContextRec&, void*) const SK_
OVERRIDE; | |
2357 virtual size_t contextSize() const SK_OVERRIDE; | 2356 virtual size_t contextSize() const SK_OVERRIDE; |
2358 | 2357 |
2359 class TriColorShaderContext : public SkShader::Context { | 2358 class TriColorShaderContext : public SkShader::Context { |
2360 public: | 2359 public: |
2361 TriColorShaderContext(const SkTriColorShader& shader, const ContextRec&)
; | 2360 TriColorShaderContext(const SkTriColorShader& shader, const ContextRec&)
; |
2362 virtual ~TriColorShaderContext(); | 2361 virtual ~TriColorShaderContext(); |
2363 | 2362 |
2364 bool setup(const SkPoint pts[], const SkColor colors[], int, int, int); | 2363 bool setup(const SkPoint pts[], const SkColor colors[], int, int, int); |
2365 | 2364 |
2366 virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count) SK_OVE
RRIDE; | 2365 virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count) SK_OVE
RRIDE; |
2367 | 2366 |
2368 private: | 2367 private: |
2369 SkMatrix fDstToUnit; | 2368 SkMatrix fDstToUnit; |
2370 SkPMColor fColors[3]; | 2369 SkPMColor fColors[3]; |
2371 | 2370 |
2372 typedef SkShader::Context INHERITED; | 2371 typedef SkShader::Context INHERITED; |
2373 }; | 2372 }; |
2374 | 2373 |
2375 SK_TO_STRING_OVERRIDE() | 2374 SK_TO_STRING_OVERRIDE() |
2376 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTriColorShader) | 2375 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTriColorShader) |
2377 | 2376 |
2378 protected: | 2377 protected: |
2379 SkTriColorShader(SkReadBuffer& buffer) : SkShader(buffer) {} | 2378 SkTriColorShader(SkReadBuffer& buffer) : SkShader(buffer) {} |
2380 | 2379 |
| 2380 virtual Context* onCreateContext(const ContextRec& rec, void* storage) const
SK_OVERRIDE { |
| 2381 return SkNEW_PLACEMENT_ARGS(storage, TriColorShaderContext, (*this, rec)
); |
| 2382 } |
| 2383 |
2381 private: | 2384 private: |
2382 typedef SkShader INHERITED; | 2385 typedef SkShader INHERITED; |
2383 }; | 2386 }; |
2384 | 2387 |
2385 SkShader::Context* SkTriColorShader::createContext(const ContextRec& rec, void*
storage) const { | |
2386 if (!this->validContext(rec)) { | |
2387 return NULL; | |
2388 } | |
2389 | |
2390 return SkNEW_PLACEMENT_ARGS(storage, TriColorShaderContext, (*this, rec)); | |
2391 } | |
2392 | |
2393 bool SkTriColorShader::TriColorShaderContext::setup(const SkPoint pts[], const S
kColor colors[], | 2388 bool SkTriColorShader::TriColorShaderContext::setup(const SkPoint pts[], const S
kColor colors[], |
2394 int index0, int index1, int
index2) { | 2389 int index0, int index1, int
index2) { |
2395 | 2390 |
2396 fColors[0] = SkPreMultiplyColor(colors[index0]); | 2391 fColors[0] = SkPreMultiplyColor(colors[index0]); |
2397 fColors[1] = SkPreMultiplyColor(colors[index1]); | 2392 fColors[1] = SkPreMultiplyColor(colors[index1]); |
2398 fColors[2] = SkPreMultiplyColor(colors[index2]); | 2393 fColors[2] = SkPreMultiplyColor(colors[index2]); |
2399 | 2394 |
2400 SkMatrix m, im; | 2395 SkMatrix m, im; |
2401 m.reset(); | 2396 m.reset(); |
2402 m.set(0, pts[index1].fX - pts[index0].fX); | 2397 m.set(0, pts[index1].fX - pts[index0].fX); |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2829 mask->fImage = SkMask::AllocImage(size); | 2824 mask->fImage = SkMask::AllocImage(size); |
2830 memset(mask->fImage, 0, mask->computeImageSize()); | 2825 memset(mask->fImage, 0, mask->computeImageSize()); |
2831 } | 2826 } |
2832 | 2827 |
2833 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2828 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
2834 draw_into_mask(*mask, devPath, style); | 2829 draw_into_mask(*mask, devPath, style); |
2835 } | 2830 } |
2836 | 2831 |
2837 return true; | 2832 return true; |
2838 } | 2833 } |
OLD | NEW |