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

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

Issue 2234623002: SkPDF: bikeshed: use `auto` less (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | 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 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
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 8
9 #include "SkPDFShader.h" 9 #include "SkPDFShader.h"
10 10
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 SkPDFDocument* doc, SkScalar dpi, const SkPDFShader::State& state) { 646 SkPDFDocument* doc, SkScalar dpi, const SkPDFShader::State& state) {
647 SkRect bbox; 647 SkRect bbox;
648 bbox.set(state.fBBox); 648 bbox.set(state.fBBox);
649 649
650 sk_sp<SkPDFObject> luminosityShader( 650 sk_sp<SkPDFObject> luminosityShader(
651 get_pdf_shader_by_state(doc, dpi, state.MakeAlphaToLuminosityState() , 651 get_pdf_shader_by_state(doc, dpi, state.MakeAlphaToLuminosityState() ,
652 SkBitmap())); 652 SkBitmap()));
653 653
654 std::unique_ptr<SkStreamAsset> alphaStream(create_pattern_fill_content(-1, b box)); 654 std::unique_ptr<SkStreamAsset> alphaStream(create_pattern_fill_content(-1, b box));
655 655
656 auto resources = 656 sk_sp<SkPDFDict> resources =
657 get_gradient_resource_dict(luminosityShader.get(), nullptr); 657 get_gradient_resource_dict(luminosityShader.get(), nullptr);
658 658
659 auto alphaMask = SkPDFMakeFormXObject(std::move(alphaStream), 659 sk_sp<SkPDFObject> alphaMask =
660 SkPDFUtils::RectToArray(bbox), 660 SkPDFMakeFormXObject(std::move(alphaStream),
661 std::move(resources), 661 SkPDFUtils::RectToArray(bbox),
662 SkMatrix::I(), 662 std::move(resources),
663 "DeviceRGB"); 663 SkMatrix::I(),
664 "DeviceRGB");
664 return SkPDFGraphicState::GetSMaskGraphicState( 665 return SkPDFGraphicState::GetSMaskGraphicState(
665 std::move(alphaMask), false, 666 std::move(alphaMask), false,
666 SkPDFGraphicState::kLuminosity_SMaskMode, doc->canon()); 667 SkPDFGraphicState::kLuminosity_SMaskMode, doc->canon());
667 } 668 }
668 669
669 static sk_sp<SkPDFStream> make_alpha_function_shader(SkPDFDocument* doc, 670 static sk_sp<SkPDFStream> make_alpha_function_shader(SkPDFDocument* doc,
670 SkScalar dpi, 671 SkScalar dpi,
671 const SkPDFShader::State& s tate) { 672 const SkPDFShader::State& s tate) {
672 SkRect bbox; 673 SkRect bbox;
673 bbox.set(state.fBBox); 674 bbox.set(state.fBBox);
674 675
675 SkPDFShader::State opaqueState(state.MakeOpaqueState()); 676 SkPDFShader::State opaqueState(state.MakeOpaqueState());
676 677
677 sk_sp<SkPDFObject> colorShader( 678 sk_sp<SkPDFObject> colorShader(
678 get_pdf_shader_by_state(doc, dpi, std::move(opaqueState), SkBitmap() )); 679 get_pdf_shader_by_state(doc, dpi, std::move(opaqueState), SkBitmap() ));
679 if (!colorShader) { 680 if (!colorShader) {
680 return nullptr; 681 return nullptr;
681 } 682 }
682 683
683 // Create resource dict with alpha graphics state as G0 and 684 // Create resource dict with alpha graphics state as G0 and
684 // pattern shader as P0, then write content stream. 685 // pattern shader as P0, then write content stream.
685 auto alphaGs = create_smask_graphic_state(doc, dpi, state); 686 sk_sp<SkPDFObject> alphaGs = create_smask_graphic_state(doc, dpi, state);
686 687
687 auto resourceDict = 688 sk_sp<SkPDFDict> resourceDict =
688 get_gradient_resource_dict(colorShader.get(), alphaGs.get()); 689 get_gradient_resource_dict(colorShader.get(), alphaGs.get());
689 690
690 std::unique_ptr<SkStreamAsset> colorStream( 691 std::unique_ptr<SkStreamAsset> colorStream(
691 create_pattern_fill_content(0, bbox)); 692 create_pattern_fill_content(0, bbox));
692 auto alphaFunctionShader = sk_make_sp<SkPDFStream>(std::move(colorStream)); 693 auto alphaFunctionShader = sk_make_sp<SkPDFStream>(std::move(colorStream));
693 694
694 populate_tiling_pattern_dict(alphaFunctionShader->dict(), bbox, 695 populate_tiling_pattern_dict(alphaFunctionShader->dict(), bbox,
695 std::move(resourceDict), SkMatrix::I()); 696 std::move(resourceDict), SkMatrix::I());
696 return alphaFunctionShader; 697 return alphaFunctionShader;
697 } 698 }
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 } 1346 }
1346 return false; 1347 return false;
1347 } 1348 }
1348 1349
1349 void SkPDFShader::State::allocateGradientInfoStorage() { 1350 void SkPDFShader::State::allocateGradientInfoStorage() {
1350 fColors.reset(new SkColor[fInfo.fColorCount]); 1351 fColors.reset(new SkColor[fInfo.fColorCount]);
1351 fStops.reset(new SkScalar[fInfo.fColorCount]); 1352 fStops.reset(new SkScalar[fInfo.fColorCount]);
1352 fInfo.fColors = fColors.get(); 1353 fInfo.fColors = fColors.get();
1353 fInfo.fColorOffsets = fStops.get(); 1354 fInfo.fColorOffsets = fStops.get();
1354 } 1355 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698