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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/ImageFrameGenerator.cpp

Issue 2398453002: Rewrap comments to 80 columns in Source/platform/graphics/. (Closed)
Patch Set: Review feedback Created 4 years, 2 months 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 /* 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 21 matching lines...) Expand all
32 #include "third_party/skia/include/core/SkYUVSizeInfo.h" 32 #include "third_party/skia/include/core/SkYUVSizeInfo.h"
33 #include "wtf/PtrUtil.h" 33 #include "wtf/PtrUtil.h"
34 #include <memory> 34 #include <memory>
35 35
36 namespace blink { 36 namespace blink {
37 37
38 static bool compatibleInfo(const SkImageInfo& src, const SkImageInfo& dst) { 38 static bool compatibleInfo(const SkImageInfo& src, const SkImageInfo& dst) {
39 if (src == dst) 39 if (src == dst)
40 return true; 40 return true;
41 41
42 // It is legal to write kOpaque_SkAlphaType pixels into a kPremul_SkAlphaType buffer. 42 // It is legal to write kOpaque_SkAlphaType pixels into a kPremul_SkAlphaType
43 // This can happen when DeferredImageDecoder allocates an kOpaque_SkAlphaType image 43 // buffer. This can happen when DeferredImageDecoder allocates an
44 // generator based on cached frame info, while the ImageFrame-allocated dest b itmap 44 // kOpaque_SkAlphaType image generator based on cached frame info, while the
45 // stays kPremul_SkAlphaType. 45 // ImageFrame-allocated dest bitmap stays kPremul_SkAlphaType.
46 if (src.alphaType() == kOpaque_SkAlphaType && 46 if (src.alphaType() == kOpaque_SkAlphaType &&
47 dst.alphaType() == kPremul_SkAlphaType) { 47 dst.alphaType() == kPremul_SkAlphaType) {
48 const SkImageInfo& tmp = src.makeAlphaType(kPremul_SkAlphaType); 48 const SkImageInfo& tmp = src.makeAlphaType(kPremul_SkAlphaType);
49 return tmp == dst; 49 return tmp == dst;
50 } 50 }
51 51
52 return false; 52 return false;
53 } 53 }
54 54
55 // Creates a SkPixelRef such that the memory for pixels is given by an external body. 55 // Creates a SkPixelRef such that the memory for pixels is given by an external
56 // This is used to write directly to the memory given by Skia during decoding. 56 // body. This is used to write directly to the memory given by Skia during
57 // decoding.
57 class ExternalMemoryAllocator final : public SkBitmap::Allocator { 58 class ExternalMemoryAllocator final : public SkBitmap::Allocator {
58 USING_FAST_MALLOC(ExternalMemoryAllocator); 59 USING_FAST_MALLOC(ExternalMemoryAllocator);
59 WTF_MAKE_NONCOPYABLE(ExternalMemoryAllocator); 60 WTF_MAKE_NONCOPYABLE(ExternalMemoryAllocator);
60 61
61 public: 62 public:
62 ExternalMemoryAllocator(const SkImageInfo& info, 63 ExternalMemoryAllocator(const SkImageInfo& info,
63 void* pixels, 64 void* pixels,
64 size_t rowBytes) 65 size_t rowBytes)
65 : m_info(info), m_pixels(pixels), m_rowBytes(rowBytes) {} 66 : m_info(info), m_pixels(pixels), m_rowBytes(rowBytes) {}
66 67
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 if (bitmap.getPixels() != pixels) 151 if (bitmap.getPixels() != pixels)
151 return bitmap.copyPixelsTo(pixels, rowBytes * info.height(), rowBytes); 152 return bitmap.copyPixelsTo(pixels, rowBytes * info.height(), rowBytes);
152 return true; 153 return true;
153 } 154 }
154 155
155 bool ImageFrameGenerator::decodeToYUV(SegmentReader* data, 156 bool ImageFrameGenerator::decodeToYUV(SegmentReader* data,
156 size_t index, 157 size_t index,
157 const SkISize componentSizes[3], 158 const SkISize componentSizes[3],
158 void* planes[3], 159 void* planes[3],
159 const size_t rowBytes[3]) { 160 const size_t rowBytes[3]) {
160 // TODO (scroggo): The only interesting thing this uses from the ImageFrameGen erator is m_decodeFailed. 161 // TODO (scroggo): The only interesting thing this uses from the
161 // Move this into DecodingImageGenerator, which is the only class that calls i t. 162 // ImageFrameGenerator is m_decodeFailed. Move this into
163 // DecodingImageGenerator, which is the only class that calls it.
162 if (m_decodeFailed) 164 if (m_decodeFailed)
163 return false; 165 return false;
164 166
165 TRACE_EVENT1("blink", "ImageFrameGenerator::decodeToYUV", "frame index", 167 TRACE_EVENT1("blink", "ImageFrameGenerator::decodeToYUV", "frame index",
166 static_cast<int>(index)); 168 static_cast<int>(index));
167 169
168 if (!planes || !planes[0] || !planes[1] || !planes[2] || !rowBytes || 170 if (!planes || !planes[0] || !planes[1] || !planes[2] || !rowBytes ||
169 !rowBytes[0] || !rowBytes[1] || !rowBytes[2]) { 171 !rowBytes[0] || !rowBytes[1] || !rowBytes[2]) {
170 return false; 172 return false;
171 } 173 }
172 174
173 std::unique_ptr<ImageDecoder> decoder = 175 std::unique_ptr<ImageDecoder> decoder =
174 ImageDecoder::create(data, true, ImageDecoder::AlphaPremultiplied, 176 ImageDecoder::create(data, true, ImageDecoder::AlphaPremultiplied,
175 ImageDecoder::GammaAndColorProfileApplied); 177 ImageDecoder::GammaAndColorProfileApplied);
176 // getYUVComponentSizes was already called and was successful, so ImageDecoder ::create must succeed. 178 // getYUVComponentSizes was already called and was successful, so
179 // ImageDecoder::create must succeed.
177 ASSERT(decoder); 180 ASSERT(decoder);
178 181
179 std::unique_ptr<ImagePlanes> imagePlanes = 182 std::unique_ptr<ImagePlanes> imagePlanes =
180 wrapUnique(new ImagePlanes(planes, rowBytes)); 183 wrapUnique(new ImagePlanes(planes, rowBytes));
181 decoder->setImagePlanes(std::move(imagePlanes)); 184 decoder->setImagePlanes(std::move(imagePlanes));
182 185
183 ASSERT(decoder->canDecodeToYUV()); 186 ASSERT(decoder->canDecodeToYUV());
184 187
185 if (decoder->decodeToYUV()) { 188 if (decoder->decodeToYUV()) {
186 setHasAlpha(0, false); // YUV is always opaque 189 setHasAlpha(0, false); // YUV is always opaque
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 363
361 if (m_yuvDecodingFailed) 364 if (m_yuvDecodingFailed)
362 return false; 365 return false;
363 366
364 std::unique_ptr<ImageDecoder> decoder = 367 std::unique_ptr<ImageDecoder> decoder =
365 ImageDecoder::create(data, true, ImageDecoder::AlphaPremultiplied, 368 ImageDecoder::create(data, true, ImageDecoder::AlphaPremultiplied,
366 ImageDecoder::GammaAndColorProfileApplied); 369 ImageDecoder::GammaAndColorProfileApplied);
367 if (!decoder) 370 if (!decoder)
368 return false; 371 return false;
369 372
370 // Setting a dummy ImagePlanes object signals to the decoder that we want to d o YUV decoding. 373 // Setting a dummy ImagePlanes object signals to the decoder that we want to
374 // do YUV decoding.
371 std::unique_ptr<ImagePlanes> dummyImagePlanes = wrapUnique(new ImagePlanes); 375 std::unique_ptr<ImagePlanes> dummyImagePlanes = wrapUnique(new ImagePlanes);
372 decoder->setImagePlanes(std::move(dummyImagePlanes)); 376 decoder->setImagePlanes(std::move(dummyImagePlanes));
373 377
374 return updateYUVComponentSizes(decoder.get(), sizeInfo->fSizes, 378 return updateYUVComponentSizes(decoder.get(), sizeInfo->fSizes,
375 sizeInfo->fWidthBytes); 379 sizeInfo->fWidthBytes);
376 } 380 }
377 381
378 } // namespace blink 382 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698