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