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

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

Issue 1842243002: Update SkImageSource to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update to ToT Created 4 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 | « samplecode/SampleFilterFuzz.cpp ('k') | src/utils/SkBitmapSourceDeserializer.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"
11 #include "SkImage.h" 11 #include "SkImage.h"
12 #include "SkReadBuffer.h" 12 #include "SkReadBuffer.h"
13 #include "SkSpecialImage.h" 13 #include "SkSpecialImage.h"
14 #include "SkSpecialSurface.h" 14 #include "SkSpecialSurface.h"
15 #include "SkWriteBuffer.h" 15 #include "SkWriteBuffer.h"
16 #include "SkString.h" 16 #include "SkString.h"
17 17
18 SkImageFilter* SkImageSource::Create(SkImage* image) { 18
19 return image ? new SkImageSource(image) : nullptr; 19 SkImageSource::SkImageSource(sk_sp<SkImage> image)
20 : INHERITED(0, nullptr)
21 , fImage(std::move(image))
22 , fSrcRect(SkRect::MakeIWH(fImage->width(), fImage->height()))
23 , fDstRect(fSrcRect)
24 , fFilterQuality(kHigh_SkFilterQuality) {
20 } 25 }
21 26
22 SkImageFilter* SkImageSource::Create(SkImage* image, 27 SkImageSource::SkImageSource(sk_sp<SkImage> image,
23 const SkRect& srcRect,
24 const SkRect& dstRect,
25 SkFilterQuality filterQuality) {
26 return image ? new SkImageSource(image, srcRect, dstRect, filterQuality) : n ullptr;
27 }
28
29 SkImageSource::SkImageSource(SkImage* image)
30 : INHERITED(0, nullptr)
31 , fImage(SkRef(image))
32 , fSrcRect(SkRect::MakeIWH(image->width(), image->height()))
33 , fDstRect(fSrcRect)
34 , fFilterQuality(kHigh_SkFilterQuality) { }
35
36 SkImageSource::SkImageSource(SkImage* image,
37 const SkRect& srcRect, 28 const SkRect& srcRect,
38 const SkRect& dstRect, 29 const SkRect& dstRect,
39 SkFilterQuality filterQuality) 30 SkFilterQuality filterQuality)
40 : INHERITED(0, nullptr) 31 : INHERITED(0, nullptr)
41 , fImage(SkRef(image)) 32 , fImage(std::move(image))
42 , fSrcRect(srcRect) 33 , fSrcRect(srcRect)
43 , fDstRect(dstRect) 34 , fDstRect(dstRect)
44 , fFilterQuality(filterQuality) { } 35 , fFilterQuality(filterQuality) {
36 }
45 37
46 SkFlattenable* SkImageSource::CreateProc(SkReadBuffer& buffer) { 38 SkFlattenable* SkImageSource::CreateProc(SkReadBuffer& buffer) {
47 SkFilterQuality filterQuality = (SkFilterQuality)buffer.readInt(); 39 SkFilterQuality filterQuality = (SkFilterQuality)buffer.readInt();
48 40
49 SkRect src, dst; 41 SkRect src, dst;
50 buffer.readRect(&src); 42 buffer.readRect(&src);
51 buffer.readRect(&dst); 43 buffer.readRect(&dst);
52 44
53 SkAutoTUnref<SkImage> image(buffer.readImage()); 45 sk_sp<SkImage> image(buffer.readImage());
54 if (!image) { 46 if (!image) {
55 return nullptr; 47 return nullptr;
56 } 48 }
57 49
58 return SkImageSource::Create(image, src, dst, filterQuality); 50 return SkImageSource::Make(std::move(image), src, dst, filterQuality).releas e();
59 } 51 }
60 52
61 void SkImageSource::flatten(SkWriteBuffer& buffer) const { 53 void SkImageSource::flatten(SkWriteBuffer& buffer) const {
62 buffer.writeInt(fFilterQuality); 54 buffer.writeInt(fFilterQuality);
63 buffer.writeRect(fSrcRect); 55 buffer.writeRect(fSrcRect);
64 buffer.writeRect(fDstRect); 56 buffer.writeRect(fDstRect);
65 buffer.writeImage(fImage.get()); 57 buffer.writeImage(fImage.get());
66 } 58 }
67 59
68 sk_sp<SkSpecialImage> SkImageSource::onFilterImage(SkSpecialImage* source, const Context& ctx, 60 sk_sp<SkSpecialImage> SkImageSource::onFilterImage(SkSpecialImage* source, const Context& ctx,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 void SkImageSource::toString(SkString* str) const { 113 void SkImageSource::toString(SkString* str) const {
122 str->appendf("SkImageSource: ("); 114 str->appendf("SkImageSource: (");
123 str->appendf("src: (%f,%f,%f,%f) dst: (%f,%f,%f,%f) ", 115 str->appendf("src: (%f,%f,%f,%f) dst: (%f,%f,%f,%f) ",
124 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto m, 116 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto m,
125 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto m); 117 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto m);
126 str->appendf("image: (%d,%d)", 118 str->appendf("image: (%d,%d)",
127 fImage->width(), fImage->height()); 119 fImage->width(), fImage->height());
128 str->append(")"); 120 str->append(")");
129 } 121 }
130 #endif 122 #endif
OLDNEW
« no previous file with comments | « samplecode/SampleFilterFuzz.cpp ('k') | src/utils/SkBitmapSourceDeserializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698