Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/GeneratedImage.cpp

Issue 2523673004: [NOT FOR COMMIT] Fully replace SkCanvas uses.
Patch Set: Support Android build. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 16 matching lines...) Expand all
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/SkPictureBuilder.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 "skia/ext/cdl_picture.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 SkPictureBuilder builder(tileRect, nullptr, &destContext);
52 builder.context().beginRecording(tileRect); 52 builder.context().beginRecording(tileRect);
53 drawTile(builder.context(), srcRect); 53 drawTile(builder.context(), srcRect);
54 sk_sp<SkPicture> tilePicture = builder.endRecording(); 54 sk_sp<CdlPicture> tilePicture = builder.endRecording();
55 55
56 SkMatrix patternMatrix = SkMatrix::MakeTrans(phase.x(), phase.y()); 56 SkMatrix patternMatrix = SkMatrix::MakeTrans(phase.x(), phase.y());
57 patternMatrix.preScale(scale.width(), scale.height()); 57 patternMatrix.preScale(scale.width(), scale.height());
58 patternMatrix.preTranslate(tileRect.x(), tileRect.y()); 58 patternMatrix.preTranslate(tileRect.x(), tileRect.y());
59 59
60 RefPtr<Pattern> picturePattern = 60 RefPtr<Pattern> picturePattern =
61 Pattern::createPicturePattern(std::move(tilePicture)); 61 Pattern::createPicturePattern(std::move(tilePicture));
62 62
63 SkPaint fillPaint = destContext.fillPaint(); 63 CdlPaint fillPaint = destContext.fillPaint();
64 picturePattern->applyToPaint(fillPaint, patternMatrix); 64 picturePattern->applyToPaint(fillPaint, patternMatrix);
65 fillPaint.setColor(SK_ColorBLACK); 65 fillPaint.setColor(SK_ColorBLACK);
66 fillPaint.setBlendMode(compositeOp); 66 fillPaint.setBlendMode(compositeOp);
67 67
68 destContext.drawRect(destRect, fillPaint); 68 destContext.drawRect(destRect, fillPaint);
69 } 69 }
70 70
71 sk_sp<SkImage> GeneratedImage::imageForCurrentFrame() { 71 sk_sp<SkImage> GeneratedImage::imageForCurrentFrame() {
72 return nullptr; 72 return nullptr;
73 } 73 }
74 74
75 } // namespace blink 75 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698