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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp

Issue 2326473005: Use sk_sp<SkBitmap::Allocator> instead of raw pointers or WTF::RefPtr<T>. (Closed)
Patch Set: Created 4 years, 3 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) 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) 2008, 2009 Google, Inc. 3 * Copyright (C) 2008, 2009 Google, Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
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 26
27 #include "platform/image-decoders/ImageFrame.h" 27 #include "platform/image-decoders/ImageFrame.h"
28 28
29 #include "platform/RuntimeEnabledFeatures.h" 29 #include "platform/RuntimeEnabledFeatures.h"
30 #include "platform/image-decoders/ImageDecoder.h" 30 #include "platform/image-decoders/ImageDecoder.h"
31 31
32 namespace blink { 32 namespace blink {
33 33
34 ImageFrame::ImageFrame() 34 ImageFrame::ImageFrame()
35 : m_allocator(0) 35 : m_allocator(nullptr)
36 , m_hasAlpha(true) 36 , m_hasAlpha(true)
37 , m_status(FrameEmpty) 37 , m_status(FrameEmpty)
38 , m_duration(0) 38 , m_duration(0)
39 , m_disposalMethod(DisposeNotSpecified) 39 , m_disposalMethod(DisposeNotSpecified)
40 , m_alphaBlendSource(BlendAtopPreviousFrame) 40 , m_alphaBlendSource(BlendAtopPreviousFrame)
41 , m_premultiplyAlpha(true) 41 , m_premultiplyAlpha(true)
42 , m_pixelsChanged(false) 42 , m_pixelsChanged(false)
43 , m_requiredPreviousFrameIndex(kNotFound) 43 , m_requiredPreviousFrameIndex(kNotFound)
44 { 44 {
45 } 45 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 { 100 {
101 // setSizeAndColorProfile() should only be called once, it leaks memory othe rwise. 101 // setSizeAndColorProfile() should only be called once, it leaks memory othe rwise.
102 ASSERT(!width() && !height()); 102 ASSERT(!width() && !height());
103 103
104 sk_sp<SkColorSpace> colorSpace; 104 sk_sp<SkColorSpace> colorSpace;
105 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled() && !newIccProfile .isEmpty()) 105 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled() && !newIccProfile .isEmpty())
106 colorSpace = SkColorSpace::NewICC(newIccProfile.data(), newIccProfile.si ze()); 106 colorSpace = SkColorSpace::NewICC(newIccProfile.data(), newIccProfile.si ze());
107 107
108 m_bitmap.setInfo(SkImageInfo::MakeN32(newWidth, newHeight, 108 m_bitmap.setInfo(SkImageInfo::MakeN32(newWidth, newHeight,
109 m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType, colorS pace)); 109 m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType, colorS pace));
110 if (!m_bitmap.tryAllocPixels(m_allocator, 0)) 110 if (!m_bitmap.tryAllocPixels(m_allocator.get(), 0))
111 return false; 111 return false;
112 112
113 zeroFillPixelData(); 113 zeroFillPixelData();
114 return true; 114 return true;
115 } 115 }
116 116
117 bool ImageFrame::hasAlpha() const 117 bool ImageFrame::hasAlpha() const
118 { 118 {
119 return m_hasAlpha; 119 return m_hasAlpha;
120 } 120 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // If the frame is not fully loaded, there will be transparent pixels, 152 // If the frame is not fully loaded, there will be transparent pixels,
153 // so we can't tell skia we're opaque, even for image types that logically 153 // so we can't tell skia we're opaque, even for image types that logically
154 // always are (e.g. jpeg). 154 // always are (e.g. jpeg).
155 if (!m_hasAlpha && m_status == FrameComplete) 155 if (!m_hasAlpha && m_status == FrameComplete)
156 return kOpaque_SkAlphaType; 156 return kOpaque_SkAlphaType;
157 157
158 return m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType; 158 return m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType;
159 } 159 }
160 160
161 } // namespace blink 161 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698