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

Unified Diff: ui/gfx/canvas_skia.h

Issue 6879013: skia::PlatformCanvas is being deprecated. Going forward we will use gfx::Canvas wherever we need ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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
« no previous file with comments | « ui/base/clipboard/clipboard_win.cc ('k') | ui/gfx/canvas_skia.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/canvas_skia.h
===================================================================
--- ui/gfx/canvas_skia.h (revision 82144)
+++ ui/gfx/canvas_skia.h (working copy)
@@ -7,8 +7,8 @@
#pragma once
#include "base/basictypes.h"
+#include "base/scoped_ptr.h"
#include "base/string16.h"
-#include "skia/ext/platform_canvas.h"
#include "ui/gfx/canvas.h"
#if defined(OS_POSIX) && !defined(OS_MACOSX)
@@ -19,9 +19,9 @@
class Canvas;
-// CanvasSkia is a SkCanvas subclass that provides a number of methods for
-// common operations used throughout an application built using base/gfx and
-// app/gfx.
+// CanvasSkia is a Canvas subclass implemented using skia canvas.
+// It provides a number of methods for common operations used throughout an
+// application built using base/gfx and app/gfx.
//
// All methods that take integer arguments (as is used throughout views)
// end with Int. If you need to use methods provided by the superclass
@@ -34,8 +34,7 @@
// source and destination colors are combined. Unless otherwise specified,
// the variant that does not take a SkXfermode::Mode uses a transfer mode
// of kSrcOver_Mode.
-class CanvasSkia : public skia::PlatformCanvas,
- public Canvas {
+class CanvasSkia : public Canvas {
public:
enum TruncateFadeMode {
TruncateFadeTail,
@@ -43,12 +42,9 @@
TruncateFadeHeadAndTail,
};
- // Creates an empty Canvas. Callers must use initialize before using the
- // canvas.
+ // Creates an empty Canvas.
+ // Callers must use Init before using the canvas.
CanvasSkia();
-
- CanvasSkia(int width, int height, bool is_opaque);
-
virtual ~CanvasSkia();
// Compute the size required to draw some text with the provided font.
@@ -69,6 +65,11 @@
// gfx::Canvas::TEXT_ALIGN_RIGHT.
static int DefaultCanvasTextAlignment();
+ bool Init(int width, int height, bool is_opaque);
+
+ // Returns the underlying skia canvas.
+ SkCanvas* skia_canvas() { return skia_canvas_.get(); }
+
#if defined(OS_POSIX) && !defined(OS_MACOSX)
// Draw the pixbuf in its natural size at (x, y).
void DrawGdkPixbuf(GdkPixbuf* pixbuf, int x, int y);
@@ -163,6 +164,17 @@
virtual CanvasSkia* AsCanvasSkia();
virtual const CanvasSkia* AsCanvasSkia() const;
+ // Blits a rectangle from this canvas into the destination context.
+ // This function uses two blit modes to achieve the final color:
+ // 1. Copy: If the source canvas is opaque the color data in the source
+ // rectangle is simply copied to the destination rectangle.
+ // 2. Blend: If the source canvas is translucent, the color data in the
+ // source rectangle is blended with that in the destination
+ // rectangle.
+ void BlitToNativeContext(const Rect& src_rect,
+ const Point& dst_origin,
+ NativeDrawingContext dst_context);
+
private:
// Test whether the provided rectangle intersects the current clip rect.
bool IntersectsClipRectInt(int x, int y, int w, int h);
@@ -178,6 +190,7 @@
int flags);
#endif
+ scoped_ptr<SkCanvas> skia_canvas_;
DISALLOW_COPY_AND_ASSIGN(CanvasSkia);
};
« no previous file with comments | « ui/base/clipboard/clipboard_win.cc ('k') | ui/gfx/canvas_skia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698