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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 #include "third_party/skia/include/core/SkColorFilter.h" | 43 #include "third_party/skia/include/core/SkColorFilter.h" |
44 #include "third_party/skia/include/core/SkData.h" | 44 #include "third_party/skia/include/core/SkData.h" |
45 #include "third_party/skia/include/core/SkDevice.h" | 45 #include "third_party/skia/include/core/SkDevice.h" |
46 #include "third_party/skia/include/core/SkPicture.h" | 46 #include "third_party/skia/include/core/SkPicture.h" |
47 #include "third_party/skia/include/core/SkRRect.h" | 47 #include "third_party/skia/include/core/SkRRect.h" |
48 #include "third_party/skia/include/core/SkRefCnt.h" | 48 #include "third_party/skia/include/core/SkRefCnt.h" |
49 #include "third_party/skia/include/core/SkSurface.h" | 49 #include "third_party/skia/include/core/SkSurface.h" |
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" | |
54 #include "third_party/skia/include/effects/SkPictureImageFilter.h" | |
53 #include "third_party/skia/include/gpu/GrRenderTarget.h" | 55 #include "third_party/skia/include/gpu/GrRenderTarget.h" |
54 #include "third_party/skia/include/gpu/GrTexture.h" | 56 #include "third_party/skia/include/gpu/GrTexture.h" |
55 #include "wtf/Assertions.h" | 57 #include "wtf/Assertions.h" |
56 #include "wtf/MathExtras.h" | 58 #include "wtf/MathExtras.h" |
57 | 59 |
58 using namespace std; | 60 using namespace std; |
59 using blink::WebBlendMode; | 61 using blink::WebBlendMode; |
60 | 62 |
61 namespace blink { | 63 namespace blink { |
62 | 64 |
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1104 return; | 1106 return; |
1105 | 1107 |
1106 image->draw(this, dest, src, op, blendMode); | 1108 image->draw(this, dest, src, op, blendMode); |
1107 } | 1109 } |
1108 | 1110 |
1109 void GraphicsContext::drawPicture(PassRefPtr<SkPicture> picture, const FloatRect & dest, const FloatRect& src, CompositeOperator op, WebBlendMode blendMode) | 1111 void GraphicsContext::drawPicture(PassRefPtr<SkPicture> picture, const FloatRect & dest, const FloatRect& src, CompositeOperator op, WebBlendMode blendMode) |
1110 { | 1112 { |
1111 if (contextDisabled() || !picture) | 1113 if (contextDisabled() || !picture) |
1112 return; | 1114 return; |
1113 | 1115 |
1116 SkMatrix ctm = m_canvas->getTotalMatrix(); | |
1117 SkRect deviceDest; | |
1118 ctm.mapRect(&deviceDest, dest); | |
1119 SkRect sourceBounds = WebCoreFloatRectToSKRect(src); | |
1120 | |
1121 RefPtr<SkPictureImageFilter> pictureFilter = adoptRef(SkPictureImageFilter:: Create(picture.get(), sourceBounds)); | |
1122 SkMatrix layerScale; | |
1123 layerScale.setScale(deviceDest.width() / src.width(), deviceDest.height() / src.height()); | |
1124 RefPtr<SkMatrixImageFilter> matrixFilter = adoptRef(SkMatrixImageFilter::Cre ate(layerScale, SkPaint::kLow_FilterLevel, pictureFilter.get())); | |
Stephen White
2014/08/13 21:26:50
Perf note: using a matrix filter will incur one ex
| |
1114 SkPaint picturePaint; | 1125 SkPaint picturePaint; |
1115 picturePaint.setXfermode(WebCoreCompositeToSkiaComposite(op, blendMode).get( )); | 1126 picturePaint.setXfermode(WebCoreCompositeToSkiaComposite(op, blendMode).get( )); |
1116 SkRect skBounds = WebCoreFloatRectToSKRect(dest); | 1127 picturePaint.setImageFilter(matrixFilter.get()); |
1117 saveLayer(&skBounds, &picturePaint); | 1128 SkRect layerBounds = SkRect::MakeWH(max(deviceDest.width(), sourceBounds.wid th()), max(deviceDest.height(), sourceBounds.height())); |
1118 SkMatrix pictureTransform; | 1129 m_canvas->save(); |
1119 pictureTransform.setRectToRect(WebCoreFloatRectToSKRect(src), skBounds, SkMa trix::kFill_ScaleToFit); | 1130 m_canvas->resetMatrix(); |
1120 m_canvas->concat(pictureTransform); | 1131 m_canvas->translate(deviceDest.x(), deviceDest.y()); |
1121 picture->draw(m_canvas); | 1132 m_canvas->saveLayer(&layerBounds, &picturePaint); |
1122 restoreLayer(); | 1133 m_canvas->restore(); |
1134 m_canvas->restore(); | |
1123 } | 1135 } |
1124 | 1136 |
1125 void GraphicsContext::writePixels(const SkImageInfo& info, const void* pixels, s ize_t rowBytes, int x, int y) | 1137 void GraphicsContext::writePixels(const SkImageInfo& info, const void* pixels, s ize_t rowBytes, int x, int y) |
1126 { | 1138 { |
1127 if (contextDisabled()) | 1139 if (contextDisabled()) |
1128 return; | 1140 return; |
1129 | 1141 |
1130 m_canvas->writePixels(info, pixels, rowBytes, x, y); | 1142 m_canvas->writePixels(info, pixels, rowBytes, x, y); |
1131 | 1143 |
1132 if (regionTrackingEnabled()) { | 1144 if (regionTrackingEnabled()) { |
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1938 // FIXME: This is to not break tests (it results in the filter bitmap fl ag | 1950 // FIXME: This is to not break tests (it results in the filter bitmap fl ag |
1939 // being set to true). We need to decide if we respect InterpolationNone | 1951 // being set to true). We need to decide if we respect InterpolationNone |
1940 // being returned from computeInterpolationQuality. | 1952 // being returned from computeInterpolationQuality. |
1941 resampling = InterpolationLow; | 1953 resampling = InterpolationLow; |
1942 } | 1954 } |
1943 resampling = limitInterpolationQuality(this, resampling); | 1955 resampling = limitInterpolationQuality(this, resampling); |
1944 paint->setFilterLevel(static_cast<SkPaint::FilterLevel>(resampling)); | 1956 paint->setFilterLevel(static_cast<SkPaint::FilterLevel>(resampling)); |
1945 } | 1957 } |
1946 | 1958 |
1947 } | 1959 } |
OLD | NEW |