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

Side by Side Diff: third_party/WebKit/Source/core/frame/ImageBitmap.cpp

Issue 1423513005: Reland of: Make Imagebitmap Transferable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: should-work code Created 5 years 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 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/frame/ImageBitmap.h" 6 #include "core/frame/ImageBitmap.h"
7 7
8 #include "core/html/HTMLCanvasElement.h" 8 #include "core/html/HTMLCanvasElement.h"
9 #include "core/html/HTMLVideoElement.h" 9 #include "core/html/HTMLVideoElement.h"
10 #include "core/html/ImageData.h" 10 #include "core/html/ImageData.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 ImageBitmap::ImageBitmap(ImageBitmap* bitmap, const IntRect& cropRect) 99 ImageBitmap::ImageBitmap(ImageBitmap* bitmap, const IntRect& cropRect)
100 { 100 {
101 m_image = cropImage(bitmap->bitmapImage(), cropRect); 101 m_image = cropImage(bitmap->bitmapImage(), cropRect);
102 } 102 }
103 103
104 ImageBitmap::ImageBitmap(Image* image, const IntRect& cropRect) 104 ImageBitmap::ImageBitmap(Image* image, const IntRect& cropRect)
105 { 105 {
106 m_image = cropImage(static_cast<StaticBitmapImage*>(image), cropRect); 106 m_image = cropImage(static_cast<StaticBitmapImage*>(image), cropRect);
107 } 107 }
108 108
109 ImageBitmap::ImageBitmap(PassRefPtr<StaticBitmapImage> image)
110 {
111 m_image = image;
112 }
113
114 PassRefPtr<StaticBitmapImage> ImageBitmap::transfer()
115 {
116 ASSERT(!isNeutered());
117 m_isNeutered = true;
118 return m_image.release();
119 }
120
109 ImageBitmap::~ImageBitmap() 121 ImageBitmap::~ImageBitmap()
110 { 122 {
111 } 123 }
112 124
113 PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(HTMLImageElement* image, const IntRect& cropRect) 125 PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(HTMLImageElement* image, const IntRect& cropRect)
114 { 126 {
115 IntRect normalizedCropRect = normalizeRect(cropRect); 127 IntRect normalizedCropRect = normalizeRect(cropRect);
116 return adoptRefWillBeNoop(new ImageBitmap(image, normalizedCropRect)); 128 return adoptRefWillBeNoop(new ImageBitmap(image, normalizedCropRect));
117 } 129 }
118 130
(...skipping 20 matching lines...) Expand all
139 IntRect normalizedCropRect = normalizeRect(cropRect); 151 IntRect normalizedCropRect = normalizeRect(cropRect);
140 return adoptRefWillBeNoop(new ImageBitmap(bitmap, normalizedCropRect)); 152 return adoptRefWillBeNoop(new ImageBitmap(bitmap, normalizedCropRect));
141 } 153 }
142 154
143 PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(Image* image, const IntR ect& cropRect) 155 PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(Image* image, const IntR ect& cropRect)
144 { 156 {
145 IntRect normalizedCropRect = normalizeRect(cropRect); 157 IntRect normalizedCropRect = normalizeRect(cropRect);
146 return adoptRefWillBeNoop(new ImageBitmap(image, normalizedCropRect)); 158 return adoptRefWillBeNoop(new ImageBitmap(image, normalizedCropRect));
147 } 159 }
148 160
161 PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(PassRefPtr<StaticBitmapI mage> image)
162 {
163 return adoptRefWillBeNoop(new ImageBitmap(image));
164 }
165
149 unsigned long ImageBitmap::width() const 166 unsigned long ImageBitmap::width() const
150 { 167 {
151 if (!m_image) 168 if (!m_image)
152 return 0; 169 return 0;
153 ASSERT(m_image->width() > 0); 170 ASSERT(m_image->width() > 0);
154 return m_image->width(); 171 return m_image->width();
155 } 172 }
156 173
157 unsigned long ImageBitmap::height() const 174 unsigned long ImageBitmap::height() const
158 { 175 {
(...skipping 29 matching lines...) Expand all
188 { 205 {
189 return FloatSize(width(), height()); 206 return FloatSize(width(), height());
190 } 207 }
191 208
192 DEFINE_TRACE(ImageBitmap) 209 DEFINE_TRACE(ImageBitmap)
193 { 210 {
194 ImageLoaderClient::trace(visitor); 211 ImageLoaderClient::trace(visitor);
195 } 212 }
196 213
197 } // namespace blink 214 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/ImageBitmap.h ('k') | third_party/WebKit/Source/web/WebSerializedScriptValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698