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

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

Issue 2161233002: pre-land special methods on device (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 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/SkPDFDevice.h ('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 * 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 #include "SkAnnotationKeys.h" 9 #include "SkAnnotationKeys.h"
10 #include "SkBitmapDevice.h" 10 #include "SkBitmapDevice.h"
(...skipping 2198 matching lines...) Expand 10 before | Expand all | Expand 10 after
2209 if (!pdfimage) { 2209 if (!pdfimage) {
2210 return; 2210 return;
2211 } 2211 }
2212 fDocument->serialize(pdfimage); // serialize images early. 2212 fDocument->serialize(pdfimage); // serialize images early.
2213 fDocument->canon()->addPDFBitmap(key, pdfimage); 2213 fDocument->canon()->addPDFBitmap(key, pdfimage);
2214 } 2214 }
2215 // TODO(halcanary): addXObjectResource() should take a sk_sp<SkPDFObject> 2215 // TODO(halcanary): addXObjectResource() should take a sk_sp<SkPDFObject>
2216 SkPDFUtils::DrawFormXObject(this->addXObjectResource(pdfimage.get()), 2216 SkPDFUtils::DrawFormXObject(this->addXObjectResource(pdfimage.get()),
2217 &content.entry()->fContent); 2217 &content.entry()->fContent);
2218 } 2218 }
2219
2220 //////////////////////////////////////////////////////////////////////////////// ///////////////////
2221
2222 #include "SkSpecialImage.h"
2223 #include "SkImageFilter.h"
2224
2225 void SkPDFDevice::drawSpecial(const SkDraw& draw, SkSpecialImage* srcImg, int x, int y,
2226 const SkPaint& paint) {
2227 SkASSERT(!srcImg->isTextureBacked());
2228
2229 SkBitmap resultBM;
2230
2231 SkImageFilter* filter = paint.getImageFilter();
2232 if (filter) {
2233 SkIPoint offset = SkIPoint::Make(0, 0);
2234 SkMatrix matrix = *draw.fMatrix;
2235 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
2236 const SkIRect clipBounds = draw.fRC->getBounds().makeOffset(-x, -y);
robertphillips 2016/07/19 21:08:04 Should be override getImageFilterCache for the SkP
reed1 2016/07/19 21:32:26 Good catch. I think its just a public/protected is
2237 // SkAutoTUnref<SkImageFilterCache> cache(this->getImageFilterCache());
2238 SkImageFilter::Context ctx(matrix, clipBounds, nullptr /*cache.get()*/);
2239
2240 sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg, ctx, &offset ));
2241 if (resultImg) {
2242 SkPaint tmpUnfiltered(paint);
2243 tmpUnfiltered.setImageFilter(nullptr);
2244 if (resultImg->getROPixels(&resultBM)) {
2245 this->drawSprite(draw, resultBM, x + offset.x(), y + offset.y(), tmpUnfiltered);
2246 }
2247 }
2248 } else {
2249 if (srcImg->getROPixels(&resultBM)) {
2250 this->drawSprite(draw, resultBM, x, y, paint);
2251 }
2252 }
2253 }
2254
2255 sk_sp<SkSpecialImage> SkPDFDevice::makeSpecial(const SkBitmap& bitmap) {
2256 return SkSpecialImage::MakeFromRaster(bitmap.bounds(), bitmap);
2257 }
2258
2259 sk_sp<SkSpecialImage> SkPDFDevice::makeSpecial(const SkImage* image) {
2260 return SkSpecialImage::MakeFromImage(SkIRect::MakeWH(image->width(), image-> height()),
2261 image->makeNonTextureImage());
2262 }
2263
2264 sk_sp<SkSpecialImage> SkPDFDevice::snapSpecial() {
2265 SkASSERT(false);
2266 return nullptr;
2267 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFDevice.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698