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

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

Issue 540033002: use tryAllocPixels to check the result, allocPixels to require success (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
« no previous file with comments | « Source/platform/graphics/gpu/DrawingBuffer.cpp ('k') | Source/web/tests/WebFrameTest.cpp » ('j') | 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) 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 m_bitmap.reset(); 100 m_bitmap.reset();
101 return other.m_bitmap.copyTo(&m_bitmap, other.m_bitmap.colorType()); 101 return other.m_bitmap.copyTo(&m_bitmap, other.m_bitmap.colorType());
102 } 102 }
103 103
104 bool ImageFrame::setSize(int newWidth, int newHeight) 104 bool ImageFrame::setSize(int newWidth, int newHeight)
105 { 105 {
106 // setSize() should only be called once, it leaks memory otherwise. 106 // setSize() should only be called once, it leaks memory otherwise.
107 ASSERT(!width() && !height()); 107 ASSERT(!width() && !height());
108 108
109 m_bitmap.setInfo(SkImageInfo::MakeN32Premul(newWidth, newHeight)); 109 m_bitmap.setInfo(SkImageInfo::MakeN32Premul(newWidth, newHeight));
110 if (!m_bitmap.allocPixels(m_allocator, 0)) 110 if (!m_bitmap.tryAllocPixels(m_allocator, 0))
111 return false; 111 return false;
112 112
113 zeroFillPixelData(); 113 zeroFillPixelData();
114 return true; 114 return true;
115 } 115 }
116 116
117 PassRefPtr<NativeImageSkia> ImageFrame::asNewNativeImage() const 117 PassRefPtr<NativeImageSkia> ImageFrame::asNewNativeImage() const
118 { 118 {
119 return NativeImageSkia::create(m_bitmap); 119 return NativeImageSkia::create(m_bitmap);
120 } 120 }
(...skipping 30 matching lines...) Expand all
151 void ImageFrame::zeroFillFrameRect(const IntRect& rect) 151 void ImageFrame::zeroFillFrameRect(const IntRect& rect)
152 { 152 {
153 if (rect.isEmpty()) 153 if (rect.isEmpty())
154 return; 154 return;
155 155
156 m_bitmap.eraseArea(rect, SkColorSetARGB(0, 0, 0, 0)); 156 m_bitmap.eraseArea(rect, SkColorSetARGB(0, 0, 0, 0));
157 setHasAlpha(true); 157 setHasAlpha(true);
158 } 158 }
159 159
160 } // namespace blink 160 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/graphics/gpu/DrawingBuffer.cpp ('k') | Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698