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

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

Issue 2812853002: don't call deprecated copyPixelsTo (Closed)
Patch Set: compute exact bytes per row Created 3 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 17 matching lines...) Expand all
28 #include <memory> 28 #include <memory>
29 #include "SkData.h" 29 #include "SkData.h"
30 #include "platform/graphics/ImageDecodingStore.h" 30 #include "platform/graphics/ImageDecodingStore.h"
31 #include "platform/image-decoders/ImageDecoder.h" 31 #include "platform/image-decoders/ImageDecoder.h"
32 #include "platform/instrumentation/tracing/TraceEvent.h" 32 #include "platform/instrumentation/tracing/TraceEvent.h"
33 #include "platform/wtf/PtrUtil.h" 33 #include "platform/wtf/PtrUtil.h"
34 #include "third_party/skia/include/core/SkYUVSizeInfo.h" 34 #include "third_party/skia/include/core/SkYUVSizeInfo.h"
35 35
36 namespace blink { 36 namespace blink {
37 37
38 static void CopyPixels(void* dst_addr,
39 size_t dst_row_bytes,
40 const void* src_addr,
41 size_t src_row_bytes,
42 const SkImageInfo& info) {
43 size_t row_bytes = info.bytesPerPixel() * info.width();
44 for (int y = 0; y < info.height(); ++y) {
45 memcpy(dst_addr, src_addr, row_bytes);
46 src_addr = static_cast<const char*>(src_addr) + src_row_bytes;
47 dst_addr = static_cast<char*>(dst_addr) + dst_row_bytes;
48 }
49 }
50
38 static bool CompatibleInfo(const SkImageInfo& src, const SkImageInfo& dst) { 51 static bool CompatibleInfo(const SkImageInfo& src, const SkImageInfo& dst) {
39 if (src == dst) 52 if (src == dst)
40 return true; 53 return true;
41 54
42 // It is legal to write kOpaque_SkAlphaType pixels into a kPremul_SkAlphaType 55 // It is legal to write kOpaque_SkAlphaType pixels into a kPremul_SkAlphaType
43 // buffer. This can happen when DeferredImageDecoder allocates an 56 // buffer. This can happen when DeferredImageDecoder allocates an
44 // kOpaque_SkAlphaType image generator based on cached frame info, while the 57 // kOpaque_SkAlphaType image generator based on cached frame info, while the
45 // ImageFrame-allocated dest bitmap stays kPremul_SkAlphaType. 58 // ImageFrame-allocated dest bitmap stays kPremul_SkAlphaType.
46 if (src.alphaType() == kOpaque_SkAlphaType && 59 if (src.alphaType() == kOpaque_SkAlphaType &&
47 dst.alphaType() == kPremul_SkAlphaType) { 60 dst.alphaType() == kPremul_SkAlphaType) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 157
145 if (bitmap.isNull()) 158 if (bitmap.isNull())
146 return false; 159 return false;
147 160
148 // 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
149 // provided. If not, make a copy. 162 // provided. If not, make a copy.
150 ASSERT(bitmap.width() == scaled_size.width()); 163 ASSERT(bitmap.width() == scaled_size.width());
151 ASSERT(bitmap.height() == scaled_size.height()); 164 ASSERT(bitmap.height() == scaled_size.height());
152 SkAutoLockPixels bitmap_lock(bitmap); 165 SkAutoLockPixels bitmap_lock(bitmap);
153 if (bitmap.getPixels() != pixels) 166 if (bitmap.getPixels() != pixels)
154 return bitmap.copyPixelsTo(pixels, row_bytes * info.height(), row_bytes); 167 CopyPixels(pixels, row_bytes, bitmap.getPixels(), bitmap.rowBytes(), info);
155 return true; 168 return true;
156 } 169 }
157 170
158 bool ImageFrameGenerator::DecodeToYUV(SegmentReader* data, 171 bool ImageFrameGenerator::DecodeToYUV(SegmentReader* data,
159 size_t index, 172 size_t index,
160 const SkISize component_sizes[3], 173 const SkISize component_sizes[3],
161 void* planes[3], 174 void* planes[3],
162 const size_t row_bytes[3]) { 175 const size_t row_bytes[3]) {
163 // TODO (scroggo): The only interesting thing this uses from the 176 // TODO (scroggo): The only interesting thing this uses from the
164 // ImageFrameGenerator is m_decodeFailed. Move this into 177 // ImageFrameGenerator is m_decodeFailed. Move this into
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 // do YUV decoding. 395 // do YUV decoding.
383 std::unique_ptr<ImagePlanes> dummy_image_planes = 396 std::unique_ptr<ImagePlanes> dummy_image_planes =
384 WTF::WrapUnique(new ImagePlanes); 397 WTF::WrapUnique(new ImagePlanes);
385 decoder->SetImagePlanes(std::move(dummy_image_planes)); 398 decoder->SetImagePlanes(std::move(dummy_image_planes));
386 399
387 return UpdateYUVComponentSizes(decoder.get(), size_info->fSizes, 400 return UpdateYUVComponentSizes(decoder.get(), size_info->fSizes,
388 size_info->fWidthBytes); 401 size_info->fWidthBytes);
389 } 402 }
390 403
391 } // namespace blink 404 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698