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

Side by Side Diff: sky/engine/core/frame/ImageBitmap.cpp

Issue 706123005: Remove nop ScriptWrappable::init calls (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 | « sky/engine/core/frame/History.cpp ('k') | sky/engine/core/frame/LocalDOMWindow.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 // 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/ImageData.h" 9 #include "core/html/ImageData.h"
10 #include "core/html/canvas/CanvasRenderingContext.h" 10 #include "core/html/canvas/CanvasRenderingContext.h"
(...skipping 30 matching lines...) Expand all
41 { 41 {
42 IntRect srcRect = intersection(cropRect, IntRect(0, 0, image->width(), image ->height())); 42 IntRect srcRect = intersection(cropRect, IntRect(0, 0, image->width(), image ->height()));
43 m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro pRect.y())), srcRect.size()); 43 m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro pRect.y())), srcRect.size());
44 m_bitmapOffset = srcRect.location(); 44 m_bitmapOffset = srcRect.location();
45 45
46 if (!srcRect.width() || !srcRect.height()) 46 if (!srcRect.width() || !srcRect.height())
47 m_imageElement = nullptr; 47 m_imageElement = nullptr;
48 else 48 else
49 m_imageElement->addClient(this); 49 m_imageElement->addClient(this);
50 50
51 ScriptWrappable::init(this);
52 } 51 }
53 52
54 ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas, const IntRect& cropRect) 53 ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas, const IntRect& cropRect)
55 : m_imageElement(nullptr) 54 : m_imageElement(nullptr)
56 , m_cropRect(cropRect) 55 , m_cropRect(cropRect)
57 , m_bitmapOffset(IntPoint()) 56 , m_bitmapOffset(IntPoint())
58 { 57 {
59 CanvasRenderingContext* sourceContext = canvas->renderingContext(); 58 CanvasRenderingContext* sourceContext = canvas->renderingContext();
60 if (sourceContext && sourceContext->is3d()) 59 if (sourceContext && sourceContext->is3d())
61 sourceContext->paintRenderingResultsToCanvas(); 60 sourceContext->paintRenderingResultsToCanvas();
62 61
63 IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), canvas->size()) ); 62 IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), canvas->size()) );
64 m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro pRect.y())), srcRect.size()); 63 m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro pRect.y())), srcRect.size());
65 m_bitmap = cropImage(canvas->buffer()->copyImage(CopyBackingStore).get(), cr opRect); 64 m_bitmap = cropImage(canvas->buffer()->copyImage(CopyBackingStore).get(), cr opRect);
66
67 ScriptWrappable::init(this);
68 } 65 }
69 66
70 ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect) 67 ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect)
71 : m_imageElement(nullptr) 68 : m_imageElement(nullptr)
72 , m_cropRect(cropRect) 69 , m_cropRect(cropRect)
73 , m_bitmapOffset(IntPoint()) 70 , m_bitmapOffset(IntPoint())
74 { 71 {
75 IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), data->size())); 72 IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), data->size()));
76 73
77 OwnPtr<ImageBuffer> buf = ImageBuffer::create(data->size()); 74 OwnPtr<ImageBuffer> buf = ImageBuffer::create(data->size());
78 if (!buf) 75 if (!buf)
79 return; 76 return;
80 if (srcRect.width() > 0 && srcRect.height() > 0) 77 if (srcRect.width() > 0 && srcRect.height() > 0)
81 buf->putByteArray(Premultiplied, data->data(), data->size(), srcRect, In tPoint(std::min(0, -cropRect.x()), std::min(0, -cropRect.y()))); 78 buf->putByteArray(Premultiplied, data->data(), data->size(), srcRect, In tPoint(std::min(0, -cropRect.x()), std::min(0, -cropRect.y())));
82 79
83 m_bitmap = buf->copyImage(DontCopyBackingStore); 80 m_bitmap = buf->copyImage(DontCopyBackingStore);
84 m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro pRect.y())), srcRect.size()); 81 m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro pRect.y())), srcRect.size());
85
86 ScriptWrappable::init(this);
87 } 82 }
88 83
89 ImageBitmap::ImageBitmap(ImageBitmap* bitmap, const IntRect& cropRect) 84 ImageBitmap::ImageBitmap(ImageBitmap* bitmap, const IntRect& cropRect)
90 : m_imageElement(bitmap->imageElement()) 85 : m_imageElement(bitmap->imageElement())
91 , m_bitmap(nullptr) 86 , m_bitmap(nullptr)
92 , m_cropRect(cropRect) 87 , m_cropRect(cropRect)
93 , m_bitmapOffset(IntPoint()) 88 , m_bitmapOffset(IntPoint())
94 { 89 {
95 IntRect oldBitmapRect = bitmap->bitmapRect(); 90 IntRect oldBitmapRect = bitmap->bitmapRect();
96 IntRect srcRect = intersection(cropRect, oldBitmapRect); 91 IntRect srcRect = intersection(cropRect, oldBitmapRect);
97 m_bitmapRect = IntRect(IntPoint(std::max(0, oldBitmapRect.x() - cropRect.x() ), std::max(0, oldBitmapRect.y() - cropRect.y())), srcRect.size()); 92 m_bitmapRect = IntRect(IntPoint(std::max(0, oldBitmapRect.x() - cropRect.x() ), std::max(0, oldBitmapRect.y() - cropRect.y())), srcRect.size());
98 93
99 if (m_imageElement) { 94 if (m_imageElement) {
100 m_imageElement->addClient(this); 95 m_imageElement->addClient(this);
101 m_bitmapOffset = srcRect.location(); 96 m_bitmapOffset = srcRect.location();
102 } else if (bitmap->bitmapImage()) { 97 } else if (bitmap->bitmapImage()) {
103 IntRect adjustedCropRect(IntPoint(cropRect.x() -oldBitmapRect.x(), cropR ect.y() - oldBitmapRect.y()), cropRect.size()); 98 IntRect adjustedCropRect(IntPoint(cropRect.x() -oldBitmapRect.x(), cropR ect.y() - oldBitmapRect.y()), cropRect.size());
104 m_bitmap = cropImage(bitmap->bitmapImage().get(), adjustedCropRect); 99 m_bitmap = cropImage(bitmap->bitmapImage().get(), adjustedCropRect);
105 } 100 }
106
107 ScriptWrappable::init(this);
108 } 101 }
109 102
110 ImageBitmap::ImageBitmap(Image* image, const IntRect& cropRect) 103 ImageBitmap::ImageBitmap(Image* image, const IntRect& cropRect)
111 : m_imageElement(nullptr) 104 : m_imageElement(nullptr)
112 , m_cropRect(cropRect) 105 , m_cropRect(cropRect)
113 { 106 {
114 IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), image->size())) ; 107 IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), image->size())) ;
115 m_bitmap = cropImage(image, cropRect); 108 m_bitmap = cropImage(image, cropRect);
116 m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro pRect.y())), srcRect.size()); 109 m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro pRect.y())), srcRect.size());
117
118 ScriptWrappable::init(this);
119 } 110 }
120 111
121 ImageBitmap::~ImageBitmap() 112 ImageBitmap::~ImageBitmap()
122 { 113 {
123 #if !ENABLE(OILPAN) 114 #if !ENABLE(OILPAN)
124 if (m_imageElement) 115 if (m_imageElement)
125 m_imageElement->removeClient(this); 116 m_imageElement->removeClient(this);
126 #endif 117 #endif
127 } 118 }
128 119
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 return FloatSize(width(), height()); 186 return FloatSize(width(), height());
196 } 187 }
197 188
198 void ImageBitmap::trace(Visitor* visitor) 189 void ImageBitmap::trace(Visitor* visitor)
199 { 190 {
200 visitor->trace(m_imageElement); 191 visitor->trace(m_imageElement);
201 ImageLoaderClient::trace(visitor); 192 ImageLoaderClient::trace(visitor);
202 } 193 }
203 194
204 } 195 }
OLDNEW
« no previous file with comments | « sky/engine/core/frame/History.cpp ('k') | sky/engine/core/frame/LocalDOMWindow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698