| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 UI_GFX_CANVAS_DIRECT2D_H_ | 5 #ifndef UI_GFX_CANVAS_DIRECT2D_H_ |
| 6 #define UI_GFX_CANVAS_DIRECT2D_H_ | 6 #define UI_GFX_CANVAS_DIRECT2D_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <d2d1.h> | 9 #include <d2d1.h> |
| 10 | 10 |
| 11 #include <stack> | 11 #include <stack> |
| 12 | 12 |
| 13 #include "base/scoped_comptr_win.h" | 13 #include "base/win/scoped_comptr.h" |
| 14 #include "ui/gfx/canvas.h" | 14 #include "ui/gfx/canvas.h" |
| 15 | 15 |
| 16 namespace gfx { | 16 namespace gfx { |
| 17 | 17 |
| 18 class CanvasDirect2D : public Canvas { | 18 class CanvasDirect2D : public Canvas { |
| 19 public: | 19 public: |
| 20 // Creates an empty Canvas. | 20 // Creates an empty Canvas. |
| 21 explicit CanvasDirect2D(ID2D1RenderTarget* rt); | 21 explicit CanvasDirect2D(ID2D1RenderTarget* rt); |
| 22 virtual ~CanvasDirect2D(); | 22 virtual ~CanvasDirect2D(); |
| 23 | 23 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 virtual void EndPlatformPaint(); | 79 virtual void EndPlatformPaint(); |
| 80 virtual void Transform(const ui::Transform& transform); | 80 virtual void Transform(const ui::Transform& transform); |
| 81 virtual ui::TextureID GetTextureID(); | 81 virtual ui::TextureID GetTextureID(); |
| 82 virtual CanvasSkia* AsCanvasSkia(); | 82 virtual CanvasSkia* AsCanvasSkia(); |
| 83 virtual const CanvasSkia* AsCanvasSkia() const; | 83 virtual const CanvasSkia* AsCanvasSkia() const; |
| 84 | 84 |
| 85 private: | 85 private: |
| 86 void SaveInternal(ID2D1Layer* layer); | 86 void SaveInternal(ID2D1Layer* layer); |
| 87 | 87 |
| 88 ID2D1RenderTarget* rt_; | 88 ID2D1RenderTarget* rt_; |
| 89 ScopedComPtr<ID2D1GdiInteropRenderTarget> interop_rt_; | 89 base::win::ScopedComPtr<ID2D1GdiInteropRenderTarget> interop_rt_; |
| 90 ScopedComPtr<ID2D1DrawingStateBlock> drawing_state_block_; | 90 base::win::ScopedComPtr<ID2D1DrawingStateBlock> drawing_state_block_; |
| 91 static ID2D1Factory* d2d1_factory_; | 91 static ID2D1Factory* d2d1_factory_; |
| 92 | 92 |
| 93 // Every time Save* is called, a RenderState object is pushed onto the | 93 // Every time Save* is called, a RenderState object is pushed onto the |
| 94 // RenderState stack. | 94 // RenderState stack. |
| 95 struct RenderState { | 95 struct RenderState { |
| 96 explicit RenderState(ID2D1Layer* layer) : layer(layer), clip_count(0) {} | 96 explicit RenderState(ID2D1Layer* layer) : layer(layer), clip_count(0) {} |
| 97 RenderState() : layer(NULL), clip_count(0) {} | 97 RenderState() : layer(NULL), clip_count(0) {} |
| 98 | 98 |
| 99 // A D2D layer associated with this state, or NULL if there is no layer. | 99 // A D2D layer associated with this state, or NULL if there is no layer. |
| 100 // The layer is created and owned by the Canvas. | 100 // The layer is created and owned by the Canvas. |
| 101 ID2D1Layer* layer; | 101 ID2D1Layer* layer; |
| 102 // The number of clip operations performed. This is used to balance calls to | 102 // The number of clip operations performed. This is used to balance calls to |
| 103 // PushAxisAlignedClip with calls to PopAxisAlignedClip when Restore() is | 103 // PushAxisAlignedClip with calls to PopAxisAlignedClip when Restore() is |
| 104 // called. | 104 // called. |
| 105 int clip_count; | 105 int clip_count; |
| 106 }; | 106 }; |
| 107 std::stack<RenderState> state_; | 107 std::stack<RenderState> state_; |
| 108 | 108 |
| 109 DISALLOW_COPY_AND_ASSIGN(CanvasDirect2D); | 109 DISALLOW_COPY_AND_ASSIGN(CanvasDirect2D); |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 } // namespace gfx; | 112 } // namespace gfx; |
| 113 | 113 |
| 114 #endif // UI_GFX_CANVAS_DIRECT2D_H_ | 114 #endif // UI_GFX_CANVAS_DIRECT2D_H_ |
| OLD | NEW |