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

Side by Side Diff: src/effects/SkImageSource.cpp

Issue 1826893002: Switch new SkImageFilter internal methods over to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Change method name to drawSpriteWithFilter 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
« no previous file with comments | « src/effects/SkDropShadowImageFilter.cpp ('k') | src/effects/SkMergeImageFilter.cpp » ('j') | 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 2015 Google Inc. 2 * Copyright 2015 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 "SkImageSource.h" 8 #include "SkImageSource.h"
9 9
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 return SkImageSource::Create(image, src, dst, filterQuality); 58 return SkImageSource::Create(image, src, dst, filterQuality);
59 } 59 }
60 60
61 void SkImageSource::flatten(SkWriteBuffer& buffer) const { 61 void SkImageSource::flatten(SkWriteBuffer& buffer) const {
62 buffer.writeInt(fFilterQuality); 62 buffer.writeInt(fFilterQuality);
63 buffer.writeRect(fSrcRect); 63 buffer.writeRect(fSrcRect);
64 buffer.writeRect(fDstRect); 64 buffer.writeRect(fDstRect);
65 buffer.writeImage(fImage.get()); 65 buffer.writeImage(fImage.get());
66 } 66 }
67 67
68 SkSpecialImage* SkImageSource::onFilterImage(SkSpecialImage* source, const Conte xt& ctx, 68 sk_sp<SkSpecialImage> SkImageSource::onFilterImage(SkSpecialImage* source, const Context& ctx,
69 SkIPoint* offset) const { 69 SkIPoint* offset) const {
70 SkRect dstRect; 70 SkRect dstRect;
71 ctx.ctm().mapRect(&dstRect, fDstRect); 71 ctx.ctm().mapRect(&dstRect, fDstRect);
72 72
73 SkRect bounds = SkRect::MakeIWH(fImage->width(), fImage->height()); 73 SkRect bounds = SkRect::MakeIWH(fImage->width(), fImage->height());
74 if (fSrcRect == bounds && dstRect == bounds) { 74 if (fSrcRect == bounds && dstRect == bounds) {
75 // No regions cropped out or resized; return entire image. 75 // No regions cropped out or resized; return entire image.
76 offset->fX = offset->fY = 0; 76 offset->fX = offset->fY = 0;
77 return SkSpecialImage::MakeFromImage(source->internal_getProxy(), 77 return SkSpecialImage::MakeFromImage(source->internal_getProxy(),
78 SkIRect::MakeWH(fImage->width(), fI mage->height()), 78 SkIRect::MakeWH(fImage->width(), fI mage->height()),
79 fImage).release(); 79 fImage);
80 } 80 }
81 81
82 const SkIRect dstIRect = dstRect.roundOut(); 82 const SkIRect dstIRect = dstRect.roundOut();
83 83
84 const SkImageInfo info = SkImageInfo::MakeN32(dstIRect.width(), dstIRect.hei ght(), 84 const SkImageInfo info = SkImageInfo::MakeN32(dstIRect.width(), dstIRect.hei ght(),
85 kPremul_SkAlphaType); 85 kPremul_SkAlphaType);
86 86
87 sk_sp<SkSpecialSurface> surf(source->makeSurface(info)); 87 sk_sp<SkSpecialSurface> surf(source->makeSurface(info));
88 if (!surf) { 88 if (!surf) {
89 return nullptr; 89 return nullptr;
(...skipping 13 matching lines...) Expand all
103 // FIXME: this probably shouldn't be necessary, but drawImageRect asserts 103 // FIXME: this probably shouldn't be necessary, but drawImageRect asserts
104 // None filtering when it's translate-only 104 // None filtering when it's translate-only
105 paint.setFilterQuality( 105 paint.setFilterQuality(
106 fSrcRect.width() == dstRect.width() && fSrcRect.height() == dstRect.heig ht() ? 106 fSrcRect.width() == dstRect.width() && fSrcRect.height() == dstRect.heig ht() ?
107 kNone_SkFilterQuality : fFilterQuality); 107 kNone_SkFilterQuality : fFilterQuality);
108 canvas->drawImageRect(fImage.get(), fSrcRect, dstRect, &paint, 108 canvas->drawImageRect(fImage.get(), fSrcRect, dstRect, &paint,
109 SkCanvas::kStrict_SrcRectConstraint); 109 SkCanvas::kStrict_SrcRectConstraint);
110 110
111 offset->fX = dstIRect.fLeft; 111 offset->fX = dstIRect.fLeft;
112 offset->fY = dstIRect.fTop; 112 offset->fY = dstIRect.fTop;
113 return surf->makeImageSnapshot().release(); 113 return surf->makeImageSnapshot();
114 } 114 }
115 115
116 SkRect SkImageSource::computeFastBounds(const SkRect& src) const { 116 SkRect SkImageSource::computeFastBounds(const SkRect& src) const {
117 return fDstRect; 117 return fDstRect;
118 } 118 }
119 119
120 #ifndef SK_IGNORE_TO_STRING 120 #ifndef SK_IGNORE_TO_STRING
121 void SkImageSource::toString(SkString* str) const { 121 void SkImageSource::toString(SkString* str) const {
122 str->appendf("SkImageSource: ("); 122 str->appendf("SkImageSource: (");
123 str->appendf("src: (%f,%f,%f,%f) dst: (%f,%f,%f,%f) ", 123 str->appendf("src: (%f,%f,%f,%f) dst: (%f,%f,%f,%f) ",
124 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto m, 124 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto m,
125 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto m); 125 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto m);
126 str->appendf("image: (%d,%d)", 126 str->appendf("image: (%d,%d)",
127 fImage->width(), fImage->height()); 127 fImage->width(), fImage->height());
128 str->append(")"); 128 str->append(")");
129 } 129 }
130 #endif 130 #endif
OLDNEW
« no previous file with comments | « src/effects/SkDropShadowImageFilter.cpp ('k') | src/effects/SkMergeImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698