Chromium Code Reviews| Index: third_party/WebKit/Source/modules/csspaint/PaintRenderingContext2D.h |
| diff --git a/third_party/WebKit/Source/modules/csspaint/PaintRenderingContext2D.h b/third_party/WebKit/Source/modules/csspaint/PaintRenderingContext2D.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..01825bc36cbf0122ebecaac4ecf18f9489e6ce10 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/modules/csspaint/PaintRenderingContext2D.h |
| @@ -0,0 +1,76 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef PaintRenderingContext2D_h |
| +#define PaintRenderingContext2D_h |
| + |
| +#include "bindings/core/v8/ScriptWrappable.h" |
| +#include "modules/ModulesExport.h" |
| +#include "modules/canvas2d/BaseRenderingContext2D.h" |
| +#include "third_party/skia/include/core/SkCanvas.h" |
| + |
| +namespace blink { |
| + |
| +class CanvasImageSource; |
| +class Color; |
| +class ImageBuffer; |
| + |
| +class MODULES_EXPORT PaintRenderingContext2D : public BaseRenderingContext2D, public NoBaseWillBeGarbageCollectedFinalized<PaintRenderingContext2D>, public ScriptWrappable { |
| + DEFINE_WRAPPERTYPEINFO(); |
| + WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PaintRenderingContext2D); |
| + WTF_MAKE_NONCOPYABLE(PaintRenderingContext2D); |
| + USING_FAST_MALLOC_WILL_BE_REMOVED(PaintRenderingContext2D); |
| +public: |
| + PassOwnPtrWillBeRawPtr<PaintRenderingContext2D> create(PassOwnPtr<ImageBuffer> imageBuffer) |
| + { |
| + return adoptPtrWillBeNoop(new PaintRenderingContext2D(imageBuffer)); |
| + } |
| + |
| + // BaseRenderingContext2D |
| + |
| + // PaintRenderingContext2D doesn't have any pixel readback so the origin |
| + // is always clean, and unable to taint it. |
| + bool originClean() const final { return true; } |
|
Justin Novosad
2016/03/17 18:46:10
could put ASSERT_NOT_REACHED() here and in wouldTa
ikilpatrick
2016/03/17 19:15:41
It's actually used a bunch of times inside of Base
|
| + void setOriginTainted() final { } |
| + bool wouldTaintOrigin(CanvasImageSource*) final { return false; } |
| + |
| + int width() const final; |
| + int height() const final; |
| + |
| + bool hasImageBuffer() const final { return m_imageBuffer; } |
| + ImageBuffer* imageBuffer() const final { return m_imageBuffer.get(); } |
| + |
| + bool parseColorOrCurrentColor(Color&, const String& colorString) const final; |
| + |
| + SkCanvas* drawingCanvas() const final; |
| + SkCanvas* existingDrawingCanvas() const final; |
| + void disableDeferral(DisableDeferralReason) final { } |
| + |
| + AffineTransform baseTransform() const final; |
| + |
| + void didDraw(const SkIRect& dirtyRect) final; |
| + |
| + // TODO(ikilpatrick): We'll need to either only accept resolved filters |
| + // from a typed-om <filter> object, or use the appropriate style resolution |
| + // host to determine 'em' units etc in filters. At the moment just pretend |
|
Justin Novosad
2016/03/17 18:46:10
You could just specify built-in defaults
ikilpatrick
2016/03/17 19:15:42
Sorry, I fall off quickly when it comes to filters
|
| + // that we don't have a filter set. |
| + bool stateHasFilter() final { return false; } |
| + SkImageFilter* stateGetFilter() final { return nullptr; } |
| + |
| + void validateStateStack() final; |
| + |
| + bool hasAlpha() const final { return true; } |
| + |
| + // PaintRenderingContext2D cannot lose it's context. |
| + bool isContextLost() const final { return false; } |
| + |
| +private: |
| + explicit PaintRenderingContext2D(PassOwnPtr<ImageBuffer>); |
| + |
| + OwnPtr<ImageBuffer> m_imageBuffer; |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // PaintRenderingContext2D_h |