OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 #include "third_party/skia/include/effects/SkBlurMaskFilter.h" | 50 #include "third_party/skia/include/effects/SkBlurMaskFilter.h" |
51 #include "third_party/skia/include/effects/SkCornerPathEffect.h" | 51 #include "third_party/skia/include/effects/SkCornerPathEffect.h" |
52 #include "third_party/skia/include/effects/SkLumaColorFilter.h" | 52 #include "third_party/skia/include/effects/SkLumaColorFilter.h" |
53 #include "third_party/skia/include/effects/SkMatrixImageFilter.h" | 53 #include "third_party/skia/include/effects/SkMatrixImageFilter.h" |
54 #include "third_party/skia/include/effects/SkPictureImageFilter.h" | 54 #include "third_party/skia/include/effects/SkPictureImageFilter.h" |
55 #include "third_party/skia/include/gpu/GrRenderTarget.h" | 55 #include "third_party/skia/include/gpu/GrRenderTarget.h" |
56 #include "third_party/skia/include/gpu/GrTexture.h" | 56 #include "third_party/skia/include/gpu/GrTexture.h" |
57 #include "wtf/Assertions.h" | 57 #include "wtf/Assertions.h" |
58 #include "wtf/MathExtras.h" | 58 #include "wtf/MathExtras.h" |
59 | 59 |
60 using namespace std; | |
61 | |
62 namespace blink { | 60 namespace blink { |
63 | 61 |
64 namespace { | 62 namespace { |
65 | 63 |
66 class CompatibleImageBufferSurface : public ImageBufferSurface { | 64 class CompatibleImageBufferSurface : public ImageBufferSurface { |
67 WTF_MAKE_NONCOPYABLE(CompatibleImageBufferSurface); WTF_MAKE_FAST_ALLOCATED; | 65 WTF_MAKE_NONCOPYABLE(CompatibleImageBufferSurface); WTF_MAKE_FAST_ALLOCATED; |
68 public: | 66 public: |
69 CompatibleImageBufferSurface(PassRefPtr<SkSurface> surface, const IntSize& s
ize, OpacityMode opacityMode) | 67 CompatibleImageBufferSurface(PassRefPtr<SkSurface> surface, const IntSize& s
ize, OpacityMode opacityMode) |
70 : ImageBufferSurface(size, opacityMode) | 68 : ImageBufferSurface(size, opacityMode) |
71 , m_surface(surface) | 69 , m_surface(surface) |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 | 686 |
689 if (holeRect.isEmpty()) { | 687 if (holeRect.isEmpty()) { |
690 if (rect.isRounded()) | 688 if (rect.isRounded()) |
691 fillRoundedRect(rect, shadowColor); | 689 fillRoundedRect(rect, shadowColor); |
692 else | 690 else |
693 fillRect(rect.rect(), shadowColor); | 691 fillRect(rect.rect(), shadowColor); |
694 return; | 692 return; |
695 } | 693 } |
696 | 694 |
697 if (clippedEdges & LeftEdge) { | 695 if (clippedEdges & LeftEdge) { |
698 holeRect.move(-max(shadowOffset.width(), 0) - shadowBlur, 0); | 696 holeRect.move(-std::max(shadowOffset.width(), 0) - shadowBlur, 0); |
699 holeRect.setWidth(holeRect.width() + max(shadowOffset.width(), 0) + shad
owBlur); | 697 holeRect.setWidth(holeRect.width() + std::max(shadowOffset.width(), 0) +
shadowBlur); |
700 } | 698 } |
701 if (clippedEdges & TopEdge) { | 699 if (clippedEdges & TopEdge) { |
702 holeRect.move(0, -max(shadowOffset.height(), 0) - shadowBlur); | 700 holeRect.move(0, -std::max(shadowOffset.height(), 0) - shadowBlur); |
703 holeRect.setHeight(holeRect.height() + max(shadowOffset.height(), 0) + s
hadowBlur); | 701 holeRect.setHeight(holeRect.height() + std::max(shadowOffset.height(), 0
) + shadowBlur); |
704 } | 702 } |
705 if (clippedEdges & RightEdge) | 703 if (clippedEdges & RightEdge) |
706 holeRect.setWidth(holeRect.width() - min(shadowOffset.width(), 0) + shad
owBlur); | 704 holeRect.setWidth(holeRect.width() - std::min(shadowOffset.width(), 0) +
shadowBlur); |
707 if (clippedEdges & BottomEdge) | 705 if (clippedEdges & BottomEdge) |
708 holeRect.setHeight(holeRect.height() - min(shadowOffset.height(), 0) + s
hadowBlur); | 706 holeRect.setHeight(holeRect.height() - std::min(shadowOffset.height(), 0
) + shadowBlur); |
709 | 707 |
710 Color fillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(),
255); | 708 Color fillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(),
255); |
711 | 709 |
712 IntRect outerRect = areaCastingShadowInHole(rect.rect(), shadowBlur, shadowS
pread, shadowOffset); | 710 IntRect outerRect = areaCastingShadowInHole(rect.rect(), shadowBlur, shadowS
pread, shadowOffset); |
713 RoundedRect roundedHole(holeRect, rect.radii()); | 711 RoundedRect roundedHole(holeRect, rect.radii()); |
714 | 712 |
715 save(); | 713 save(); |
716 if (rect.isRounded()) { | 714 if (rect.isRounded()) { |
717 Path path; | 715 Path path; |
718 path.addRoundedRect(rect); | 716 path.addRoundedRect(rect); |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1116 ctm.mapRect(&deviceDest, dest); | 1114 ctm.mapRect(&deviceDest, dest); |
1117 SkRect sourceBounds = WebCoreFloatRectToSKRect(src); | 1115 SkRect sourceBounds = WebCoreFloatRectToSKRect(src); |
1118 | 1116 |
1119 RefPtr<SkPictureImageFilter> pictureFilter = adoptRef(SkPictureImageFilter::
Create(picture.get(), sourceBounds)); | 1117 RefPtr<SkPictureImageFilter> pictureFilter = adoptRef(SkPictureImageFilter::
Create(picture.get(), sourceBounds)); |
1120 SkMatrix layerScale; | 1118 SkMatrix layerScale; |
1121 layerScale.setScale(deviceDest.width() / src.width(), deviceDest.height() /
src.height()); | 1119 layerScale.setScale(deviceDest.width() / src.width(), deviceDest.height() /
src.height()); |
1122 RefPtr<SkMatrixImageFilter> matrixFilter = adoptRef(SkMatrixImageFilter::Cre
ate(layerScale, SkPaint::kLow_FilterLevel, pictureFilter.get())); | 1120 RefPtr<SkMatrixImageFilter> matrixFilter = adoptRef(SkMatrixImageFilter::Cre
ate(layerScale, SkPaint::kLow_FilterLevel, pictureFilter.get())); |
1123 SkPaint picturePaint; | 1121 SkPaint picturePaint; |
1124 picturePaint.setXfermodeMode(WebCoreCompositeToSkiaComposite(op, blendMode))
; | 1122 picturePaint.setXfermodeMode(WebCoreCompositeToSkiaComposite(op, blendMode))
; |
1125 picturePaint.setImageFilter(matrixFilter.get()); | 1123 picturePaint.setImageFilter(matrixFilter.get()); |
1126 SkRect layerBounds = SkRect::MakeWH(max(deviceDest.width(), sourceBounds.wid
th()), max(deviceDest.height(), sourceBounds.height())); | 1124 SkRect layerBounds = SkRect::MakeWH(std::max(deviceDest.width(), sourceBound
s.width()), std::max(deviceDest.height(), sourceBounds.height())); |
1127 m_canvas->save(); | 1125 m_canvas->save(); |
1128 m_canvas->resetMatrix(); | 1126 m_canvas->resetMatrix(); |
1129 m_canvas->translate(deviceDest.x(), deviceDest.y()); | 1127 m_canvas->translate(deviceDest.x(), deviceDest.y()); |
1130 m_canvas->saveLayer(&layerBounds, &picturePaint); | 1128 m_canvas->saveLayer(&layerBounds, &picturePaint); |
1131 m_canvas->restore(); | 1129 m_canvas->restore(); |
1132 m_canvas->restore(); | 1130 m_canvas->restore(); |
1133 } | 1131 } |
1134 | 1132 |
1135 void GraphicsContext::writePixels(const SkImageInfo& info, const void* pixels, s
ize_t rowBytes, int x, int y) | 1133 void GraphicsContext::writePixels(const SkImageInfo& info, const void* pixels, s
ize_t rowBytes, int x, int y) |
1136 { | 1134 { |
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1947 // FIXME: This is to not break tests (it results in the filter bitmap fl
ag | 1945 // FIXME: This is to not break tests (it results in the filter bitmap fl
ag |
1948 // being set to true). We need to decide if we respect InterpolationNone | 1946 // being set to true). We need to decide if we respect InterpolationNone |
1949 // being returned from computeInterpolationQuality. | 1947 // being returned from computeInterpolationQuality. |
1950 resampling = InterpolationLow; | 1948 resampling = InterpolationLow; |
1951 } | 1949 } |
1952 resampling = limitInterpolationQuality(this, resampling); | 1950 resampling = limitInterpolationQuality(this, resampling); |
1953 paint->setFilterLevel(static_cast<SkPaint::FilterLevel>(resampling)); | 1951 paint->setFilterLevel(static_cast<SkPaint::FilterLevel>(resampling)); |
1954 } | 1952 } |
1955 | 1953 |
1956 } // namespace blink | 1954 } // namespace blink |
OLD | NEW |