OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "ktx.h" | 9 #include "ktx.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 249 |
250 // We don't support texture arrays | 250 // We don't support texture arrays |
251 if (fHeader.fNumberOfArrayElements > 1) { | 251 if (fHeader.fNumberOfArrayElements > 1) { |
252 return false; | 252 return false; |
253 } | 253 } |
254 | 254 |
255 // We don't support cube maps | 255 // We don't support cube maps |
256 if (fHeader.fNumberOfFaces > 1) { | 256 if (fHeader.fNumberOfFaces > 1) { |
257 return false; | 257 return false; |
258 } | 258 } |
| 259 |
| 260 // We don't support width and/or height <= 0 |
| 261 if (fHeader.fPixelWidth <= 0 || fHeader.fPixelHeight <= 0) { |
| 262 return false; |
| 263 } |
259 } | 264 } |
260 | 265 |
261 // Make sure that we have enough bytes left for the key/value | 266 // Make sure that we have enough bytes left for the key/value |
262 // data according to what was said in the header. | 267 // data according to what was said in the header. |
263 if (bytesLeft < fHeader.fBytesOfKeyValueData) { | 268 if (bytesLeft < fHeader.fBytesOfKeyValueData) { |
264 return false; | 269 return false; |
265 } | 270 } |
266 | 271 |
267 // Next read the key value pairs | 272 // Next read the key value pairs |
268 size_t keyValueBytesRead = 0; | 273 size_t keyValueBytesRead = 0; |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 for (int i = 0; i < height; ++i) { | 550 for (int i = 0; i < height; ++i) { |
546 if (!stream->write(rowPtr, bpp*width)) { | 551 if (!stream->write(rowPtr, bpp*width)) { |
547 return false; | 552 return false; |
548 } | 553 } |
549 rowPtr += bitmap.rowBytes(); | 554 rowPtr += bitmap.rowBytes(); |
550 } | 555 } |
551 } | 556 } |
552 | 557 |
553 return true; | 558 return true; |
554 } | 559 } |
OLD | NEW |