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

Side by Side Diff: gm/etc1bitmap.cpp

Issue 1516833003: Switch SkAutoMalloc to SkAutoTMalloc to avoid cast (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Go back to patch set 3 Created 5 years 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 | « gm/colorcube.cpp ('k') | include/effects/SkColorCubeFilter.h » ('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 2014 Google Inc. 2 * Copyright 2014 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 "gm.h" 8 #include "gm.h"
9 9
10 #include "Resources.h" 10 #include "Resources.h"
11 #include "SkCanvas.h" 11 #include "SkCanvas.h"
12 #include "SkData.h" 12 #include "SkData.h"
13 #include "SkImageGenerator.h" 13 #include "SkImageGenerator.h"
14 #include "SkImageDecoder.h" 14 #include "SkImageDecoder.h"
15 #include "SkOSFile.h" 15 #include "SkOSFile.h"
16 #include "SkTemplates.h"
16 17
17 #ifndef SK_IGNORE_ETC1_SUPPORT 18 #ifndef SK_IGNORE_ETC1_SUPPORT
18 19
19 #include "etc1.h" 20 #include "etc1.h"
20 21
21 /** 22 /**
22 * Remove the last row and column of ETC1 blocks, effectively 23 * Remove the last row and column of ETC1 blocks, effectively
23 * making a texture that started as power of two into a texture 24 * making a texture that started as power of two into a texture
24 * that is no longer power of two... 25 * that is no longer power of two...
25 */ 26 */
(...skipping 13 matching lines...) Expand all
39 40
40 // Make sure that we have blocks to trim off.. 41 // Make sure that we have blocks to trim off..
41 if (blockWidth < 2 || blockHeight < 2) { 42 if (blockWidth < 2 || blockHeight < 2) {
42 return false; 43 return false;
43 } 44 }
44 45
45 int newWidth = (blockWidth - 1) << 2; 46 int newWidth = (blockWidth - 1) << 2;
46 int newHeight = (blockHeight - 1) << 2; 47 int newHeight = (blockHeight - 1) << 2;
47 48
48 size_t newDataSz = etc1_get_encoded_data_size(newWidth, newHeight) + ETC_PKM _HEADER_SIZE; 49 size_t newDataSz = etc1_get_encoded_data_size(newWidth, newHeight) + ETC_PKM _HEADER_SIZE;
49 SkAutoMalloc am(newDataSz); 50 SkAutoTMalloc<etc1_byte> am(newDataSz);
50 51
51 etc1_byte *newData = reinterpret_cast<etc1_byte *>(am.get()); 52 etc1_byte* newData = am.get();
52 53
53 etc1_pkm_format_header(newData, newWidth, newHeight); 54 etc1_pkm_format_header(newData, newWidth, newHeight);
54 newData += ETC_PKM_HEADER_SIZE; 55 newData += ETC_PKM_HEADER_SIZE;
55 origData += ETC_PKM_HEADER_SIZE; 56 origData += ETC_PKM_HEADER_SIZE;
56 57
57 for (int j = 0; j < blockHeight - 1; ++j) { 58 for (int j = 0; j < blockHeight - 1; ++j) {
58 memcpy(newData, origData, (blockWidth - 1)*ETC1_ENCODED_BLOCK_SIZE); 59 memcpy(newData, origData, (blockWidth - 1)*ETC1_ENCODED_BLOCK_SIZE);
59 origData += blockWidth*ETC1_ENCODED_BLOCK_SIZE; 60 origData += blockWidth*ETC1_ENCODED_BLOCK_SIZE;
60 newData += (blockWidth - 1)*ETC1_ENCODED_BLOCK_SIZE; 61 newData += (blockWidth - 1)*ETC1_ENCODED_BLOCK_SIZE;
61 } 62 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 212
212 ////////////////////////////////////////////////////////////////////////////// 213 //////////////////////////////////////////////////////////////////////////////
213 214
214 DEF_GM(return new skiagm::ETC1Bitmap_PKM_GM;) 215 DEF_GM(return new skiagm::ETC1Bitmap_PKM_GM;)
215 DEF_GM(return new skiagm::ETC1Bitmap_KTX_GM;) 216 DEF_GM(return new skiagm::ETC1Bitmap_KTX_GM;)
216 DEF_GM(return new skiagm::ETC1Bitmap_R11_KTX_GM;) 217 DEF_GM(return new skiagm::ETC1Bitmap_R11_KTX_GM;)
217 218
218 #ifndef SK_IGNORE_ETC1_SUPPORT 219 #ifndef SK_IGNORE_ETC1_SUPPORT
219 DEF_GM(return new skiagm::ETC1Bitmap_NPOT_GM;) 220 DEF_GM(return new skiagm::ETC1Bitmap_NPOT_GM;)
220 #endif // SK_IGNORE_ETC1_SUPPORT 221 #endif // SK_IGNORE_ETC1_SUPPORT
OLDNEW
« no previous file with comments | « gm/colorcube.cpp ('k') | include/effects/SkColorCubeFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698