| OLD | NEW |
| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 142 |
| 143 ScriptWrappable::init(this); | 143 ScriptWrappable::init(this); |
| 144 } | 144 } |
| 145 | 145 |
| 146 ImageBitmap::~ImageBitmap() | 146 ImageBitmap::~ImageBitmap() |
| 147 { | 147 { |
| 148 if (m_imageElement) | 148 if (m_imageElement) |
| 149 m_imageElement->removeClient(this); | 149 m_imageElement->removeClient(this); |
| 150 } | 150 } |
| 151 | 151 |
| 152 PassRefPtr<ImageBitmap> ImageBitmap::create(HTMLImageElement* image, const IntRe
ct& cropRect) | 152 PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(HTMLImageElement* image,
const IntRect& cropRect) |
| 153 { | 153 { |
| 154 IntRect normalizedCropRect = normalizeRect(cropRect); | 154 IntRect normalizedCropRect = normalizeRect(cropRect); |
| 155 return adoptRef(new ImageBitmap(image, normalizedCropRect)); | 155 return adoptRefWillBeNoop(new ImageBitmap(image, normalizedCropRect)); |
| 156 } | 156 } |
| 157 | 157 |
| 158 PassRefPtr<ImageBitmap> ImageBitmap::create(HTMLVideoElement* video, const IntRe
ct& cropRect) | 158 PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(HTMLVideoElement* video,
const IntRect& cropRect) |
| 159 { | 159 { |
| 160 IntRect normalizedCropRect = normalizeRect(cropRect); | 160 IntRect normalizedCropRect = normalizeRect(cropRect); |
| 161 return adoptRef(new ImageBitmap(video, normalizedCropRect)); | 161 return adoptRefWillBeNoop(new ImageBitmap(video, normalizedCropRect)); |
| 162 } | 162 } |
| 163 | 163 |
| 164 PassRefPtr<ImageBitmap> ImageBitmap::create(HTMLCanvasElement* canvas, const Int
Rect& cropRect) | 164 PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(HTMLCanvasElement* canva
s, const IntRect& cropRect) |
| 165 { | 165 { |
| 166 IntRect normalizedCropRect = normalizeRect(cropRect); | 166 IntRect normalizedCropRect = normalizeRect(cropRect); |
| 167 return adoptRef(new ImageBitmap(canvas, normalizedCropRect)); | 167 return adoptRefWillBeNoop(new ImageBitmap(canvas, normalizedCropRect)); |
| 168 } | 168 } |
| 169 | 169 |
| 170 PassRefPtr<ImageBitmap> ImageBitmap::create(ImageData* data, const IntRect& crop
Rect) | 170 PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(ImageData* data, const I
ntRect& cropRect) |
| 171 { | 171 { |
| 172 IntRect normalizedCropRect = normalizeRect(cropRect); | 172 IntRect normalizedCropRect = normalizeRect(cropRect); |
| 173 return adoptRef(new ImageBitmap(data, normalizedCropRect)); | 173 return adoptRefWillBeNoop(new ImageBitmap(data, normalizedCropRect)); |
| 174 } | 174 } |
| 175 | 175 |
| 176 PassRefPtr<ImageBitmap> ImageBitmap::create(ImageBitmap* bitmap, const IntRect&
cropRect) | 176 PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(ImageBitmap* bitmap, con
st IntRect& cropRect) |
| 177 { | 177 { |
| 178 IntRect normalizedCropRect = normalizeRect(cropRect); | 178 IntRect normalizedCropRect = normalizeRect(cropRect); |
| 179 return adoptRef(new ImageBitmap(bitmap, normalizedCropRect)); | 179 return adoptRefWillBeNoop(new ImageBitmap(bitmap, normalizedCropRect)); |
| 180 } | 180 } |
| 181 | 181 |
| 182 PassRefPtr<ImageBitmap> ImageBitmap::create(Image* image, const IntRect& cropRec
t) | 182 PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(Image* image, const IntR
ect& cropRect) |
| 183 { | 183 { |
| 184 IntRect normalizedCropRect = normalizeRect(cropRect); | 184 IntRect normalizedCropRect = normalizeRect(cropRect); |
| 185 return adoptRef(new ImageBitmap(image, normalizedCropRect)); | 185 return adoptRefWillBeNoop(new ImageBitmap(image, normalizedCropRect)); |
| 186 } | 186 } |
| 187 | 187 |
| 188 void ImageBitmap::notifyImageSourceChanged() | 188 void ImageBitmap::notifyImageSourceChanged() |
| 189 { | 189 { |
| 190 m_bitmap = cropImage(m_imageElement->cachedImage()->image(), m_cropRect); | 190 m_bitmap = cropImage(m_imageElement->cachedImage()->image(), m_cropRect); |
| 191 m_bitmapOffset = IntPoint(); | 191 m_bitmapOffset = IntPoint(); |
| 192 m_imageElement = nullptr; | 192 m_imageElement = nullptr; |
| 193 } | 193 } |
| 194 | 194 |
| 195 PassRefPtr<Image> ImageBitmap::bitmapImage() const | 195 PassRefPtr<Image> ImageBitmap::bitmapImage() const |
| (...skipping 21 matching lines...) Expand all Loading... |
| 217 newDstRect.moveBy(dstRect->location()); | 217 newDstRect.moveBy(dstRect->location()); |
| 218 *srcRect = newSrcRect; | 218 *srcRect = newSrcRect; |
| 219 *dstRect = newDstRect; | 219 *dstRect = newDstRect; |
| 220 } | 220 } |
| 221 | 221 |
| 222 FloatSize ImageBitmap::sourceSize() const | 222 FloatSize ImageBitmap::sourceSize() const |
| 223 { | 223 { |
| 224 return FloatSize(width(), height()); | 224 return FloatSize(width(), height()); |
| 225 } | 225 } |
| 226 | 226 |
| 227 void ImageBitmap::trace(Visitor*) |
| 228 { |
| 227 } | 229 } |
| 230 |
| 231 } |
| OLD | NEW |