| 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 15 matching lines...) Expand all Loading... |
| 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/PaintController.h" |
| 36 #include "platform/graphics/paint/PaintRecord.h" |
| 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 | 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 std::unique_ptr<PaintController> paintController = PaintController::create(); | 51 std::unique_ptr<PaintController> paintController = PaintController::create(); |
| 52 GraphicsContext context(*paintController); | 52 GraphicsContext context(*paintController); |
| 53 context.beginRecording(tileRect); | 53 context.beginRecording(tileRect); |
| 54 drawTile(context, srcRect); | 54 drawTile(context, srcRect); |
| 55 sk_sp<SkPicture> tilePicture = context.endRecording(); | 55 sk_sp<PaintRecord> tilePicture = context.endRecording(); |
| 56 | 56 |
| 57 SkMatrix patternMatrix = SkMatrix::MakeTrans(phase.x(), phase.y()); | 57 SkMatrix patternMatrix = SkMatrix::MakeTrans(phase.x(), phase.y()); |
| 58 patternMatrix.preScale(scale.width(), scale.height()); | 58 patternMatrix.preScale(scale.width(), scale.height()); |
| 59 patternMatrix.preTranslate(tileRect.x(), tileRect.y()); | 59 patternMatrix.preTranslate(tileRect.x(), tileRect.y()); |
| 60 | 60 |
| 61 RefPtr<Pattern> picturePattern = | 61 RefPtr<Pattern> picturePattern = |
| 62 Pattern::createPicturePattern(std::move(tilePicture)); | 62 Pattern::createPicturePattern(std::move(tilePicture)); |
| 63 | 63 |
| 64 SkPaint fillPaint = destContext.fillPaint(); | 64 PaintFlags fillPaint = destContext.fillPaint(); |
| 65 picturePattern->applyToPaint(fillPaint, patternMatrix); | 65 picturePattern->applyToPaint(fillPaint, patternMatrix); |
| 66 fillPaint.setColor(SK_ColorBLACK); | 66 fillPaint.setColor(SK_ColorBLACK); |
| 67 fillPaint.setBlendMode(compositeOp); | 67 fillPaint.setBlendMode(compositeOp); |
| 68 | 68 |
| 69 destContext.drawRect(destRect, fillPaint); | 69 destContext.drawRect(destRect, fillPaint); |
| 70 } | 70 } |
| 71 | 71 |
| 72 sk_sp<SkImage> GeneratedImage::imageForCurrentFrame( | 72 sk_sp<SkImage> GeneratedImage::imageForCurrentFrame( |
| 73 const ColorBehavior& colorBehavior) { | 73 const ColorBehavior& colorBehavior) { |
| 74 return nullptr; | 74 return nullptr; |
| 75 } | 75 } |
| 76 | 76 |
| 77 } // namespace blink | 77 } // namespace blink |
| OLD | NEW |