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

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

Issue 2559013002: Add ColorBehavior to blink::Image draw methods (Closed)
Patch Set: Rebase 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) 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 18 matching lines...) Expand all
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(SkCanvas* canvas,
35 const SkPaint& paint, 35 const SkPaint& 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 const ColorBehavior& colorBehavior) {
41 // TODO(ccameron): This function should not ignore |colorBehavior|.
42 // https://crbug.com/672306
40 SkRect visibleSrcRect = srcRect; 43 SkRect visibleSrcRect = srcRect;
41 if (!visibleSrcRect.intersect( 44 if (!visibleSrcRect.intersect(
42 SkRect::MakeIWH(m_size.width(), m_size.height()))) 45 SkRect::MakeIWH(m_size.width(), m_size.height())))
43 return; 46 return;
44 47
45 const SkMatrix transform = 48 const SkMatrix transform =
46 SkMatrix::MakeRectToRect(srcRect, destRect, SkMatrix::kFill_ScaleToFit); 49 SkMatrix::MakeRectToRect(srcRect, destRect, SkMatrix::kFill_ScaleToFit);
47 SkRect visibleDestRect; 50 SkRect visibleDestRect;
48 transform.mapRect(&visibleDestRect, visibleSrcRect); 51 transform.mapRect(&visibleDestRect, visibleSrcRect);
49 52
50 SkPaint gradientPaint(paint); 53 SkPaint gradientPaint(paint);
51 m_gradient->applyToPaint(gradientPaint, transform); 54 m_gradient->applyToPaint(gradientPaint, transform);
52 canvas->drawRect(visibleDestRect, gradientPaint); 55 canvas->drawRect(visibleDestRect, gradientPaint);
53 } 56 }
54 57
55 void GradientGeneratedImage::drawTile(GraphicsContext& context, 58 void GradientGeneratedImage::drawTile(GraphicsContext& context,
56 const FloatRect& srcRect) { 59 const FloatRect& srcRect) {
60 // TODO(ccameron): This function should not ignore |context|'s color behavior.
61 // https://crbug.com/672306
57 SkPaint gradientPaint(context.fillPaint()); 62 SkPaint gradientPaint(context.fillPaint());
58 m_gradient->applyToPaint(gradientPaint, SkMatrix::I()); 63 m_gradient->applyToPaint(gradientPaint, SkMatrix::I());
59 64
60 context.drawRect(srcRect, gradientPaint); 65 context.drawRect(srcRect, gradientPaint);
61 } 66 }
62 67
63 bool GradientGeneratedImage::applyShader(SkPaint& paint, 68 bool GradientGeneratedImage::applyShader(SkPaint& paint,
64 const SkMatrix& localMatrix) { 69 const SkMatrix& localMatrix,
70 const ColorBehavior& colorBehavior) {
71 // TODO(ccameron): This function should not ignore |colorBehavior|.
72 // https://crbug.com/672306
65 DCHECK(m_gradient); 73 DCHECK(m_gradient);
66 m_gradient->applyToPaint(paint, localMatrix); 74 m_gradient->applyToPaint(paint, localMatrix);
67 75
68 return true; 76 return true;
69 } 77 }
70 78
71 } // namespace blink 79 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698