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 "DMSrcSink.h" | 8 #include "DMSrcSink.h" |
9 #include "SamplePipeControllers.h" | 9 #include "SamplePipeControllers.h" |
10 #include "SkAndroidCodec.h" | 10 #include "SkAndroidCodec.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 const uint32_t height = brd->height(); | 121 const uint32_t height = brd->height(); |
122 // Visually inspecting very small output images is not necessary. | 122 // Visually inspecting very small output images is not necessary. |
123 if ((width / fSampleSize <= 10 || height / fSampleSize <= 10) && 1 != fSampl eSize) { | 123 if ((width / fSampleSize <= 10 || height / fSampleSize <= 10) && 1 != fSampl eSize) { |
124 return Error::Nonfatal("Scaling very small images is uninteresting."); | 124 return Error::Nonfatal("Scaling very small images is uninteresting."); |
125 } | 125 } |
126 switch (fMode) { | 126 switch (fMode) { |
127 case kFullImage_Mode: { | 127 case kFullImage_Mode: { |
128 SkBitmap bitmap; | 128 SkBitmap bitmap; |
129 if (!brd->decodeRegion(&bitmap, nullptr, SkIRect::MakeXYWH(0, 0, wid th, height), | 129 if (!brd->decodeRegion(&bitmap, nullptr, SkIRect::MakeXYWH(0, 0, wid th, height), |
130 fSampleSize, colorType, false)) { | 130 fSampleSize, colorType, false)) { |
131 return "Cannot decode region.\n"; | 131 return "Cannot decode (full) region.\n"; |
132 } | 132 } |
133 if (colorType != bitmap.colorType()) { | 133 if (colorType != bitmap.colorType()) { |
134 return Error::Nonfatal("Cannot convert to color type.\n"); | 134 return Error::Nonfatal("Cannot convert to color type.\n"); |
135 } | 135 } |
136 canvas->drawBitmap(bitmap, 0, 0); | 136 canvas->drawBitmap(bitmap, 0, 0); |
137 return ""; | 137 return ""; |
138 } | 138 } |
139 case kDivisor_Mode: { | 139 case kDivisor_Mode: { |
140 const uint32_t divisor = 2; | 140 const uint32_t divisor = 2; |
141 if (width < divisor || height < divisor) { | 141 if (width < divisor || height < divisor) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 subsetHeight += (y + 1 == divisor) ? (height % divisor) : 0; | 177 subsetHeight += (y + 1 == divisor) ? (height % divisor) : 0; |
178 | 178 |
179 // Increase the size of the subset in order to have a border on each side | 179 // Increase the size of the subset in order to have a border on each side |
180 const int decodeLeft = left - unscaledBorder; | 180 const int decodeLeft = left - unscaledBorder; |
181 const int decodeTop = top - unscaledBorder; | 181 const int decodeTop = top - unscaledBorder; |
182 const uint32_t decodeWidth = subsetWidth + unscaledBorder * 2; | 182 const uint32_t decodeWidth = subsetWidth + unscaledBorder * 2; |
183 const uint32_t decodeHeight = subsetHeight + unscaledBorder * 2; | 183 const uint32_t decodeHeight = subsetHeight + unscaledBorder * 2; |
184 SkBitmap bitmap; | 184 SkBitmap bitmap; |
185 if (!brd->decodeRegion(&bitmap, nullptr, SkIRect::MakeXYWH(d ecodeLeft, | 185 if (!brd->decodeRegion(&bitmap, nullptr, SkIRect::MakeXYWH(d ecodeLeft, |
186 decodeTop, decodeWidth, decodeHeight), fSampleSize, colorType, false)) { | 186 decodeTop, decodeWidth, decodeHeight), fSampleSize, colorType, false)) { |
187 return "Cannot not decode region.\n"; | 187 return "Cannot decode region.\n"; |
msarett
2015/11/03 21:22:50
Haha
| |
188 } | 188 } |
189 if (colorType != bitmap.colorType()) { | 189 if (colorType != bitmap.colorType()) { |
190 return Error::Nonfatal("Cannot convert to color type.\n" ); | 190 return Error::Nonfatal("Cannot convert to color type.\n" ); |
191 } | 191 } |
192 | 192 |
193 canvas->drawBitmapRect(bitmap, | 193 canvas->drawBitmapRect(bitmap, |
194 SkRect::MakeXYWH((SkScalar) scaledBorder, (SkScalar) scaledBorder, | 194 SkRect::MakeXYWH((SkScalar) scaledBorder, (SkScalar) scaledBorder, |
195 (SkScalar) (subsetWidth / fSampleSize), | 195 (SkScalar) (subsetWidth / fSampleSize), |
196 (SkScalar) (subsetHeight / fSampleSize)), | 196 (SkScalar) (subsetHeight / fSampleSize)), |
197 SkRect::MakeXYWH((SkScalar) (left / fSampleSize), | 197 SkRect::MakeXYWH((SkScalar) (left / fSampleSize), |
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1374 skr.visit<void>(i, drawsAsSingletonPictures); | 1374 skr.visit<void>(i, drawsAsSingletonPictures); |
1375 } | 1375 } |
1376 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); | 1376 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); |
1377 | 1377 |
1378 canvas->drawPicture(macroPic); | 1378 canvas->drawPicture(macroPic); |
1379 return ""; | 1379 return ""; |
1380 }); | 1380 }); |
1381 } | 1381 } |
1382 | 1382 |
1383 } // namespace DM | 1383 } // namespace DM |
OLD | NEW |