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

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

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

Powered by Google App Engine
This is Rietveld 408576698