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 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 return SkData::NewWithCopy(buffer->data(), buffer->size()); | 58 return SkData::NewWithCopy(buffer->data(), buffer->size()); |
59 return 0; | 59 return 0; |
60 } | 60 } |
61 | 61 |
62 bool DecodingImageGenerator::onGetInfo(SkImageInfo* info) | 62 bool DecodingImageGenerator::onGetInfo(SkImageInfo* info) |
63 { | 63 { |
64 *info = m_imageInfo; | 64 *info = m_imageInfo; |
65 return true; | 65 return true; |
66 } | 66 } |
67 | 67 |
68 SkImageGenerator::Result DecodingImageGenerator::onGetPixels(const SkImageInfo&
info, void* pixels, size_t rowBytes, SkPMColor ctable[], int* ctableCount) | 68 bool DecodingImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels,
size_t rowBytes, SkPMColor ctable[], int* ctableCount) |
69 { | 69 { |
70 TRACE_EVENT1("blink", "DecodingImageGenerator::getPixels", "index", static_c
ast<int>(m_frameIndex)); | 70 TRACE_EVENT1("blink", "DecodingImageGenerator::getPixels", "index", static_c
ast<int>(m_frameIndex)); |
71 | 71 |
72 // Implementation doesn't support scaling yet so make sure we're not given a
different size. | 72 // Implementation doesn't support scaling yet so make sure we're not given a
different size. |
73 if (info.width() != m_imageInfo.width() || info.height() != m_imageInfo.heig
ht() || info.colorType() != m_imageInfo.colorType()) { | 73 if (info.width() != m_imageInfo.width() || info.height() != m_imageInfo.heig
ht() || info.colorType() != m_imageInfo.colorType()) { |
74 // ImageFrame may have changed the owning SkBitmap to kOpaque_SkAlphaTyp
e after sniffing the encoded data, so if we see a request | 74 // ImageFrame may have changed the owning SkBitmap to kOpaque_SkAlphaTyp
e after sniffing the encoded data, so if we see a request |
75 // for opaque, that is ok even if our initial alphatype was not opaque. | 75 // for opaque, that is ok even if our initial alphatype was not opaque. |
76 return Result::kInvalidScale; | 76 return false; |
77 } | 77 } |
78 | 78 |
79 bool decoded = m_frameGenerator->decodeAndScale(m_imageInfo, m_frameIndex, p
ixels, rowBytes); | 79 bool decoded = m_frameGenerator->decodeAndScale(m_imageInfo, m_frameIndex, p
ixels, rowBytes); |
80 return decoded ? Result::kSuccess : Result::kInvalidInput; | 80 return decoded; |
81 } | 81 } |
82 | 82 |
83 bool DecodingImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3],
size_t rowBytes[3]) | 83 bool DecodingImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3],
size_t rowBytes[3]) |
84 { | 84 { |
85 if (!planes || !planes[0]) { | 85 if (!planes || !planes[0]) { |
86 return m_frameGenerator->getYUVComponentSizes(sizes); | 86 return m_frameGenerator->getYUVComponentSizes(sizes); |
87 } | 87 } |
88 | 88 |
89 TRACE_EVENT0("blink", "DecodingImageGenerator::onGetYUV8Planes"); | 89 TRACE_EVENT0("blink", "DecodingImageGenerator::onGetYUV8Planes"); |
90 bool decoded = m_frameGenerator->decodeToYUV(planes, rowBytes); | 90 bool decoded = m_frameGenerator->decodeToYUV(planes, rowBytes); |
91 return decoded; | 91 return decoded; |
92 } | 92 } |
93 | 93 |
94 } // namespace blink | 94 } // namespace blink |
OLD | NEW |