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/PaintController.h" | |
35 #include "platform/graphics/paint/SkPictureBuilder.h" | 36 #include "platform/graphics/paint/SkPictureBuilder.h" |
chrishtr
2016/12/09 02:02:31
You can remove this include.
vmiura
2016/12/09 03:48:57
Done.
| |
36 #include "third_party/skia/include/core/SkImage.h" | 37 #include "third_party/skia/include/core/SkImage.h" |
37 #include "third_party/skia/include/core/SkPicture.h" | 38 #include "third_party/skia/include/core/SkPicture.h" |
38 | 39 |
39 namespace blink { | 40 namespace blink { |
40 | 41 |
41 void GeneratedImage::drawPattern(GraphicsContext& destContext, | 42 void GeneratedImage::drawPattern(GraphicsContext& destContext, |
42 const FloatRect& srcRect, | 43 const FloatRect& srcRect, |
43 const FloatSize& scale, | 44 const FloatSize& scale, |
44 const FloatPoint& phase, | 45 const FloatPoint& phase, |
45 SkBlendMode compositeOp, | 46 SkBlendMode compositeOp, |
46 const FloatRect& destRect, | 47 const FloatRect& destRect, |
47 const FloatSize& repeatSpacing) { | 48 const FloatSize& repeatSpacing) { |
48 FloatRect tileRect = srcRect; | 49 FloatRect tileRect = srcRect; |
49 tileRect.expand(FloatSize(repeatSpacing)); | 50 tileRect.expand(FloatSize(repeatSpacing)); |
50 | 51 |
51 SkPictureBuilder builder(tileRect, nullptr, &destContext); | 52 std::unique_ptr<PaintController> paintController = PaintController::create(); |
52 builder.context().beginRecording(tileRect); | 53 GraphicsContext context(*paintController); |
53 drawTile(builder.context(), srcRect); | 54 context.beginRecording(tileRect); |
54 sk_sp<SkPicture> tilePicture = builder.endRecording(); | 55 drawTile(context, srcRect); |
56 sk_sp<SkPicture> tilePicture = context.endRecording(); | |
55 | 57 |
56 SkMatrix patternMatrix = SkMatrix::MakeTrans(phase.x(), phase.y()); | 58 SkMatrix patternMatrix = SkMatrix::MakeTrans(phase.x(), phase.y()); |
57 patternMatrix.preScale(scale.width(), scale.height()); | 59 patternMatrix.preScale(scale.width(), scale.height()); |
58 patternMatrix.preTranslate(tileRect.x(), tileRect.y()); | 60 patternMatrix.preTranslate(tileRect.x(), tileRect.y()); |
59 | 61 |
60 RefPtr<Pattern> picturePattern = | 62 RefPtr<Pattern> picturePattern = |
61 Pattern::createPicturePattern(std::move(tilePicture)); | 63 Pattern::createPicturePattern(std::move(tilePicture)); |
62 | 64 |
63 SkPaint fillPaint = destContext.fillPaint(); | 65 SkPaint fillPaint = destContext.fillPaint(); |
64 picturePattern->applyToPaint(fillPaint, patternMatrix); | 66 picturePattern->applyToPaint(fillPaint, patternMatrix); |
65 fillPaint.setColor(SK_ColorBLACK); | 67 fillPaint.setColor(SK_ColorBLACK); |
66 fillPaint.setBlendMode(compositeOp); | 68 fillPaint.setBlendMode(compositeOp); |
67 | 69 |
68 destContext.drawRect(destRect, fillPaint); | 70 destContext.drawRect(destRect, fillPaint); |
69 } | 71 } |
70 | 72 |
71 sk_sp<SkImage> GeneratedImage::imageForCurrentFrame() { | 73 sk_sp<SkImage> GeneratedImage::imageForCurrentFrame() { |
72 return nullptr; | 74 return nullptr; |
73 } | 75 } |
74 | 76 |
75 } // namespace blink | 77 } // namespace blink |
OLD | NEW |