| OLD | NEW |
| 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 "SkTextureCompressor.h" | 8 #include "SkTextureCompressor.h" |
| 9 #include "SkTextureCompressor_ASTC.h" | 9 #include "SkTextureCompressor_ASTC.h" |
| 10 #include "SkTextureCompressor_LATC.h" | 10 #include "SkTextureCompressor_LATC.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 | 168 |
| 169 if (proc) { | 169 if (proc) { |
| 170 return proc(dst, src, width, height, rowBytes); | 170 return proc(dst, src, width, height, rowBytes); |
| 171 } | 171 } |
| 172 | 172 |
| 173 return false; | 173 return false; |
| 174 } | 174 } |
| 175 | 175 |
| 176 SkData* CompressBitmapToFormat(const SkPixmap& pixmap, Format format) { | 176 SkData* CompressBitmapToFormat(const SkBitmap &bitmap, Format format) { |
| 177 int compressedDataSize = GetCompressedDataSize(format, pixmap.width(), pixma
p.height()); | 177 SkAutoLockPixels alp(bitmap); |
| 178 |
| 179 int compressedDataSize = GetCompressedDataSize(format, bitmap.width(), bitma
p.height()); |
| 178 if (compressedDataSize < 0) { | 180 if (compressedDataSize < 0) { |
| 179 return NULL; | 181 return NULL; |
| 180 } | 182 } |
| 181 | 183 |
| 182 const uint8_t* src = reinterpret_cast<const uint8_t*>(pixmap.addr()); | 184 const uint8_t* src = reinterpret_cast<const uint8_t*>(bitmap.getPixels()); |
| 183 SkData* dst = SkData::NewUninitialized(compressedDataSize); | 185 SkData* dst = SkData::NewUninitialized(compressedDataSize); |
| 184 | 186 |
| 185 if (!CompressBufferToFormat((uint8_t*)dst->writable_data(), src, pixmap.colo
rType(), | 187 if (!CompressBufferToFormat((uint8_t*)dst->writable_data(), src, bitmap.colo
rType(), |
| 186 pixmap.width(), pixmap.height(), pixmap.rowBytes
(), format)) { | 188 bitmap.width(), bitmap.height(), bitmap.rowBytes
(), format)) { |
| 187 dst->unref(); | 189 dst->unref(); |
| 188 dst = NULL; | 190 dst = NULL; |
| 189 } | 191 } |
| 190 return dst; | 192 return dst; |
| 191 } | 193 } |
| 192 | 194 |
| 193 SkBlitter* CreateBlitterForFormat(int width, int height, void* compressedBuffer, | 195 SkBlitter* CreateBlitterForFormat(int width, int height, void* compressedBuffer, |
| 194 SkTBlitterAllocator *allocator, Format format)
{ | 196 SkTBlitterAllocator *allocator, Format format)
{ |
| 195 switch(format) { | 197 switch(format) { |
| 196 case kLATC_Format: | 198 case kLATC_Format: |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 253 |
| 252 default: | 254 default: |
| 253 // Do nothing... | 255 // Do nothing... |
| 254 break; | 256 break; |
| 255 } | 257 } |
| 256 | 258 |
| 257 return false; | 259 return false; |
| 258 } | 260 } |
| 259 | 261 |
| 260 } // namespace SkTextureCompressor | 262 } // namespace SkTextureCompressor |
| OLD | NEW |