OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/paint/ImagePainter.h" | 6 #include "core/paint/ImagePainter.h" |
7 | 7 |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/dom/Element.h" | 9 #include "core/dom/Element.h" |
10 #include "core/editing/FrameSelection.h" | 10 #include "core/editing/FrameSelection.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 void ImagePainter::paintIntoRect(GraphicsContext* context, const LayoutRect& rec
t) | 175 void ImagePainter::paintIntoRect(GraphicsContext* context, const LayoutRect& rec
t) |
176 { | 176 { |
177 IntRect alignedRect = pixelSnappedIntRect(rect); | 177 IntRect alignedRect = pixelSnappedIntRect(rect); |
178 if (!m_renderImage.imageResource()->hasImage() || m_renderImage.imageResourc
e()->errorOccurred() || alignedRect.width() <= 0 || alignedRect.height() <= 0) | 178 if (!m_renderImage.imageResource()->hasImage() || m_renderImage.imageResourc
e()->errorOccurred() || alignedRect.width() <= 0 || alignedRect.height() <= 0) |
179 return; | 179 return; |
180 | 180 |
181 RefPtr<Image> img = m_renderImage.imageResource()->image(alignedRect.width()
, alignedRect.height()); | 181 RefPtr<Image> img = m_renderImage.imageResource()->image(alignedRect.width()
, alignedRect.height()); |
182 if (!img || img->isNull()) | 182 if (!img || img->isNull()) |
183 return; | 183 return; |
184 | 184 |
185 HTMLImageElement* imageElt = isHTMLImageElement(m_renderImage.node()) ? toHT
MLImageElement(m_renderImage.node()) : 0; | |
186 CompositeOperator compositeOperator = imageElt ? imageElt->compositeOperator
() : CompositeSourceOver; | |
187 Image* image = img.get(); | 185 Image* image = img.get(); |
188 InterpolationQuality interpolationQuality = BoxPainter::chooseInterpolationQ
uality(m_renderImage, context, image, image, alignedRect.size()); | 186 InterpolationQuality interpolationQuality = BoxPainter::chooseInterpolationQ
uality(m_renderImage, context, image, image, alignedRect.size()); |
189 | 187 |
190 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage", "
data", InspectorPaintImageEvent::data(m_renderImage)); | 188 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage", "
data", InspectorPaintImageEvent::data(m_renderImage)); |
191 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli
ne migrates to tracing. | 189 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli
ne migrates to tracing. |
192 InspectorInstrumentation::willPaintImage(&m_renderImage); | 190 InspectorInstrumentation::willPaintImage(&m_renderImage); |
193 InterpolationQuality previousInterpolationQuality = context->imageInterpolat
ionQuality(); | 191 InterpolationQuality previousInterpolationQuality = context->imageInterpolat
ionQuality(); |
194 context->setImageInterpolationQuality(interpolationQuality); | 192 context->setImageInterpolationQuality(interpolationQuality); |
195 context->drawImage(image, alignedRect, compositeOperator, m_renderImage.shou
ldRespectImageOrientation()); | 193 context->drawImage(image, alignedRect, CompositeSourceOver, m_renderImage.sh
ouldRespectImageOrientation()); |
196 context->setImageInterpolationQuality(previousInterpolationQuality); | 194 context->setImageInterpolationQuality(previousInterpolationQuality); |
197 InspectorInstrumentation::didPaintImage(&m_renderImage); | 195 InspectorInstrumentation::didPaintImage(&m_renderImage); |
198 } | 196 } |
199 | 197 |
200 } // namespace blink | 198 } // namespace blink |
OLD | NEW |