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

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

Issue 2523673004: [NOT FOR COMMIT] Fully replace SkCanvas uses.
Patch Set: Support Android build. Created 3 years, 12 months 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) 2008, 2009, 2010, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2008, 2009, 2010, 2012 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 13 matching lines...) Expand all
24 */ 24 */
25 25
26 #include "platform/graphics/GradientGeneratedImage.h" 26 #include "platform/graphics/GradientGeneratedImage.h"
27 27
28 #include "platform/geometry/FloatRect.h" 28 #include "platform/geometry/FloatRect.h"
29 #include "platform/geometry/IntSize.h" 29 #include "platform/geometry/IntSize.h"
30 #include "platform/graphics/GraphicsContext.h" 30 #include "platform/graphics/GraphicsContext.h"
31 31
32 namespace blink { 32 namespace blink {
33 33
34 void GradientGeneratedImage::draw(SkCanvas* canvas, 34 void GradientGeneratedImage::draw(CdlCanvas* canvas,
35 const SkPaint& paint, 35 const CdlPaint& paint,
36 const FloatRect& destRect, 36 const FloatRect& destRect,
37 const FloatRect& srcRect, 37 const FloatRect& srcRect,
38 RespectImageOrientationEnum, 38 RespectImageOrientationEnum,
39 ImageClampingMode) { 39 ImageClampingMode) {
40 SkRect visibleSrcRect = srcRect; 40 SkRect visibleSrcRect = srcRect;
41 if (!visibleSrcRect.intersect( 41 if (!visibleSrcRect.intersect(
42 SkRect::MakeIWH(m_size.width(), m_size.height()))) 42 SkRect::MakeIWH(m_size.width(), m_size.height())))
43 return; 43 return;
44 44
45 const SkMatrix transform = 45 const SkMatrix transform =
46 SkMatrix::MakeRectToRect(srcRect, destRect, SkMatrix::kFill_ScaleToFit); 46 SkMatrix::MakeRectToRect(srcRect, destRect, SkMatrix::kFill_ScaleToFit);
47 SkRect visibleDestRect; 47 SkRect visibleDestRect;
48 transform.mapRect(&visibleDestRect, visibleSrcRect); 48 transform.mapRect(&visibleDestRect, visibleSrcRect);
49 49
50 SkPaint gradientPaint(paint); 50 CdlPaint gradientPaint(paint);
51 m_gradient->applyToPaint(gradientPaint, transform); 51 m_gradient->applyToPaint(gradientPaint, transform);
52 canvas->drawRect(visibleDestRect, gradientPaint); 52 canvas->drawRect(visibleDestRect, gradientPaint);
53 } 53 }
54 54
55 void GradientGeneratedImage::drawTile(GraphicsContext& context, 55 void GradientGeneratedImage::drawTile(GraphicsContext& context,
56 const FloatRect& srcRect) { 56 const FloatRect& srcRect) {
57 SkPaint gradientPaint(context.fillPaint()); 57 CdlPaint gradientPaint(context.fillPaint());
58 m_gradient->applyToPaint(gradientPaint, SkMatrix::I()); 58 m_gradient->applyToPaint(gradientPaint, SkMatrix::I());
59 59
60 context.drawRect(srcRect, gradientPaint); 60 context.drawRect(srcRect, gradientPaint);
61 } 61 }
62 62
63 bool GradientGeneratedImage::applyShader(SkPaint& paint, 63 bool GradientGeneratedImage::applyShader(CdlPaint& paint,
64 const SkMatrix& localMatrix) { 64 const SkMatrix& localMatrix) {
65 DCHECK(m_gradient); 65 DCHECK(m_gradient);
66 m_gradient->applyToPaint(paint, localMatrix); 66 m_gradient->applyToPaint(paint, localMatrix);
67 67
68 return true; 68 return true;
69 } 69 }
70 70
71 } // namespace blink 71 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698