OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 14 matching lines...) Expand all Loading... |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "platform/graphics/GeneratedImage.h" | 31 #include "platform/graphics/GeneratedImage.h" |
32 | 32 |
33 #include "platform/geometry/FloatRect.h" | 33 #include "platform/geometry/FloatRect.h" |
34 #include "platform/graphics/GraphicsContext.h" | 34 #include "platform/graphics/GraphicsContext.h" |
35 #include "platform/graphics/paint/SkPictureBuilder.h" | 35 #include "platform/graphics/paint/PaintController.h" |
36 #include "third_party/skia/include/core/SkImage.h" | 36 #include "third_party/skia/include/core/SkImage.h" |
37 #include "third_party/skia/include/core/SkPicture.h" | 37 #include "third_party/skia/include/core/SkPicture.h" |
38 | 38 |
39 namespace blink { | 39 namespace blink { |
40 | 40 |
41 void GeneratedImage::drawPattern(GraphicsContext& destContext, | 41 void GeneratedImage::drawPattern(GraphicsContext& destContext, |
42 const FloatRect& srcRect, | 42 const FloatRect& srcRect, |
43 const FloatSize& scale, | 43 const FloatSize& scale, |
44 const FloatPoint& phase, | 44 const FloatPoint& phase, |
45 SkBlendMode compositeOp, | 45 SkBlendMode compositeOp, |
46 const FloatRect& destRect, | 46 const FloatRect& destRect, |
47 const FloatSize& repeatSpacing) { | 47 const FloatSize& repeatSpacing) { |
48 FloatRect tileRect = srcRect; | 48 FloatRect tileRect = srcRect; |
49 tileRect.expand(FloatSize(repeatSpacing)); | 49 tileRect.expand(FloatSize(repeatSpacing)); |
50 | 50 |
51 SkPictureBuilder builder(tileRect, nullptr, &destContext); | 51 std::unique_ptr<PaintController> paintController = PaintController::create(); |
52 builder.context().beginRecording(tileRect); | 52 GraphicsContext context(*paintController); |
53 drawTile(builder.context(), srcRect); | 53 context.beginRecording(tileRect); |
54 sk_sp<SkPicture> tilePicture = builder.endRecording(); | 54 drawTile(context, srcRect); |
| 55 sk_sp<SkPicture> tilePicture = context.endRecording(); |
55 | 56 |
56 SkMatrix patternMatrix = SkMatrix::MakeTrans(phase.x(), phase.y()); | 57 SkMatrix patternMatrix = SkMatrix::MakeTrans(phase.x(), phase.y()); |
57 patternMatrix.preScale(scale.width(), scale.height()); | 58 patternMatrix.preScale(scale.width(), scale.height()); |
58 patternMatrix.preTranslate(tileRect.x(), tileRect.y()); | 59 patternMatrix.preTranslate(tileRect.x(), tileRect.y()); |
59 | 60 |
60 RefPtr<Pattern> picturePattern = | 61 RefPtr<Pattern> picturePattern = |
61 Pattern::createPicturePattern(std::move(tilePicture)); | 62 Pattern::createPicturePattern(std::move(tilePicture)); |
62 | 63 |
63 SkPaint fillPaint = destContext.fillPaint(); | 64 SkPaint fillPaint = destContext.fillPaint(); |
64 picturePattern->applyToPaint(fillPaint, patternMatrix); | 65 picturePattern->applyToPaint(fillPaint, patternMatrix); |
65 fillPaint.setColor(SK_ColorBLACK); | 66 fillPaint.setColor(SK_ColorBLACK); |
66 fillPaint.setBlendMode(compositeOp); | 67 fillPaint.setBlendMode(compositeOp); |
67 | 68 |
68 destContext.drawRect(destRect, fillPaint); | 69 destContext.drawRect(destRect, fillPaint); |
69 } | 70 } |
70 | 71 |
71 sk_sp<SkImage> GeneratedImage::imageForCurrentFrame() { | 72 sk_sp<SkImage> GeneratedImage::imageForCurrentFrame() { |
72 return nullptr; | 73 return nullptr; |
73 } | 74 } |
74 | 75 |
75 } // namespace blink | 76 } // namespace blink |
OLD | NEW |