OLD | NEW |
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 sk_sp<SkImage> image(buffer.readImage()); | 65 sk_sp<SkImage> image(buffer.readImage()); |
66 if (!image) { | 66 if (!image) { |
67 return nullptr; | 67 return nullptr; |
68 } | 68 } |
69 | 69 |
70 return SkImageSource::Make(std::move(image), src, dst, filterQuality); | 70 return SkImageSource::Make(std::move(image), src, dst, filterQuality); |
71 } | 71 } |
72 | 72 |
73 void SkImageSource::flatten(SkWriteBuffer& buffer) const { | 73 void SkImageSource::flatten(SkWriteBuffer& buffer) const { |
74 buffer.writeInt(fFilterQuality); | 74 buffer.writeInt("fFilterQuality", fFilterQuality); |
75 buffer.writeRect(fSrcRect); | 75 buffer.writeRect("fSrcRect", fSrcRect); |
76 buffer.writeRect(fDstRect); | 76 buffer.writeRect("fDstRect", fDstRect); |
77 buffer.writeImage(fImage.get()); | 77 buffer.writeImage("fImage", fImage.get()); |
78 } | 78 } |
79 | 79 |
80 sk_sp<SkSpecialImage> SkImageSource::onFilterImage(SkSpecialImage* source, const
Context& ctx, | 80 sk_sp<SkSpecialImage> SkImageSource::onFilterImage(SkSpecialImage* source, const
Context& ctx, |
81 SkIPoint* offset) const { | 81 SkIPoint* offset) const { |
82 SkRect dstRect; | 82 SkRect dstRect; |
83 ctx.ctm().mapRect(&dstRect, fDstRect); | 83 ctx.ctm().mapRect(&dstRect, fDstRect); |
84 | 84 |
85 SkRect bounds = SkRect::MakeIWH(fImage->width(), fImage->height()); | 85 SkRect bounds = SkRect::MakeIWH(fImage->width(), fImage->height()); |
86 if (fSrcRect == bounds && dstRect == bounds) { | 86 if (fSrcRect == bounds && dstRect == bounds) { |
87 // No regions cropped out or resized; return entire image. | 87 // No regions cropped out or resized; return entire image. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 void SkImageSource::toString(SkString* str) const { | 134 void SkImageSource::toString(SkString* str) const { |
135 str->appendf("SkImageSource: ("); | 135 str->appendf("SkImageSource: ("); |
136 str->appendf("src: (%f,%f,%f,%f) dst: (%f,%f,%f,%f) ", | 136 str->appendf("src: (%f,%f,%f,%f) dst: (%f,%f,%f,%f) ", |
137 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m, | 137 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m, |
138 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto
m); | 138 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto
m); |
139 str->appendf("image: (%d,%d)", | 139 str->appendf("image: (%d,%d)", |
140 fImage->width(), fImage->height()); | 140 fImage->width(), fImage->height()); |
141 str->append(")"); | 141 str->append(")"); |
142 } | 142 } |
143 #endif | 143 #endif |
OLD | NEW |