| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 default: | 138 default: |
| 139 break; | 139 break; |
| 140 } | 140 } |
| 141 if (proc && proc(dst, src, width, height, rowBytes)) { | 141 if (proc && proc(dst, src, width, height, rowBytes)) { |
| 142 return true; | 142 return true; |
| 143 } | 143 } |
| 144 | 144 |
| 145 return false; | 145 return false; |
| 146 } | 146 } |
| 147 | 147 |
| 148 SkData* CompressBitmapToFormat(const SkPixmap& pixmap, Format format) { | 148 sk_sp<SkData> CompressBitmapToFormat(const SkPixmap& pixmap, Format format) { |
| 149 int compressedDataSize = GetCompressedDataSize(format, pixmap.width(), pixma
p.height()); | 149 int compressedDataSize = GetCompressedDataSize(format, pixmap.width(), pixma
p.height()); |
| 150 if (compressedDataSize < 0) { | 150 if (compressedDataSize < 0) { |
| 151 return nullptr; | 151 return nullptr; |
| 152 } | 152 } |
| 153 | 153 |
| 154 const uint8_t* src = reinterpret_cast<const uint8_t*>(pixmap.addr()); | 154 const uint8_t* src = reinterpret_cast<const uint8_t*>(pixmap.addr()); |
| 155 SkData* dst = SkData::NewUninitialized(compressedDataSize); | 155 sk_sp<SkData> dst(SkData::MakeUninitialized(compressedDataSize)); |
| 156 | 156 |
| 157 if (!CompressBufferToFormat((uint8_t*)dst->writable_data(), src, pixmap.colo
rType(), | 157 if (!CompressBufferToFormat((uint8_t*)dst->writable_data(), src, pixmap.colo
rType(), |
| 158 pixmap.width(), pixmap.height(), pixmap.rowBytes
(), format)) { | 158 pixmap.width(), pixmap.height(), pixmap.rowBytes
(), format)) { |
| 159 dst->unref(); | 159 return nullptr; |
| 160 dst = nullptr; | |
| 161 } | 160 } |
| 162 return dst; | 161 return dst; |
| 163 } | 162 } |
| 164 | 163 |
| 165 SkBlitter* CreateBlitterForFormat(int width, int height, void* compressedBuffer, | 164 SkBlitter* CreateBlitterForFormat(int width, int height, void* compressedBuffer, |
| 166 SkTBlitterAllocator *allocator, Format format)
{ | 165 SkTBlitterAllocator *allocator, Format format)
{ |
| 167 switch(format) { | 166 switch(format) { |
| 168 case kLATC_Format: | 167 case kLATC_Format: |
| 169 return CreateLATCBlitter(width, height, compressedBuffer, allocator)
; | 168 return CreateLATCBlitter(width, height, compressedBuffer, allocator)
; |
| 170 | 169 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 222 |
| 224 default: | 223 default: |
| 225 // Do nothing... | 224 // Do nothing... |
| 226 break; | 225 break; |
| 227 } | 226 } |
| 228 | 227 |
| 229 return false; | 228 return false; |
| 230 } | 229 } |
| 231 | 230 |
| 232 } // namespace SkTextureCompressor | 231 } // namespace SkTextureCompressor |
| OLD | NEW |