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

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

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 * 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 14 matching lines...) Expand all
25 25
26 #include "platform/graphics/DecodingImageGenerator.h" 26 #include "platform/graphics/DecodingImageGenerator.h"
27 27
28 #include "platform/PlatformInstrumentation.h" 28 #include "platform/PlatformInstrumentation.h"
29 #include "platform/SharedBuffer.h" 29 #include "platform/SharedBuffer.h"
30 #include "platform/TraceEvent.h" 30 #include "platform/TraceEvent.h"
31 #include "platform/graphics/ImageFrameGenerator.h" 31 #include "platform/graphics/ImageFrameGenerator.h"
32 #include "platform/image-decoders/ImageDecoder.h" 32 #include "platform/image-decoders/ImageDecoder.h"
33 #include "platform/image-decoders/SegmentReader.h" 33 #include "platform/image-decoders/SegmentReader.h"
34 #include "third_party/skia/include/core/SkData.h" 34 #include "third_party/skia/include/core/SkData.h"
35 #include <memory>
36 35
37 namespace blink { 36 namespace blink {
38 37
39 DecodingImageGenerator::DecodingImageGenerator(PassRefPtr<ImageFrameGenerator> f rameGenerator, const SkImageInfo& info, PassRefPtr<SegmentReader> data, bool all DataReceived, size_t index, uint32_t uniqueID) 38 DecodingImageGenerator::DecodingImageGenerator(PassRefPtr<ImageFrameGenerator> f rameGenerator, const SkImageInfo& info, PassRefPtr<SegmentReader> data, bool all DataReceived, size_t index, uint32_t uniqueID)
40 : SkImageGenerator(info, uniqueID) 39 : SkImageGenerator(info, uniqueID)
41 , m_frameGenerator(frameGenerator) 40 , m_frameGenerator(frameGenerator)
42 , m_data(data) 41 , m_data(data)
43 , m_allDataReceived(allDataReceived) 42 , m_allDataReceived(allDataReceived)
44 , m_frameIndex(index) 43 , m_frameIndex(index)
45 , m_canYUVDecode(false) 44 , m_canYUVDecode(false)
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 bool decoded = m_frameGenerator->decodeToYUV(m_data.get(), m_frameIndex, siz eInfo.fSizes, planes, sizeInfo.fWidthBytes); 102 bool decoded = m_frameGenerator->decodeToYUV(m_data.get(), m_frameIndex, siz eInfo.fSizes, planes, sizeInfo.fWidthBytes);
104 PlatformInstrumentation::didDecodeLazyPixelRef(); 103 PlatformInstrumentation::didDecodeLazyPixelRef();
105 104
106 return decoded; 105 return decoded;
107 } 106 }
108 107
109 SkImageGenerator* DecodingImageGenerator::create(SkData* data) 108 SkImageGenerator* DecodingImageGenerator::create(SkData* data)
110 { 109 {
111 // We just need the size of the image, so we have to temporarily create an I mageDecoder. Since 110 // We just need the size of the image, so we have to temporarily create an I mageDecoder. Since
112 // we only need the size, it doesn't really matter about premul or not, or g amma settings. 111 // we only need the size, it doesn't really matter about premul or not, or g amma settings.
113 std::unique_ptr<ImageDecoder> decoder = ImageDecoder::create(static_cast<con st char*>(data->data()), data->size(), 112 OwnPtr<ImageDecoder> decoder = ImageDecoder::create(static_cast<const char*> (data->data()), data->size(),
114 ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileAppl ied); 113 ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileAppl ied);
115 if (!decoder) 114 if (!decoder)
116 return 0; 115 return 0;
117 116
118 // Blink does not know Skia has already adopted |data|. 117 // Blink does not know Skia has already adopted |data|.
119 WTF::adopted(data); 118 WTF::adopted(data);
120 RefPtr<SegmentReader> segmentReader = SegmentReader::createFromSkData(data); 119 RefPtr<SegmentReader> segmentReader = SegmentReader::createFromSkData(data);
121 decoder->setData(segmentReader.get(), true); 120 decoder->setData(segmentReader.get(), true);
122 if (!decoder->isSizeAvailable()) 121 if (!decoder->isSizeAvailable())
123 return 0; 122 return 0;
124 123
125 const IntSize size = decoder->size(); 124 const IntSize size = decoder->size();
126 const SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.heigh t()); 125 const SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.heigh t());
127 126
128 RefPtr<ImageFrameGenerator> frame = ImageFrameGenerator::create(SkISize::Mak e(size.width(), size.height()), false); 127 RefPtr<ImageFrameGenerator> frame = ImageFrameGenerator::create(SkISize::Mak e(size.width(), size.height()), false);
129 if (!frame) 128 if (!frame)
130 return 0; 129 return 0;
131 130
132 return new DecodingImageGenerator(frame, info, segmentReader.release(), true , 0); 131 return new DecodingImageGenerator(frame, info, segmentReader.release(), true , 0);
133 } 132 }
134 133
135 } // namespace blink 134 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698