| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 : info_(info), pixels_(pixels), row_bytes_(row_bytes) {} | 79 : info_(info), pixels_(pixels), row_bytes_(row_bytes) {} |
| 80 | 80 |
| 81 bool allocPixelRef(SkBitmap* dst, SkColorTable* ctable) override { | 81 bool allocPixelRef(SkBitmap* dst, SkColorTable* ctable) override { |
| 82 const SkImageInfo& info = dst->info(); | 82 const SkImageInfo& info = dst->info(); |
| 83 if (kUnknown_SkColorType == info.colorType()) | 83 if (kUnknown_SkColorType == info.colorType()) |
| 84 return false; | 84 return false; |
| 85 | 85 |
| 86 if (!CompatibleInfo(info_, info) || row_bytes_ != dst->rowBytes()) | 86 if (!CompatibleInfo(info_, info) || row_bytes_ != dst->rowBytes()) |
| 87 return false; | 87 return false; |
| 88 | 88 |
| 89 if (!dst->installPixels(info, pixels_, row_bytes_)) | 89 return dst->installPixels(info, pixels_, row_bytes_); |
| 90 return false; | |
| 91 dst->lockPixels(); | |
| 92 return true; | |
| 93 } | 90 } |
| 94 | 91 |
| 95 private: | 92 private: |
| 96 SkImageInfo info_; | 93 SkImageInfo info_; |
| 97 void* pixels_; | 94 void* pixels_; |
| 98 size_t row_bytes_; | 95 size_t row_bytes_; |
| 99 }; | 96 }; |
| 100 | 97 |
| 101 static bool UpdateYUVComponentSizes(ImageDecoder* decoder, | 98 static bool UpdateYUVComponentSizes(ImageDecoder* decoder, |
| 102 SkISize component_sizes[3], | 99 SkISize component_sizes[3], |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 &external_allocator, alpha_option); | 155 &external_allocator, alpha_option); |
| 159 DCHECK(external_allocator.unique()); // Verify we have the only ref-count. | 156 DCHECK(external_allocator.unique()); // Verify we have the only ref-count. |
| 160 | 157 |
| 161 if (bitmap.isNull()) | 158 if (bitmap.isNull()) |
| 162 return false; | 159 return false; |
| 163 | 160 |
| 164 // Check to see if the decoder has written directly to the pixel memory | 161 // Check to see if the decoder has written directly to the pixel memory |
| 165 // provided. If not, make a copy. | 162 // provided. If not, make a copy. |
| 166 DCHECK_EQ(bitmap.width(), scaled_size.width()); | 163 DCHECK_EQ(bitmap.width(), scaled_size.width()); |
| 167 DCHECK_EQ(bitmap.height(), scaled_size.height()); | 164 DCHECK_EQ(bitmap.height(), scaled_size.height()); |
| 168 SkAutoLockPixels bitmap_lock(bitmap); | |
| 169 if (bitmap.getPixels() != pixels) | 165 if (bitmap.getPixels() != pixels) |
| 170 CopyPixels(pixels, row_bytes, bitmap.getPixels(), bitmap.rowBytes(), info); | 166 CopyPixels(pixels, row_bytes, bitmap.getPixels(), bitmap.rowBytes(), info); |
| 171 return true; | 167 return true; |
| 172 } | 168 } |
| 173 | 169 |
| 174 bool ImageFrameGenerator::DecodeToYUV(SegmentReader* data, | 170 bool ImageFrameGenerator::DecodeToYUV(SegmentReader* data, |
| 175 size_t index, | 171 size_t index, |
| 176 const SkISize component_sizes[3], | 172 const SkISize component_sizes[3], |
| 177 void* planes[3], | 173 void* planes[3], |
| 178 const size_t row_bytes[3]) { | 174 const size_t row_bytes[3]) { |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 // do YUV decoding. | 397 // do YUV decoding. |
| 402 std::unique_ptr<ImagePlanes> dummy_image_planes = | 398 std::unique_ptr<ImagePlanes> dummy_image_planes = |
| 403 WTF::WrapUnique(new ImagePlanes); | 399 WTF::WrapUnique(new ImagePlanes); |
| 404 decoder->SetImagePlanes(std::move(dummy_image_planes)); | 400 decoder->SetImagePlanes(std::move(dummy_image_planes)); |
| 405 | 401 |
| 406 return UpdateYUVComponentSizes(decoder.get(), size_info->fSizes, | 402 return UpdateYUVComponentSizes(decoder.get(), size_info->fSizes, |
| 407 size_info->fWidthBytes); | 403 size_info->fWidthBytes); |
| 408 } | 404 } |
| 409 | 405 |
| 410 } // namespace blink | 406 } // namespace blink |
| OLD | NEW |