Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/gpu/SkGr.cpp

Issue 1882593002: Make is_ktx safer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/images/SkKTXImageEncoder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2010 Google Inc. 2 * Copyright 2010 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 8
9 #include "SkGr.h" 9 #include "SkGr.h"
10 #include "SkGrPriv.h" 10 #include "SkGrPriv.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // Does the data match the dimensions of the bitmap? If not, 80 // Does the data match the dimensions of the bitmap? If not,
81 // then we don't know how to scale the image to match it... 81 // then we don't know how to scale the image to match it...
82 if (etc1_pkm_get_width(bytes) != (unsigned)expectedW || 82 if (etc1_pkm_get_width(bytes) != (unsigned)expectedW ||
83 etc1_pkm_get_height(bytes) != (unsigned)expectedH) 83 etc1_pkm_get_height(bytes) != (unsigned)expectedH)
84 { 84 {
85 return kUnknown_GrPixelConfig; 85 return kUnknown_GrPixelConfig;
86 } 86 }
87 87
88 *outStartOfDataToUpload = bytes + ETC_PKM_HEADER_SIZE; 88 *outStartOfDataToUpload = bytes + ETC_PKM_HEADER_SIZE;
89 return kETC1_GrPixelConfig; 89 return kETC1_GrPixelConfig;
90 } else if (SkKTXFile::is_ktx(bytes)) { 90 } else if (SkKTXFile::is_ktx(bytes, data->size())) {
91 SkKTXFile ktx(data); 91 SkKTXFile ktx(data);
92 92
93 // Is it actually an ETC1 texture? 93 // Is it actually an ETC1 texture?
94 if (!ktx.isCompressedFormat(SkTextureCompressor::kETC1_Format)) { 94 if (!ktx.isCompressedFormat(SkTextureCompressor::kETC1_Format)) {
95 return kUnknown_GrPixelConfig; 95 return kUnknown_GrPixelConfig;
96 } 96 }
97 97
98 // Does the data match the dimensions of the bitmap? If not, 98 // Does the data match the dimensions of the bitmap? If not,
99 // then we don't know how to scale the image to match it... 99 // then we don't know how to scale the image to match it...
100 if (ktx.width() != expectedW || ktx.height() != expectedH) { 100 if (ktx.width() != expectedW || ktx.height() != expectedH) {
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 SkErrorInternals::SetError( kInvalidPaint_SkError, 756 SkErrorInternals::SetError( kInvalidPaint_SkError,
757 "Sorry, I don't understand the filtering " 757 "Sorry, I don't understand the filtering "
758 "mode you asked for. Falling back to " 758 "mode you asked for. Falling back to "
759 "MIPMaps."); 759 "MIPMaps.");
760 textureFilterMode = GrTextureParams::kMipMap_FilterMode; 760 textureFilterMode = GrTextureParams::kMipMap_FilterMode;
761 break; 761 break;
762 762
763 } 763 }
764 return textureFilterMode; 764 return textureFilterMode;
765 } 765 }
OLDNEW
« no previous file with comments | « no previous file | src/images/SkKTXImageEncoder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698