diff options
author | sail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-02 23:03:07 +0000 |
---|---|---|
committer | sail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-02 23:03:07 +0000 |
commit | 267c03d478d9c83ef8c37999f3abb1cd822881ff (patch) | |
tree | 6286c650d0ec58cdee9c7482fda929252bd985b5 /ui/gfx/canvas_direct2d.h | |
parent | 7c085463177741a3844215675577bba3de1be836 (diff) | |
download | chromium_src-267c03d478d9c83ef8c37999f3abb1cd822881ff.zip chromium_src-267c03d478d9c83ef8c37999f3abb1cd822881ff.tar.gz chromium_src-267c03d478d9c83ef8c37999f3abb1cd822881ff.tar.bz2 |
Move src/gfx/ to src/ui/gfx
To reduce the size of this change I've left stub header files in src/gfx/. Once all includes have been updated I'll delete the stub files.
BUG=71063
TEST=Still doing test builds.
Review URL: http://codereview.chromium.org/6246027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73530 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/canvas_direct2d.h')
-rw-r--r-- | ui/gfx/canvas_direct2d.h | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/ui/gfx/canvas_direct2d.h b/ui/gfx/canvas_direct2d.h new file mode 100644 index 0000000..101688a --- /dev/null +++ b/ui/gfx/canvas_direct2d.h @@ -0,0 +1,112 @@ +// Copyright (c) 2010 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 UI_GFX_CANVAS_DIRECT2D_H_ +#define UI_GFX_CANVAS_DIRECT2D_H_ +#pragma once + +#include <d2d1.h> + +#include <stack> + +#include "base/scoped_comptr_win.h" +#include "gfx/canvas.h" + +namespace gfx { + +class CanvasDirect2D : public Canvas { + public: + // Creates an empty Canvas. + explicit CanvasDirect2D(ID2D1RenderTarget* rt); + virtual ~CanvasDirect2D(); + + // Retrieves the application's D2D1 Factory. + static ID2D1Factory* GetD2D1Factory(); + + // Overridden from Canvas: + virtual void Save(); + virtual void SaveLayerAlpha(uint8 alpha); + virtual void SaveLayerAlpha(uint8 alpha, const gfx::Rect& layer_bounds); + virtual void Restore(); + virtual bool ClipRectInt(int x, int y, int w, int h); + virtual void TranslateInt(int x, int y); + virtual void ScaleInt(int x, int y); + virtual void FillRectInt(const SkColor& color, int x, int y, int w, int h); + virtual void FillRectInt(const SkColor& color, int x, int y, int w, int h, + SkXfermode::Mode mode); + virtual void FillRectInt(const gfx::Brush* brush, int x, int y, int w, int h); + virtual void DrawRectInt(const SkColor& color, int x, int y, int w, int h); + virtual void DrawRectInt(const SkColor& color, + int x, int y, int w, int h, + SkXfermode::Mode mode); + virtual void DrawRectInt(int x, int y, int w, int h, const SkPaint& paint); + virtual void DrawLineInt(const SkColor& color, + int x1, int y1, + int x2, int y2); + virtual void DrawBitmapInt(const SkBitmap& bitmap, int x, int y); + virtual void DrawBitmapInt(const SkBitmap& bitmap, + int x, int y, + const SkPaint& paint); + virtual void DrawBitmapInt(const SkBitmap& bitmap, + int src_x, int src_y, int src_w, int src_h, + int dest_x, int dest_y, int dest_w, int dest_h, + bool filter); + virtual void DrawBitmapInt(const SkBitmap& bitmap, + int src_x, int src_y, int src_w, int src_h, + int dest_x, int dest_y, int dest_w, int dest_h, + bool filter, + const SkPaint& paint); + virtual void DrawStringInt(const string16& text, + const gfx::Font& font, + const SkColor& color, + int x, int y, int w, int h); + virtual void DrawStringInt(const string16& text, + const gfx::Font& font, + const SkColor& color, + const gfx::Rect& display_rect); + virtual void DrawStringInt(const string16& text, + const gfx::Font& font, + const SkColor& color, + int x, int y, int w, int h, + int flags); + virtual void DrawFocusRect(int x, int y, int width, int height); + virtual void TileImageInt(const SkBitmap& bitmap, int x, int y, int w, int h); + virtual void TileImageInt(const SkBitmap& bitmap, + int src_x, int src_y, + int dest_x, int dest_y, int w, int h); + virtual gfx::NativeDrawingContext BeginPlatformPaint(); + virtual void EndPlatformPaint(); + virtual CanvasSkia* AsCanvasSkia(); + virtual const CanvasSkia* AsCanvasSkia() const; + + private: + void SaveInternal(ID2D1Layer* layer); + + ID2D1RenderTarget* rt_; + ScopedComPtr<ID2D1GdiInteropRenderTarget> interop_rt_; + ScopedComPtr<ID2D1DrawingStateBlock> drawing_state_block_; + static ID2D1Factory* d2d1_factory_; + + // Every time Save* is called, a RenderState object is pushed onto the + // RenderState stack. + struct RenderState { + explicit RenderState(ID2D1Layer* layer) : layer(layer), clip_count(0) {} + RenderState() : layer(NULL), clip_count(0) {} + + // A D2D layer associated with this state, or NULL if there is no layer. + // The layer is created and owned by the Canvas. + ID2D1Layer* layer; + // The number of clip operations performed. This is used to balance calls to + // PushAxisAlignedClip with calls to PopAxisAlignedClip when Restore() is + // called. + int clip_count; + }; + std::stack<RenderState> state_; + + DISALLOW_COPY_AND_ASSIGN(CanvasDirect2D); +}; + +} // namespace gfx; + +#endif // UI_GFX_CANVAS_DIRECT2D_H_ |