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

Side by Side Diff: src/pdf/SkPDFShader.cpp

Issue 1046293002: SkPDF: SkPDFGraphicState Lookup hashtabled (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-04-01 (Wednesday) 16:16:21 EDT Created 5 years, 8 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 | « src/pdf/SkPDFGraphicState.cpp ('k') | no next file » | 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 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 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 SkPDFUtils::PaintPath(SkPaint::kFill_Style, SkPath::kEvenOdd_FillType, 628 SkPDFUtils::PaintPath(SkPaint::kFill_Style, SkPath::kEvenOdd_FillType,
629 &content); 629 &content);
630 630
631 return content.detachAsStream(); 631 return content.detachAsStream();
632 } 632 }
633 633
634 /** 634 /**
635 * Creates a ExtGState with the SMask set to the luminosityShader in 635 * Creates a ExtGState with the SMask set to the luminosityShader in
636 * luminosity mode. The shader pattern extends to the bbox. 636 * luminosity mode. The shader pattern extends to the bbox.
637 */ 637 */
638 static SkPDFGraphicState* create_smask_graphic_state( 638 static SkPDFObject* create_smask_graphic_state(
639 SkPDFCanon* canon, SkScalar dpi, const SkPDFShader::State& state) { 639 SkPDFCanon* canon, SkScalar dpi, const SkPDFShader::State& state) {
640 SkRect bbox; 640 SkRect bbox;
641 bbox.set(state.fBBox); 641 bbox.set(state.fBBox);
642 642
643 SkAutoTDelete<SkPDFShader::State> alphaToLuminosityState( 643 SkAutoTDelete<SkPDFShader::State> alphaToLuminosityState(
644 state.CreateAlphaToLuminosityState()); 644 state.CreateAlphaToLuminosityState());
645 SkAutoTUnref<SkPDFObject> luminosityShader( 645 SkAutoTUnref<SkPDFObject> luminosityShader(
646 get_pdf_shader_by_state(canon, dpi, &alphaToLuminosityState)); 646 get_pdf_shader_by_state(canon, dpi, &alphaToLuminosityState));
647 647
648 SkAutoTDelete<SkStream> alphaStream(create_pattern_fill_content(-1, bbox)); 648 SkAutoTDelete<SkStream> alphaStream(create_pattern_fill_content(-1, bbox));
(...skipping 20 matching lines...) Expand all
669 SkAutoTDelete<SkPDFShader::State> opaqueState(state.CreateOpaqueState()); 669 SkAutoTDelete<SkPDFShader::State> opaqueState(state.CreateOpaqueState());
670 670
671 SkAutoTUnref<SkPDFObject> colorShader( 671 SkAutoTUnref<SkPDFObject> colorShader(
672 get_pdf_shader_by_state(canon, dpi, &opaqueState)); 672 get_pdf_shader_by_state(canon, dpi, &opaqueState));
673 if (!colorShader) { 673 if (!colorShader) {
674 return NULL; 674 return NULL;
675 } 675 }
676 676
677 // Create resource dict with alpha graphics state as G0 and 677 // Create resource dict with alpha graphics state as G0 and
678 // pattern shader as P0, then write content stream. 678 // pattern shader as P0, then write content stream.
679 SkAutoTUnref<SkPDFGraphicState> alphaGs( 679 SkAutoTUnref<SkPDFObject> alphaGs(
680 create_smask_graphic_state(canon, dpi, state)); 680 create_smask_graphic_state(canon, dpi, state));
681 681
682 SkPDFAlphaFunctionShader* alphaFunctionShader = 682 SkPDFAlphaFunctionShader* alphaFunctionShader =
683 SkNEW_ARGS(SkPDFAlphaFunctionShader, (autoState->detach())); 683 SkNEW_ARGS(SkPDFAlphaFunctionShader, (autoState->detach()));
684 684
685 SkAutoTUnref<SkPDFResourceDict> resourceDict( 685 SkAutoTUnref<SkPDFResourceDict> resourceDict(
686 get_gradient_resource_dict(colorShader.get(), alphaGs.get())); 686 get_gradient_resource_dict(colorShader.get(), alphaGs.get()));
687 687
688 SkAutoTDelete<SkStream> colorStream( 688 SkAutoTDelete<SkStream> colorStream(
689 create_pattern_fill_content(0, bbox)); 689 create_pattern_fill_content(0, bbox));
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 return false; 1303 return false;
1304 } 1304 }
1305 1305
1306 void SkPDFShader::State::AllocateGradientInfoStorage() { 1306 void SkPDFShader::State::AllocateGradientInfoStorage() {
1307 fColorData.set(sk_malloc_throw( 1307 fColorData.set(sk_malloc_throw(
1308 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar)))); 1308 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar))));
1309 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get()); 1309 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get());
1310 fInfo.fColorOffsets = 1310 fInfo.fColorOffsets =
1311 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount); 1311 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount);
1312 } 1312 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFGraphicState.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698