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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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. |
88 offset->fX = offset->fY = 0; | 88 offset->fX = offset->fY = 0; |
89 return SkSpecialImage::MakeFromImage(SkIRect::MakeWH(fImage->width(), fI
mage->height()), | 89 return SkSpecialImage::MakeFromImage(SkIRect::MakeWH(fImage->width(), fI
mage->height()), |
90 fImage, | 90 fImage, |
91 &source->props()); | 91 &source->props()); |
92 } | 92 } |
93 | 93 |
94 const SkIRect dstIRect = dstRect.roundOut(); | 94 const SkIRect dstIRect = dstRect.roundOut(); |
95 | 95 |
96 // SRGBTODO: Propagate SkColorType? | 96 sk_sp<SkSpecialSurface> surf(source->makeSurface(ctx.outputProperties(), dst
IRect.size())); |
97 const SkImageInfo info = SkImageInfo::MakeN32(dstIRect.width(), dstIRect.hei
ght(), | |
98 kPremul_SkAlphaType); | |
99 | |
100 sk_sp<SkSpecialSurface> surf(source->makeSurface(info)); | |
101 if (!surf) { | 97 if (!surf) { |
102 return nullptr; | 98 return nullptr; |
103 } | 99 } |
104 | 100 |
105 SkCanvas* canvas = surf->getCanvas(); | 101 SkCanvas* canvas = surf->getCanvas(); |
106 SkASSERT(canvas); | 102 SkASSERT(canvas); |
107 | 103 |
108 // TODO: it seems like this clear shouldn't be necessary (see skbug.com/5075
) | 104 // TODO: it seems like this clear shouldn't be necessary (see skbug.com/5075
) |
109 canvas->clear(0x0); | 105 canvas->clear(0x0); |
110 | 106 |
(...skipping 23 matching lines...) Expand all Loading... |
134 void SkImageSource::toString(SkString* str) const { | 130 void SkImageSource::toString(SkString* str) const { |
135 str->appendf("SkImageSource: ("); | 131 str->appendf("SkImageSource: ("); |
136 str->appendf("src: (%f,%f,%f,%f) dst: (%f,%f,%f,%f) ", | 132 str->appendf("src: (%f,%f,%f,%f) dst: (%f,%f,%f,%f) ", |
137 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m, | 133 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m, |
138 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto
m); | 134 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto
m); |
139 str->appendf("image: (%d,%d)", | 135 str->appendf("image: (%d,%d)", |
140 fImage->width(), fImage->height()); | 136 fImage->width(), fImage->height()); |
141 str->append(")"); | 137 str->append(")"); |
142 } | 138 } |
143 #endif | 139 #endif |
OLD | NEW |