Chromium Code Reviews| 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 #ifndef PaintRenderingContext2D_h | 5 #ifndef PaintRenderingContext2D_h |
| 6 #define PaintRenderingContext2D_h | 6 #define PaintRenderingContext2D_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptWrappable.h" | 8 #include "bindings/core/v8/ScriptWrappable.h" |
| 9 #include "modules/ModulesExport.h" | 9 #include "modules/ModulesExport.h" |
| 10 #include "modules/canvas2d/BaseRenderingContext2D.h" | 10 #include "modules/canvas2d/BaseRenderingContext2D.h" |
| 11 #include "platform/graphics/ImageBuffer.h" | 11 #include "platform/graphics/ImageBuffer.h" |
| 12 #include <memory> | 12 #include <memory> |
| 13 | 13 |
| 14 class SkCanvas; | 14 class SkCanvas; |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 class CanvasImageSource; | 18 class CanvasImageSource; |
| 19 class Color; | 19 class Color; |
| 20 | 20 |
| 21 class MODULES_EXPORT PaintRenderingContext2D : public BaseRenderingContext2D, pu blic GarbageCollectedFinalized<PaintRenderingContext2D>, public ScriptWrappable { | 21 class MODULES_EXPORT PaintRenderingContext2D : public BaseRenderingContext2D, pu blic GarbageCollectedFinalized<PaintRenderingContext2D>, public ScriptWrappable { |
| 22 DEFINE_WRAPPERTYPEINFO(); | 22 DEFINE_WRAPPERTYPEINFO(); |
| 23 USING_GARBAGE_COLLECTED_MIXIN(PaintRenderingContext2D); | 23 USING_GARBAGE_COLLECTED_MIXIN(PaintRenderingContext2D); |
| 24 WTF_MAKE_NONCOPYABLE(PaintRenderingContext2D); | 24 WTF_MAKE_NONCOPYABLE(PaintRenderingContext2D); |
| 25 public: | 25 public: |
| 26 static PaintRenderingContext2D* create(std::unique_ptr<ImageBuffer> imageBuf fer) | 26 static PaintRenderingContext2D* create(std::unique_ptr<ImageBuffer> imageBuf fer, bool hasAlphaChannel) |
| 27 { | 27 { |
| 28 return new PaintRenderingContext2D(std::move(imageBuffer)); | 28 return new PaintRenderingContext2D(std::move(imageBuffer), hasAlphaChann el); |
| 29 } | 29 } |
| 30 | 30 |
| 31 // BaseRenderingContext2D | 31 // BaseRenderingContext2D |
| 32 | 32 |
| 33 // PaintRenderingContext2D doesn't have any pixel readback so the origin | 33 // PaintRenderingContext2D doesn't have any pixel readback so the origin |
| 34 // is always clean, and unable to taint it. | 34 // is always clean, and unable to taint it. |
| 35 bool originClean() const final { return true; } | 35 bool originClean() const final { return true; } |
| 36 void setOriginTainted() final { } | 36 void setOriginTainted() final { } |
| 37 bool wouldTaintOrigin(CanvasImageSource*, ExecutionContext*) final { return false; } | 37 bool wouldTaintOrigin(CanvasImageSource*, ExecutionContext*) final { return false; } |
| 38 | 38 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 55 // TODO(ikilpatrick): We'll need to either only accept resolved filters | 55 // TODO(ikilpatrick): We'll need to either only accept resolved filters |
| 56 // from a typed-om <filter> object, or use the appropriate style resolution | 56 // from a typed-om <filter> object, or use the appropriate style resolution |
| 57 // host to determine 'em' units etc in filters. At the moment just pretend | 57 // host to determine 'em' units etc in filters. At the moment just pretend |
| 58 // that we don't have a filter set. | 58 // that we don't have a filter set. |
| 59 bool stateHasFilter() final { return false; } | 59 bool stateHasFilter() final { return false; } |
| 60 SkImageFilter* stateGetFilter() final { return nullptr; } | 60 SkImageFilter* stateGetFilter() final { return nullptr; } |
| 61 void snapshotStateForFilter() final { } | 61 void snapshotStateForFilter() final { } |
| 62 | 62 |
| 63 void validateStateStack() final; | 63 void validateStateStack() final; |
| 64 | 64 |
| 65 bool hasAlpha() const final { return true; } | 65 bool hasAlpha() const final { return m_hasAlphaChannel; } |
|
ikilpatrick
2016/06/22 16:00:24
we can probably remove this virtual method now.
T
Gleb Lanbin
2016/06/22 21:23:45
hasAlpha is declared as a pure virtual method in B
| |
| 66 | 66 |
| 67 // PaintRenderingContext2D cannot lose it's context. | 67 // PaintRenderingContext2D cannot lose it's context. |
| 68 bool isContextLost() const final { return false; } | 68 bool isContextLost() const final { return false; } |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 explicit PaintRenderingContext2D(std::unique_ptr<ImageBuffer>); | 71 PaintRenderingContext2D(std::unique_ptr<ImageBuffer>, bool hasAlphaChannel); |
| 72 | 72 |
| 73 std::unique_ptr<ImageBuffer> m_imageBuffer; | 73 std::unique_ptr<ImageBuffer> m_imageBuffer; |
| 74 bool m_hasAlphaChannel; | |
| 74 }; | 75 }; |
| 75 | 76 |
| 76 } // namespace blink | 77 } // namespace blink |
| 77 | 78 |
| 78 #endif // PaintRenderingContext2D_h | 79 #endif // PaintRenderingContext2D_h |
| OLD | NEW |