OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef PaintRenderingContext2D_h |
| 6 #define PaintRenderingContext2D_h |
| 7 |
| 8 #include "bindings/core/v8/ScriptWrappable.h" |
| 9 #include "modules/ModulesExport.h" |
| 10 #include "modules/canvas2d/BaseRenderingContext2D.h" |
| 11 #include "third_party/skia/include/core/SkCanvas.h" |
| 12 |
| 13 namespace blink { |
| 14 |
| 15 class CanvasImageSource; |
| 16 class Color; |
| 17 class ImageBuffer; |
| 18 |
| 19 class MODULES_EXPORT PaintRenderingContext2D : public BaseRenderingContext2D, pu
blic RefCountedWillBeGarbageCollectedFinalized<PaintRenderingContext2D>, public
ScriptWrappable { |
| 20 DEFINE_WRAPPERTYPEINFO(); |
| 21 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PaintRenderingContext2D); |
| 22 WTF_MAKE_NONCOPYABLE(PaintRenderingContext2D); |
| 23 USING_FAST_MALLOC_WILL_BE_REMOVED(PaintRenderingContext2D); |
| 24 public: |
| 25 static PassRefPtrWillBeRawPtr<PaintRenderingContext2D> create(PassOwnPtr<Ima
geBuffer> imageBuffer) |
| 26 { |
| 27 return adoptRefWillBeNoop(new PaintRenderingContext2D(imageBuffer)); |
| 28 } |
| 29 |
| 30 // BaseRenderingContext2D |
| 31 |
| 32 // PaintRenderingContext2D doesn't have any pixel readback so the origin |
| 33 // is always clean, and unable to taint it. |
| 34 bool originClean() const final { return true; } |
| 35 void setOriginTainted() final { } |
| 36 bool wouldTaintOrigin(CanvasImageSource*) final { return false; } |
| 37 |
| 38 int width() const final; |
| 39 int height() const final; |
| 40 |
| 41 bool hasImageBuffer() const final { return m_imageBuffer; } |
| 42 ImageBuffer* imageBuffer() const final { return m_imageBuffer.get(); } |
| 43 |
| 44 bool parseColorOrCurrentColor(Color&, const String& colorString) const final
; |
| 45 |
| 46 SkCanvas* drawingCanvas() const final; |
| 47 SkCanvas* existingDrawingCanvas() const final; |
| 48 void disableDeferral(DisableDeferralReason) final { } |
| 49 |
| 50 AffineTransform baseTransform() const final; |
| 51 |
| 52 void didDraw(const SkIRect& dirtyRect) final; |
| 53 |
| 54 // TODO(ikilpatrick): We'll need to either only accept resolved filters |
| 55 // from a typed-om <filter> object, or use the appropriate style resolution |
| 56 // host to determine 'em' units etc in filters. At the moment just pretend |
| 57 // that we don't have a filter set. |
| 58 bool stateHasFilter() final { return false; } |
| 59 SkImageFilter* stateGetFilter() final { return nullptr; } |
| 60 |
| 61 void validateStateStack() final; |
| 62 |
| 63 bool hasAlpha() const final { return true; } |
| 64 |
| 65 // PaintRenderingContext2D cannot lose it's context. |
| 66 bool isContextLost() const final { return false; } |
| 67 |
| 68 private: |
| 69 explicit PaintRenderingContext2D(PassOwnPtr<ImageBuffer>); |
| 70 |
| 71 OwnPtr<ImageBuffer> m_imageBuffer; |
| 72 }; |
| 73 |
| 74 } // namespace blink |
| 75 |
| 76 #endif // PaintRenderingContext2D_h |
OLD | NEW |