| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 GFX_CANVAS_DIRECT2D_H_ | 5 #ifndef GFX_CANVAS_DIRECT2D_H_ |
| 6 #define GFX_CANVAS_DIRECT2D_H_ | 6 #define GFX_CANVAS_DIRECT2D_H_ |
| 7 | 7 |
| 8 #include <d2d1.h> | 8 #include <d2d1.h> |
| 9 | 9 |
| 10 #include <stack> | 10 #include <stack> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 virtual ~CanvasDirect2D(); | 21 virtual ~CanvasDirect2D(); |
| 22 | 22 |
| 23 // Retrieves the application's D2D1 Factory. | 23 // Retrieves the application's D2D1 Factory. |
| 24 static ID2D1Factory* GetD2D1Factory(); | 24 static ID2D1Factory* GetD2D1Factory(); |
| 25 | 25 |
| 26 // Overridden from Canvas: | 26 // Overridden from Canvas: |
| 27 virtual void Save(); | 27 virtual void Save(); |
| 28 virtual void SaveLayerAlpha(uint8 alpha); | 28 virtual void SaveLayerAlpha(uint8 alpha); |
| 29 virtual void SaveLayerAlpha(uint8 alpha, const gfx::Rect& layer_bounds); | 29 virtual void SaveLayerAlpha(uint8 alpha, const gfx::Rect& layer_bounds); |
| 30 virtual void Restore(); | 30 virtual void Restore(); |
| 31 virtual bool GetClipRect(gfx::Rect* clip_rect); | |
| 32 virtual bool ClipRectInt(int x, int y, int w, int h); | 31 virtual bool ClipRectInt(int x, int y, int w, int h); |
| 33 virtual bool IntersectsClipRectInt(int x, int y, int w, int h); | |
| 34 virtual void TranslateInt(int x, int y); | 32 virtual void TranslateInt(int x, int y); |
| 35 virtual void ScaleInt(int x, int y); | 33 virtual void ScaleInt(int x, int y); |
| 36 virtual void FillRectInt(int x, int y, int w, int h, | 34 virtual void FillRectInt(int x, int y, int w, int h, |
| 37 const SkPaint& paint); | 35 const SkPaint& paint); |
| 38 virtual void FillRectInt(const SkColor& color, int x, int y, int w, | 36 virtual void FillRectInt(const SkColor& color, int x, int y, int w, |
| 39 int h); | 37 int h); |
| 40 virtual void DrawRectInt(const SkColor& color, int x, int y, int w, | 38 virtual void DrawRectInt(const SkColor& color, int x, int y, int w, |
| 41 int h); | 39 int h); |
| 42 virtual void DrawRectInt(const SkColor& color, int x, int y, int w, int h, | 40 virtual void DrawRectInt(const SkColor& color, int x, int y, int w, int h, |
| 43 SkXfermode::Mode mode); | 41 SkXfermode::Mode mode); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 65 virtual void DrawFocusRect(int x, int y, int width, int height); | 63 virtual void DrawFocusRect(int x, int y, int width, int height); |
| 66 virtual void TileImageInt(const SkBitmap& bitmap, int x, int y, int w, int h); | 64 virtual void TileImageInt(const SkBitmap& bitmap, int x, int y, int w, int h); |
| 67 virtual void TileImageInt(const SkBitmap& bitmap, int src_x, int src_y, | 65 virtual void TileImageInt(const SkBitmap& bitmap, int src_x, int src_y, |
| 68 int dest_x, int dest_y, int w, int h); | 66 int dest_x, int dest_y, int w, int h); |
| 69 virtual gfx::NativeDrawingContext BeginPlatformPaint(); | 67 virtual gfx::NativeDrawingContext BeginPlatformPaint(); |
| 70 virtual void EndPlatformPaint(); | 68 virtual void EndPlatformPaint(); |
| 71 virtual CanvasSkia* AsCanvasSkia(); | 69 virtual CanvasSkia* AsCanvasSkia(); |
| 72 virtual const CanvasSkia* AsCanvasSkia() const; | 70 virtual const CanvasSkia* AsCanvasSkia() const; |
| 73 | 71 |
| 74 private: | 72 private: |
| 73 void SaveInternal(ID2D1Layer* layer); |
| 74 |
| 75 ID2D1RenderTarget* rt_; | 75 ID2D1RenderTarget* rt_; |
| 76 ScopedComPtr<ID2D1GdiInteropRenderTarget> interop_rt_; | 76 ScopedComPtr<ID2D1GdiInteropRenderTarget> interop_rt_; |
| 77 ScopedComPtr<ID2D1DrawingStateBlock> drawing_state_block_; | 77 ScopedComPtr<ID2D1DrawingStateBlock> drawing_state_block_; |
| 78 static ID2D1Factory* d2d1_factory_; | 78 static ID2D1Factory* d2d1_factory_; |
| 79 std::stack<ID2D1Layer*> layers_; | 79 |
| 80 // Every time Save* is called, a RenderState object is pushed onto the |
| 81 // RenderState stack. |
| 82 struct RenderState { |
| 83 explicit RenderState(ID2D1Layer* layer) : layer(layer), clip_count(0) {} |
| 84 RenderState() : layer(NULL), clip_count(0) {} |
| 85 |
| 86 // A D2D layer associated with this state, or NULL if there is no layer. |
| 87 // The layer is created and owned by the Canvas. |
| 88 ID2D1Layer* layer; |
| 89 // The number of clip operations performed. This is used to balance calls to |
| 90 // PushAxisAlignedClip with calls to PopAxisAlignedClip when Restore() is |
| 91 // called. |
| 92 int clip_count; |
| 93 }; |
| 94 std::stack<RenderState> state_; |
| 80 | 95 |
| 81 DISALLOW_COPY_AND_ASSIGN(CanvasDirect2D); | 96 DISALLOW_COPY_AND_ASSIGN(CanvasDirect2D); |
| 82 }; | 97 }; |
| 83 | 98 |
| 84 } // namespace gfx; | 99 } // namespace gfx; |
| 85 | 100 |
| 86 #endif // GFX_CANVAS_DIRECT2D_H_ | 101 #endif // GFX_CANVAS_DIRECT2D_H_ |
| OLD | NEW |