Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: ui/gfx/canvas_direct2d.h

Issue 8383028: ui/gfx: Convert Canvas::ClipRectInt() to use gfx::Rect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/compiler_specific.h"
13 #include "base/win/scoped_comptr.h" 14 #include "base/win/scoped_comptr.h"
14 #include "ui/gfx/canvas.h" 15 #include "ui/gfx/canvas.h"
15 16
16 namespace gfx { 17 namespace gfx {
17 18
18 class UI_EXPORT CanvasDirect2D : public Canvas { 19 class UI_EXPORT CanvasDirect2D : public Canvas {
19 public: 20 public:
20 // Creates an empty Canvas. 21 // Creates an empty Canvas.
21 explicit CanvasDirect2D(ID2D1RenderTarget* rt); 22 explicit CanvasDirect2D(ID2D1RenderTarget* rt);
22 virtual ~CanvasDirect2D(); 23 virtual ~CanvasDirect2D();
23 24
24 // Retrieves the application's D2D1 Factory. 25 // Retrieves the application's D2D1 Factory.
25 static ID2D1Factory* GetD2D1Factory(); 26 static ID2D1Factory* GetD2D1Factory();
26 27
27 // Overridden from Canvas: 28 // Overridden from Canvas:
28 virtual void Save(); 29 virtual void Save() OVERRIDE;
29 virtual void SaveLayerAlpha(uint8 alpha); 30 virtual void SaveLayerAlpha(uint8 alpha) OVERRIDE;
30 virtual void SaveLayerAlpha(uint8 alpha, const gfx::Rect& layer_bounds); 31 virtual void SaveLayerAlpha(uint8 alpha,
31 virtual void Restore(); 32 const gfx::Rect& layer_bounds) OVERRIDE;
32 virtual bool ClipRectInt(int x, int y, int w, int h); 33 virtual void Restore() OVERRIDE;
33 virtual void TranslateInt(int x, int y); 34 virtual bool ClipRectInt(const gfx::Rect& rect) OVERRIDE;
34 virtual void ScaleInt(int x, int y); 35 virtual void TranslateInt(int x, int y) OVERRIDE;
35 virtual void FillRectInt(const SkColor& color, int x, int y, int w, int h); 36 virtual void ScaleInt(int x, int y) OVERRIDE;
36 virtual void FillRectInt(const SkColor& color, int x, int y, int w, int h, 37 virtual void FillRectInt(const SkColor& color,
37 SkXfermode::Mode mode); 38 int x, int y, int w, int h) OVERRIDE;
38 virtual void FillRectInt(const gfx::Brush* brush, int x, int y, int w, int h); 39 virtual void FillRectInt(const SkColor& color,
39 virtual void DrawRectInt(const SkColor& color, int x, int y, int w, int h); 40 int x, int y, int w, int h,
41 SkXfermode::Mode mode) OVERRIDE;
42 virtual void FillRectInt(const gfx::Brush* brush,
43 int x, int y, int w, int h) OVERRIDE;
44 virtual void DrawRectInt(const SkColor& color,
45 int x, int y, int w, int h) OVERRIDE;
40 virtual void DrawRectInt(const SkColor& color, 46 virtual void DrawRectInt(const SkColor& color,
41 int x, int y, int w, int h, 47 int x, int y, int w, int h,
42 SkXfermode::Mode mode); 48 SkXfermode::Mode mode) OVERRIDE;
43 virtual void DrawRectInt(int x, int y, int w, int h, const SkPaint& paint); 49 virtual void DrawRectInt(int x, int y, int w, int h,
50 const SkPaint& paint) OVERRIDE;
44 virtual void DrawLineInt(const SkColor& color, 51 virtual void DrawLineInt(const SkColor& color,
45 int x1, int y1, 52 int x1, int y1,
46 int x2, int y2); 53 int x2, int y2) OVERRIDE;
47 virtual void DrawBitmapInt(const SkBitmap& bitmap, int x, int y); 54 virtual void DrawBitmapInt(const SkBitmap& bitmap, int x, int y) OVERRIDE;
48 virtual void DrawBitmapInt(const SkBitmap& bitmap, 55 virtual void DrawBitmapInt(const SkBitmap& bitmap,
49 int x, int y, 56 int x, int y,
50 const SkPaint& paint); 57 const SkPaint& paint) OVERRIDE;
51 virtual void DrawBitmapInt(const SkBitmap& bitmap, 58 virtual void DrawBitmapInt(const SkBitmap& bitmap,
52 int src_x, int src_y, int src_w, int src_h, 59 int src_x, int src_y, int src_w, int src_h,
53 int dest_x, int dest_y, int dest_w, int dest_h, 60 int dest_x, int dest_y, int dest_w, int dest_h,
54 bool filter); 61 bool filter) OVERRIDE;
55 virtual void DrawBitmapInt(const SkBitmap& bitmap, 62 virtual void DrawBitmapInt(const SkBitmap& bitmap,
56 int src_x, int src_y, int src_w, int src_h, 63 int src_x, int src_y, int src_w, int src_h,
57 int dest_x, int dest_y, int dest_w, int dest_h, 64 int dest_x, int dest_y, int dest_w, int dest_h,
58 bool filter, 65 bool filter,
59 const SkPaint& paint); 66 const SkPaint& paint) OVERRIDE;
60 virtual void DrawStringInt(const string16& text, 67 virtual void DrawStringInt(const string16& text,
61 const gfx::Font& font, 68 const gfx::Font& font,
62 const SkColor& color, 69 const SkColor& color,
63 int x, int y, int w, int h); 70 int x, int y, int w, int h) OVERRIDE;
64 virtual void DrawStringInt(const string16& text, 71 virtual void DrawStringInt(const string16& text,
65 const gfx::Font& font, 72 const gfx::Font& font,
66 const SkColor& color, 73 const SkColor& color,
67 const gfx::Rect& display_rect); 74 const gfx::Rect& display_rect) OVERRIDE;
68 virtual void DrawStringInt(const string16& text, 75 virtual void DrawStringInt(const string16& text,
69 const gfx::Font& font, 76 const gfx::Font& font,
70 const SkColor& color, 77 const SkColor& color,
71 int x, int y, int w, int h, 78 int x, int y, int w, int h,
72 int flags); 79 int flags) OVERRIDE;
73 virtual void DrawFocusRect(const gfx::Rect& rect); 80 virtual void DrawFocusRect(const gfx::Rect& rect) OVERRIDE;
74 virtual void TileImageInt(const SkBitmap& bitmap, int x, int y, int w, int h); 81 virtual void TileImageInt(const SkBitmap& bitmap,
82 int x, int y, int w, int h) OVERRIDE;
75 virtual void TileImageInt(const SkBitmap& bitmap, 83 virtual void TileImageInt(const SkBitmap& bitmap,
76 int src_x, int src_y, 84 int src_x, int src_y,
77 int dest_x, int dest_y, int w, int h); 85 int dest_x, int dest_y, int w, int h) OVERRIDE;
78 virtual gfx::NativeDrawingContext BeginPlatformPaint(); 86 virtual gfx::NativeDrawingContext BeginPlatformPaint() OVERRIDE;
79 virtual void EndPlatformPaint(); 87 virtual void EndPlatformPaint() OVERRIDE;
80 virtual void Transform(const ui::Transform& transform); 88 virtual void Transform(const ui::Transform& transform) OVERRIDE;
81 virtual ui::TextureID GetTextureID(); 89 virtual ui::TextureID GetTextureID() OVERRIDE;
82 virtual CanvasSkia* AsCanvasSkia(); 90 virtual CanvasSkia* AsCanvasSkia() OVERRIDE;
83 virtual const CanvasSkia* AsCanvasSkia() const; 91 virtual const CanvasSkia* AsCanvasSkia() const OVERRIDE;
84 92
85 private: 93 private:
86 void SaveInternal(ID2D1Layer* layer); 94 void SaveInternal(ID2D1Layer* layer);
87 95
88 ID2D1RenderTarget* rt_; 96 ID2D1RenderTarget* rt_;
89 base::win::ScopedComPtr<ID2D1GdiInteropRenderTarget> interop_rt_; 97 base::win::ScopedComPtr<ID2D1GdiInteropRenderTarget> interop_rt_;
90 base::win::ScopedComPtr<ID2D1DrawingStateBlock> drawing_state_block_; 98 base::win::ScopedComPtr<ID2D1DrawingStateBlock> drawing_state_block_;
91 static ID2D1Factory* d2d1_factory_; 99 static ID2D1Factory* d2d1_factory_;
92 100
93 // Every time Save* is called, a RenderState object is pushed onto the 101 // Every time Save* is called, a RenderState object is pushed onto the
(...skipping 11 matching lines...) Expand all
105 int clip_count; 113 int clip_count;
106 }; 114 };
107 std::stack<RenderState> state_; 115 std::stack<RenderState> state_;
108 116
109 DISALLOW_COPY_AND_ASSIGN(CanvasDirect2D); 117 DISALLOW_COPY_AND_ASSIGN(CanvasDirect2D);
110 }; 118 };
111 119
112 } // namespace gfx; 120 } // namespace gfx;
113 121
114 #endif // UI_GFX_CANVAS_DIRECT2D_H_ 122 #endif // UI_GFX_CANVAS_DIRECT2D_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698