OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 ImageSource source; | 50 ImageSource source; |
51 source.setData(PassRefPtr<SharedBuffer>(data).get(), true); | 51 source.setData(PassRefPtr<SharedBuffer>(data).get(), true); |
52 if (!source.isSizeAvailable()) | 52 if (!source.isSizeAvailable()) |
53 return WebImage(); | 53 return WebImage(); |
54 | 54 |
55 // Frames are arranged by decreasing size, then decreasing bit depth. | 55 // Frames are arranged by decreasing size, then decreasing bit depth. |
56 // Pick the frame closest to |desiredSize|'s area without being smaller, | 56 // Pick the frame closest to |desiredSize|'s area without being smaller, |
57 // which has the highest bit depth. | 57 // which has the highest bit depth. |
58 const size_t frameCount = source.frameCount(); | 58 const size_t frameCount = source.frameCount(); |
59 size_t index = 0; // Default to first frame if none are large enough. | 59 size_t index = 0; // Default to first frame if none are large enough. |
60 int frameAreaAtIndex; | 60 int frameAreaAtIndex = 0; |
61 for (size_t i = 0; i < frameCount; ++i) { | 61 for (size_t i = 0; i < frameCount; ++i) { |
62 const IntSize frameSize = source.frameSizeAtIndex(i); | 62 const IntSize frameSize = source.frameSizeAtIndex(i); |
63 if (WebSize(frameSize) == desiredSize) { | 63 if (WebSize(frameSize) == desiredSize) { |
64 index = i; | 64 index = i; |
65 break; // Perfect match. | 65 break; // Perfect match. |
66 } | 66 } |
67 | 67 |
68 const int frameArea = frameSize.width() * frameSize.height(); | 68 const int frameArea = frameSize.width() * frameSize.height(); |
69 if (frameArea < (desiredSize.width * desiredSize.height)) | 69 if (frameArea < (desiredSize.width * desiredSize.height)) |
70 break; // No more frames that are large enough. | 70 break; // No more frames that are large enough. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 { | 111 { |
112 NativeImagePtr p; | 112 NativeImagePtr p; |
113 if (image.get() && (p = image->nativeImageForCurrentFrame())) | 113 if (image.get() && (p = image->nativeImageForCurrentFrame())) |
114 assign(*p); | 114 assign(*p); |
115 else | 115 else |
116 reset(); | 116 reset(); |
117 return *this; | 117 return *this; |
118 } | 118 } |
119 | 119 |
120 } // namespace WebKit | 120 } // namespace WebKit |
OLD | NEW |