| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 | 9 |
| 10 #include "SkPDFShader.h" | 10 #include "SkPDFShader.h" |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 SkPDFUtils::PaintPath(SkPaint::kFill_Style, SkPath::kEvenOdd_FillType, | 654 SkPDFUtils::PaintPath(SkPaint::kFill_Style, SkPath::kEvenOdd_FillType, |
| 655 &content); | 655 &content); |
| 656 | 656 |
| 657 return content.detachAsStream(); | 657 return content.detachAsStream(); |
| 658 } | 658 } |
| 659 | 659 |
| 660 /** | 660 /** |
| 661 * Creates a ExtGState with the SMask set to the luminosityShader in | 661 * Creates a ExtGState with the SMask set to the luminosityShader in |
| 662 * luminosity mode. The shader pattern extends to the bbox. | 662 * luminosity mode. The shader pattern extends to the bbox. |
| 663 */ | 663 */ |
| 664 static SkPDFGraphicState* createsmask_graphic_state( | 664 static SkPDFGraphicState* create_smask_graphic_state( |
| 665 const SkPDFShader::State& state) { | 665 const SkPDFShader::State& state) { |
| 666 SkRect bbox; | 666 SkRect bbox; |
| 667 bbox.set(state.fBBox); | 667 bbox.set(state.fBBox); |
| 668 | 668 |
| 669 SkAutoTDelete<SkPDFShader::State> alphaToLuminosityState( | 669 SkAutoTDelete<SkPDFShader::State> alphaToLuminosityState( |
| 670 state.CreateAlphaToLuminosityState()); | 670 state.CreateAlphaToLuminosityState()); |
| 671 SkAutoTUnref<SkPDFObject> luminosityShader( | 671 SkAutoTUnref<SkPDFObject> luminosityShader( |
| 672 get_pdf_shader_by_state(&alphaToLuminosityState)); | 672 get_pdf_shader_by_state(&alphaToLuminosityState)); |
| 673 | 673 |
| 674 SkAutoTDelete<SkStream> alphaStream(create_pattern_fill_content(-1, bbox)); | 674 SkAutoTDelete<SkStream> alphaStream(create_pattern_fill_content(-1, bbox)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 692 | 692 |
| 693 SkAutoTDelete<SkPDFShader::State> opaqueState(state.CreateOpaqueState()); | 693 SkAutoTDelete<SkPDFShader::State> opaqueState(state.CreateOpaqueState()); |
| 694 | 694 |
| 695 SkPDFObject* colorShader = get_pdf_shader_by_state(&opaqueState); | 695 SkPDFObject* colorShader = get_pdf_shader_by_state(&opaqueState); |
| 696 if (!colorShader) { | 696 if (!colorShader) { |
| 697 return NULL; | 697 return NULL; |
| 698 } | 698 } |
| 699 | 699 |
| 700 // Create resource dict with alpha graphics state as G0 and | 700 // Create resource dict with alpha graphics state as G0 and |
| 701 // pattern shader as P0, then write content stream. | 701 // pattern shader as P0, then write content stream. |
| 702 SkAutoTUnref<SkPDFGraphicState> alphaGs(createsmask_graphic_state(state)); | 702 SkAutoTUnref<SkPDFGraphicState> alphaGs(create_smask_graphic_state(state)); |
| 703 | 703 |
| 704 SkPDFAlphaFunctionShader* alphaFunctionShader = | 704 SkPDFAlphaFunctionShader* alphaFunctionShader = |
| 705 SkNEW_ARGS(SkPDFAlphaFunctionShader, (autoState->detach())); | 705 SkNEW_ARGS(SkPDFAlphaFunctionShader, (autoState->detach())); |
| 706 | 706 |
| 707 alphaFunctionShader->fColorShader.reset(colorShader); | 707 alphaFunctionShader->fColorShader.reset(colorShader); |
| 708 | 708 |
| 709 alphaFunctionShader->fResourceDict.reset(get_gradient_resource_dict( | 709 alphaFunctionShader->fResourceDict.reset(get_gradient_resource_dict( |
| 710 alphaFunctionShader->fColorShader.get(), alphaGs.get())); | 710 alphaFunctionShader->fColorShader.get(), alphaGs.get())); |
| 711 | 711 |
| 712 SkAutoTDelete<SkStream> colorStream( | 712 SkAutoTDelete<SkStream> colorStream( |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1325 return false; | 1325 return false; |
| 1326 } | 1326 } |
| 1327 | 1327 |
| 1328 void SkPDFShader::State::AllocateGradientInfoStorage() { | 1328 void SkPDFShader::State::AllocateGradientInfoStorage() { |
| 1329 fColorData.set(sk_malloc_throw( | 1329 fColorData.set(sk_malloc_throw( |
| 1330 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar)))); | 1330 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar)))); |
| 1331 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get()); | 1331 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get()); |
| 1332 fInfo.fColorOffsets = | 1332 fInfo.fColorOffsets = |
| 1333 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount); | 1333 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount); |
| 1334 } | 1334 } |
| OLD | NEW |