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

Side by Side Diff: components/image_fetcher/ios/webp_decoder.mm

Issue 2521253002: Move ImageFetcher to its own target. (Closed)
Patch Set: Cleanup Created 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ios/chrome/browser/webp_transcode/webp_decoder.h" 5 #include "components/image_fetcher/ios/webp_decoder.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #import <UIKit/UIKit.h> 9 #import <UIKit/UIKit.h>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 13
14 namespace { 14 namespace {
15 15
(...skipping 18 matching lines...) Expand all
34 34
35 void WriteTiffHeader(uint8_t* dst, 35 void WriteTiffHeader(uint8_t* dst,
36 int width, 36 int width,
37 int height, 37 int height,
38 int bytes_per_px, 38 int bytes_per_px,
39 bool has_alpha) { 39 bool has_alpha) {
40 // For non-alpha case, we omit tag 0x152 (ExtraSamples). 40 // For non-alpha case, we omit tag 0x152 (ExtraSamples).
41 const uint8_t num_ifd_entries = 41 const uint8_t num_ifd_entries =
42 has_alpha ? kNumIfdEntries : kNumIfdEntries - 1; 42 has_alpha ? kNumIfdEntries : kNumIfdEntries - 1;
43 uint8_t tiff_header[kHeaderSize] = { 43 uint8_t tiff_header[kHeaderSize] = {
44 0x49, 0x49, 0x2a, 0x00, // little endian signature 44 0x49, 0x49, 0x2a, 0x00, // little endian signature
45 8, 0, 0, 0, // offset to the unique IFD that follows 45 8, 0, 0, 0, // offset to the unique IFD that follows
46 // IFD (offset = 8). Entries must be written in increasing tag order. 46 // IFD (offset = 8). Entries must be written in increasing tag order.
47 num_ifd_entries, 0, // Number of entries in the IFD (12 bytes each). 47 num_ifd_entries, 0, // Number of entries in the IFD (12 bytes each).
48 0x00, 0x01, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, // 10: Width (TBD) 48 0x00, 0x01, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, // 10: Width (TBD)
49 0x01, 0x01, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, // 22: Height (TBD) 49 0x01, 0x01, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, // 22: Height (TBD)
50 0x02, 0x01, 3, 0, bytes_per_px, 0, 0, 0, // 34: BitsPerSample: 8888 50 0x02, 0x01, 3, 0, bytes_per_px, 0, 0, 0, // 34: BitsPerSample: 8888
51 kExtraDataOffset + 0, 0, 0, 0, 51 kExtraDataOffset + 0, 0, 0, 0, 0x03, 0x01, 3, 0, 1, 0, 0, 0, 1, 0, 0,
52 0x03, 0x01, 3, 0, 1, 0, 0, 0, 1, 0, 0, 0, // 46: Compression: none 52 0, // 46: Compression: none
53 0x06, 0x01, 3, 0, 1, 0, 0, 0, 2, 0, 0, 0, // 58: Photometric: RGB 53 0x06, 0x01, 3, 0, 1, 0, 0, 0, 2, 0, 0, 0, // 58: Photometric: RGB
54 0x11, 0x01, 4, 0, 1, 0, 0, 0, // 70: Strips offset: 54 0x11, 0x01, 4, 0, 1, 0, 0, 0, // 70: Strips offset:
55 kHeaderSize, 0, 0, 0, // data follows header 55 kHeaderSize, 0, 0, 0, // data follows header
56 0x12, 0x01, 3, 0, 1, 0, 0, 0, 1, 0, 0, 0, // 82: Orientation: topleft 56 0x12, 0x01, 3, 0, 1, 0, 0, 0, 1, 0, 0, 0, // 82: Orientation: topleft
57 0x15, 0x01, 3, 0, 1, 0, 0, 0, // 94: SamplesPerPixels 57 0x15, 0x01, 3, 0, 1, 0, 0, 0, // 94: SamplesPerPixels
58 bytes_per_px, 0, 0, 0, 58 bytes_per_px, 0, 0, 0, 0x16, 0x01, 3, 0, 1, 0, 0, 0, 0, 0, 0,
59 0x16, 0x01, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, // 106: Rows per strip (TBD) 59 0, // 106: Rows per strip (TBD)
60 0x17, 0x01, 4, 0, 1, 0, 0, 0, 0, 0, 0, 0, // 118: StripByteCount (TBD) 60 0x17, 0x01, 4, 0, 1, 0, 0, 0, 0, 0, 0, 0, // 118: StripByteCount (TBD)
61 0x1a, 0x01, 5, 0, 1, 0, 0, 0, // 130: X-resolution 61 0x1a, 0x01, 5, 0, 1, 0, 0, 0, // 130: X-resolution
62 kExtraDataOffset + 8, 0, 0, 0, 62 kExtraDataOffset + 8, 0, 0, 0, 0x1b, 0x01, 5, 0, 1, 0, 0,
63 0x1b, 0x01, 5, 0, 1, 0, 0, 0, // 142: Y-resolution 63 0, // 142: Y-resolution
64 kExtraDataOffset + 8, 0, 0, 0, 64 kExtraDataOffset + 8, 0, 0, 0, 0x1c, 0x01, 3, 0, 1, 0, 0, 0, 1, 0, 0,
65 0x1c, 0x01, 3, 0, 1, 0, 0, 0, 1, 0, 0, 0, // 154: PlanarConfiguration 65 0, // 154: PlanarConfiguration
66 0x28, 0x01, 3, 0, 1, 0, 0, 0, 2, 0, 0, 0, // 166: ResolutionUnit (inch) 66 0x28, 0x01, 3, 0, 1, 0, 0, 0, 2, 0, 0, 0, // 166: ResolutionUnit (inch)
67 0x52, 0x01, 3, 0, 1, 0, 0, 0, 1, 0, 0, 0, // 178: ExtraSamples: rgbA 67 0x52, 0x01, 3, 0, 1, 0, 0, 0, 1, 0, 0, 0, // 178: ExtraSamples: rgbA
68 0, 0, 0, 0, // 190: IFD terminator 68 0, 0, 0, 0, // 190: IFD terminator
69 // kExtraDataOffset: 69 // kExtraDataOffset:
70 8, 0, 8, 0, 8, 0, 8, 0, // BitsPerSample 70 8, 0, 8, 0, 8, 0, 8, 0, // BitsPerSample
71 72, 0, 0, 0, 1, 0, 0, 0 // 72 pixels/inch, for X/Y-resolution 71 72, 0, 0, 0, 1, 0, 0, 0 // 72 pixels/inch, for X/Y-resolution
72 }; 72 };
73 73
74 // Fill placeholders in IFD: 74 // Fill placeholders in IFD:
75 PutLE32(tiff_header + 10 + 8, width); 75 PutLE32(tiff_header + 10 + 8, width);
76 PutLE32(tiff_header + 22 + 8, height); 76 PutLE32(tiff_header + 22 + 8, height);
77 PutLE32(tiff_header + 106 + 8, height); 77 PutLE32(tiff_header + 106 + 8, height);
78 PutLE32(tiff_header + 118 + 8, width * bytes_per_px * height); 78 PutLE32(tiff_header + 118 + 8, width * bytes_per_px * height);
79 if (!has_alpha) 79 if (!has_alpha)
80 PutLE32(tiff_header + 178, 0); 80 PutLE32(tiff_header + 178, 0);
81 81
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } 243 }
244 UMA_HISTOGRAM_ENUMERATION("WebP.DecodedImageFormat", format, 244 UMA_HISTOGRAM_ENUMERATION("WebP.DecodedImageFormat", format,
245 DECODED_FORMAT_COUNT); 245 DECODED_FORMAT_COUNT);
246 delegate_->SetImageFeatures([result_data length], format); 246 delegate_->SetImageFeatures([result_data length], format);
247 delegate_->OnDataDecoded(result_data); 247 delegate_->OnDataDecoded(result_data);
248 output_buffer_.reset(); 248 output_buffer_.reset();
249 return true; 249 return true;
250 } 250 }
251 251
252 } // namespace webp_transcode 252 } // namespace webp_transcode
OLDNEW
« no previous file with comments | « components/image_fetcher/ios/webp_decoder.h ('k') | components/image_fetcher/ios/webp_decoder_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698