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

Unified Diff: ui/gfx/canvas.h

Issue 9562038: ui/gfx: Make gfx::Canvas inherit from gfx::CanvasSkia. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: ui/gfx/canvas.h
diff --git a/ui/gfx/canvas.h b/ui/gfx/canvas.h
index 76926059fcdd66a5c565df62054232883a92df15..b80c1991950646a3bb4c885e1f85f8032b052efe 100644
--- a/ui/gfx/canvas.h
+++ b/ui/gfx/canvas.h
@@ -6,32 +6,12 @@
#define UI_GFX_CANVAS_H_
#pragma once
-#include <string>
-
-#include "base/string16.h"
-// TODO(beng): remove these includes when we no longer depend on SkTypes.
-#include "third_party/skia/include/core/SkColor.h"
-#include "third_party/skia/include/core/SkXfermode.h"
#include "ui/base/ui_export.h"
-#include "ui/gfx/native_widget_types.h"
-
-class SkCanvas;
-
-namespace ui {
-class Transform;
-}
+#include "ui/gfx/canvas_skia.h"
namespace gfx {
-class Brush;
-class CanvasSkia;
-class Font;
-class Point;
-class Rect;
-class Size;
-
-// TODO(beng): documentation.
-class UI_EXPORT Canvas {
+class UI_EXPORT Canvas : public CanvasSkia {
public:
// Specifies the alignment for text rendered with the DrawStringInt method.
enum {
Ben Goodger (Google) 2012/03/06 15:46:58 move all this down to CanvasSkia too
tfarina 2012/03/06 17:09:09 Done.
@@ -75,146 +55,11 @@ class UI_EXPORT Canvas {
FORCE_LTR_DIRECTIONALITY = 4096,
};
- virtual ~Canvas() {}
-
- // Saves a copy of the drawing state onto a stack, operating on this copy
- // until a balanced call to Restore() is made.
- virtual void Save() = 0;
-
- // As with Save(), except draws to a layer that is blended with the canvas
- // at the specified alpha once Restore() is called.
- // |layer_bounds| are the bounds of the layer relative to the current
- // transform.
- virtual void SaveLayerAlpha(uint8 alpha) = 0;
- virtual void SaveLayerAlpha(uint8 alpha, const gfx::Rect& layer_bounds) = 0;
-
- // Restores the drawing state after a call to Save*(). It is an error to
- // call Restore() more times than Save*().
- virtual void Restore() = 0;
-
- // Returns true if the clip is non-empty.
- virtual bool ClipRect(const gfx::Rect& rect) = 0;
-
- virtual void Translate(const gfx::Point& point) = 0;
-
- virtual void Scale(int x_scale, int y_scale) = 0;
-
- // Fills |rect| with |color| using a transfer mode of
- // SkXfermode::kSrcOver_Mode.
- virtual void FillRect(const gfx::Rect& rect, const SkColor& color) = 0;
-
- // Fills |rect| with the specified |color| and |mode|.
- virtual void FillRect(const gfx::Rect& rect,
- const SkColor& color,
- SkXfermode::Mode mode) = 0;
-
- // Fills |rect| with the specified |brush|.
- virtual void FillRect(const gfx::Rect& rect, const gfx::Brush* brush) = 0;
-
- // Draws a single pixel rect in the specified region with the specified
- // color, using a transfer mode of SkXfermode::kSrcOver_Mode.
- //
- // NOTE: if you need a single pixel line, use DrawLine.
- virtual void DrawRect(const gfx::Rect& rect, const SkColor& color) = 0;
-
- // Draws a single pixel rect in the specified region with the specified
- // color and transfer mode.
- //
- // NOTE: if you need a single pixel line, use DrawLine.
- virtual void DrawRect(const gfx::Rect& rect,
- const SkColor& color,
- SkXfermode::Mode mode) = 0;
-
- // Draws the given rectangle with the given paint's parameters.
- virtual void DrawRect(const gfx::Rect& rect, const SkPaint& paint) = 0;
-
- // Draws a single pixel line with the specified color.
- virtual void DrawLine(const gfx::Point& p1,
- const gfx::Point& p2,
- const SkColor& color) = 0;
-
- // Draws a bitmap with the origin at the specified location. The upper left
- // corner of the bitmap is rendered at the specified location.
- virtual void DrawBitmapInt(const SkBitmap& bitmap, int x, int y) = 0;
-
- // Draws a bitmap with the origin at the specified location, using the
- // specified paint. The upper left corner of the bitmap is rendered at the
- // specified location.
- virtual void DrawBitmapInt(const SkBitmap& bitmap,
- int x, int y,
- const SkPaint& paint) = 0;
-
- // Draws a portion of a bitmap in the specified location. The src parameters
- // correspond to the region of the bitmap to draw in the region defined
- // by the dest coordinates.
- //
- // If the width or height of the source differs from that of the destination,
- // the bitmap will be scaled. When scaling down, it is highly recommended
- // that you call buildMipMap(false) on your bitmap to ensure that it has
- // a mipmap, which will result in much higher-quality output. Set |filter|
- // to use filtering for bitmaps, otherwise the nearest-neighbor algorithm
- // is used for resampling.
- //
- // An optional custom SkPaint can be provided.
- 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) = 0;
- 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) = 0;
-
- // Draws text with the specified color, font and location. The text is
- // aligned to the left, vertically centered, clipped to the region. If the
- // text is too big, it is truncated and '...' is added to the end.
- virtual void DrawStringInt(const string16& text,
- const gfx::Font& font,
- const SkColor& color,
- int x, int y, int w, int h) = 0;
- virtual void DrawStringInt(const string16& text,
- const gfx::Font& font,
- const SkColor& color,
- const gfx::Rect& display_rect) = 0;
-
- // Draws text with the specified color, font and location. The last argument
- // specifies flags for how the text should be rendered. It can be one of
- // TEXT_ALIGN_CENTER, TEXT_ALIGN_RIGHT or TEXT_ALIGN_LEFT.
- virtual void DrawStringInt(const string16& text,
- const gfx::Font& font,
- const SkColor& color,
- int x, int y, int w, int h,
- int flags) = 0;
-
- // Draws a dotted gray rectangle used for focus purposes.
- virtual void DrawFocusRect(const gfx::Rect& rect) = 0;
-
- // Tiles the image in the specified region.
- virtual void TileImageInt(const SkBitmap& bitmap,
- int x, int y, int w, int h) = 0;
- virtual void TileImageInt(const SkBitmap& bitmap,
- int src_x, int src_y,
- int dest_x, int dest_y, int w, int h) = 0;
-
- // Returns a native drawing context for platform specific drawing routines to
- // use. Must be balanced by a call to EndPlatformPaint().
- virtual gfx::NativeDrawingContext BeginPlatformPaint() = 0;
-
- // Signifies the end of platform drawing using the native drawing context
- // returned by BeginPlatformPaint().
- virtual void EndPlatformPaint() = 0;
+ explicit Canvas(SkCanvas* canvas);
- // Apply transformation on the canvas.
- virtual void Transform(const ui::Transform& transform) = 0;
+ Canvas(const gfx::Size& size, bool is_opaque);
- // TODO(beng): remove this once we don't need to use any skia-specific methods
- // through this interface.
- // A quick and dirty way to obtain the underlying SkCanvas.
- virtual CanvasSkia* AsCanvasSkia();
- virtual const CanvasSkia* AsCanvasSkia() const;
- virtual SkCanvas* GetSkCanvas();
- virtual const SkCanvas* GetSkCanvas() const;
+ Canvas(const SkBitmap& bitmap, bool is_opaque);
};
} // namespace gfx

Powered by Google App Engine
This is Rietveld 408576698