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

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

Issue 1822623002: switch colorfilters to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: manual rebase Created 4 years, 9 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
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 #include "SkPDFDevice.h" 8 #include "SkPDFDevice.h"
9 9
10 #include "SkAnnotationKeys.h" 10 #include "SkAnnotationKeys.h"
(...skipping 2093 matching lines...) Expand 10 before | Expand all | Expand 10 after
2104 fFontResources.push(newFont.get()); 2104 fFontResources.push(newFont.get());
2105 newFont.get()->ref(); 2105 newFont.get()->ref();
2106 } 2106 }
2107 return resourceIndex; 2107 return resourceIndex;
2108 } 2108 }
2109 2109
2110 static SkSize rect_to_size(const SkRect& r) { 2110 static SkSize rect_to_size(const SkRect& r) {
2111 return SkSize::Make(r.width(), r.height()); 2111 return SkSize::Make(r.width(), r.height());
2112 } 2112 }
2113 2113
2114 static const SkImage* color_filter(const SkImage* image, 2114 static const SkImage* color_filter(const SkImage* image, SkColorFilter* colorFil ter) {
2115 SkColorFilter* colorFilter) {
2116 sk_sp<SkSurface> surface(SkSurface::NewRaster( 2115 sk_sp<SkSurface> surface(SkSurface::NewRaster(
2117 SkImageInfo::MakeN32Premul(image->dimensions()))); 2116 SkImageInfo::MakeN32Premul(image->dimensions())));
2118 if (!surface) { 2117 if (!surface) {
2119 return image; 2118 return image;
2120 } 2119 }
2121 SkCanvas* canvas = surface->getCanvas(); 2120 SkCanvas* canvas = surface->getCanvas();
2122 canvas->clear(SK_ColorTRANSPARENT); 2121 canvas->clear(SK_ColorTRANSPARENT);
2123 SkPaint paint; 2122 SkPaint paint;
2124 paint.setColorFilter(colorFilter); 2123 paint.setColorFilter(sk_ref_sp(colorFilter));
2125 canvas->drawImage(image, 0, 0, &paint); 2124 canvas->drawImage(image, 0, 0, &paint);
2126 canvas->flush(); 2125 canvas->flush();
2127 return surface->makeImageSnapshot().release(); 2126 return surface->makeImageSnapshot().release();
2128 } 2127 }
2129 2128
2130 //////////////////////////////////////////////////////////////////////////////// 2129 ////////////////////////////////////////////////////////////////////////////////
2131 void SkPDFDevice::internalDrawImage(const SkMatrix& origMatrix, 2130 void SkPDFDevice::internalDrawImage(const SkMatrix& origMatrix,
2132 const SkClipStack* clipStack, 2131 const SkClipStack* clipStack,
2133 const SkRegion& origClipRegion, 2132 const SkRegion& origClipRegion,
2134 const SkImage* image, 2133 const SkImage* image,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
2266 pdfimage.reset(SkPDFCreateBitmapObject( 2265 pdfimage.reset(SkPDFCreateBitmapObject(
2267 image, fCanon->getPixelSerializer())); 2266 image, fCanon->getPixelSerializer()));
2268 if (!pdfimage) { 2267 if (!pdfimage) {
2269 return; 2268 return;
2270 } 2269 }
2271 fCanon->addPDFBitmap(image->uniqueID(), pdfimage.get()); 2270 fCanon->addPDFBitmap(image->uniqueID(), pdfimage.get());
2272 } 2271 }
2273 SkPDFUtils::DrawFormXObject(this->addXObjectResource(pdfimage.get()), 2272 SkPDFUtils::DrawFormXObject(this->addXObjectResource(pdfimage.get()),
2274 &content.entry()->fContent); 2273 &content.entry()->fContent);
2275 } 2274 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698