| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/csspaint/PaintRenderingContext2D.h" | 5 #include "modules/csspaint/PaintRenderingContext2D.h" |
| 6 | 6 |
| 7 #include "platform/graphics/ImageBuffer.h" | 7 #include "platform/graphics/ImageBuffer.h" |
| 8 #include "platform/graphics/paint/PaintCanvas.h" | 8 #include "platform/graphics/paint/PaintCanvas.h" |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 bool PaintRenderingContext2D::ParseColorOrCurrentColor( | 41 bool PaintRenderingContext2D::ParseColorOrCurrentColor( |
| 42 Color& color, | 42 Color& color, |
| 43 const String& color_string) const { | 43 const String& color_string) const { |
| 44 // We ignore "currentColor" for PaintRenderingContext2D and just make it | 44 // We ignore "currentColor" for PaintRenderingContext2D and just make it |
| 45 // "black". "currentColor" can be emulated by having "color" as an input | 45 // "black". "currentColor" can be emulated by having "color" as an input |
| 46 // property for the css-paint-api. | 46 // property for the css-paint-api. |
| 47 // https://github.com/w3c/css-houdini-drafts/issues/133 | 47 // https://github.com/w3c/css-houdini-drafts/issues/133 |
| 48 return ::blink::ParseColorOrCurrentColor(color, color_string, nullptr); | 48 return ::blink::ParseColorOrCurrentColor(color, color_string, nullptr); |
| 49 } | 49 } |
| 50 | 50 |
| 51 ColorBehavior PaintRenderingContext2D::DrawImageColorBehavior() const { | |
| 52 return ColorBehavior::TransformToGlobalTarget(); | |
| 53 } | |
| 54 | |
| 55 PaintCanvas* PaintRenderingContext2D::DrawingCanvas() const { | 51 PaintCanvas* PaintRenderingContext2D::DrawingCanvas() const { |
| 56 return image_buffer_->Canvas(); | 52 return image_buffer_->Canvas(); |
| 57 } | 53 } |
| 58 | 54 |
| 59 PaintCanvas* PaintRenderingContext2D::ExistingDrawingCanvas() const { | 55 PaintCanvas* PaintRenderingContext2D::ExistingDrawingCanvas() const { |
| 60 DCHECK(image_buffer_); | 56 DCHECK(image_buffer_); |
| 61 return image_buffer_->Canvas(); | 57 return image_buffer_->Canvas(); |
| 62 } | 58 } |
| 63 | 59 |
| 64 AffineTransform PaintRenderingContext2D::BaseTransform() const { | 60 AffineTransform PaintRenderingContext2D::BaseTransform() const { |
| 65 DCHECK(image_buffer_); | 61 DCHECK(image_buffer_); |
| 66 return image_buffer_->BaseTransform(); | 62 return image_buffer_->BaseTransform(); |
| 67 } | 63 } |
| 68 | 64 |
| 69 void PaintRenderingContext2D::DidDraw(const SkIRect& dirty_rect) { | 65 void PaintRenderingContext2D::DidDraw(const SkIRect& dirty_rect) { |
| 70 DCHECK(image_buffer_); | 66 DCHECK(image_buffer_); |
| 71 return image_buffer_->DidDraw(SkRect::Make(dirty_rect)); | 67 return image_buffer_->DidDraw(SkRect::Make(dirty_rect)); |
| 72 } | 68 } |
| 73 | 69 |
| 74 void PaintRenderingContext2D::ValidateStateStack() const { | 70 void PaintRenderingContext2D::ValidateStateStack() const { |
| 75 #if DCHECK_IS_ON() | 71 #if DCHECK_IS_ON() |
| 76 if (PaintCanvas* sk_canvas = ExistingDrawingCanvas()) { | 72 if (PaintCanvas* sk_canvas = ExistingDrawingCanvas()) { |
| 77 DCHECK_EQ(static_cast<size_t>(sk_canvas->getSaveCount()), | 73 DCHECK_EQ(static_cast<size_t>(sk_canvas->getSaveCount()), |
| 78 state_stack_.size() + 1); | 74 state_stack_.size() + 1); |
| 79 } | 75 } |
| 80 #endif | 76 #endif |
| 81 } | 77 } |
| 82 | 78 |
| 83 } // namespace blink | 79 } // namespace blink |
| OLD | NEW |