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

Unified Diff: ui/gfx/canvas_skia_win.cc

Issue 7265011: RenderText API Outline. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add some placeholder functionality on Windows. Created 9 years, 6 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_skia_win.cc
diff --git a/ui/gfx/canvas_skia_win.cc b/ui/gfx/canvas_skia_win.cc
index 76fe318f117efe0ad2882f72122a26e4e1f816df..65ea67d5e791d948bf27e3fe02d39efe764bb34d 100644
--- a/ui/gfx/canvas_skia_win.cc
+++ b/ui/gfx/canvas_skia_win.cc
@@ -16,6 +16,7 @@
#include "ui/gfx/color_utils.h"
#include "ui/gfx/font.h"
#include "ui/gfx/rect.h"
+#include "ui/gfx/render_text.h"
namespace {
@@ -380,6 +381,45 @@ void CanvasSkia::DrawStringInt(const string16& text,
DrawStringInt(text, font.GetNativeFont(), color, x, y, w, h, flags);
}
+// TODO(msw): Copied from another DrawStringInt. Dig in, understand, and unify.
+void CanvasSkia::DrawStringInt(const gfx::RenderText& render_text) {
+ SkRect fclip;
+ if (!getClipBounds(&fclip))
+ return;
+ const gfx::Rect& r = render_text.get_display_rect();
+ RECT text_bounds = { r.x(), r.y(), r.x() + r.width(), r.y() + r.height() };
+ SkIRect clip;
+ fclip.round(&clip);
+ if (!clip.intersect(skia::RECTToSkIRect(text_bounds)))
+ return;
+
+ // TODO(msw): Necessary with Uniscribe?
+ // Clamp the max amount of text we'll draw to 32K. There seem to be bugs in
+ // DrawText() if you e.g. ask it to character-break a no-whitespace string of
+ // length > 43680 (for which it draws nothing), and since we clamped to 2K in
+ // SizeStringInt() we're unlikely to be able to display this much anyway.
+ const int kMaxStringLength = 32768 - 1; // So the trailing \0 fits in 32K.
+ string16 clamped_string(render_text.text().substr(0, kMaxStringLength));
+
+ HDC dc;
+ {
+ // TODO(msw): Fix.
+ skia::ScopedPlatformPaint scoped_platform_paint(this);
+ dc = scoped_platform_paint.GetPlatformSurface();
+ SetBkMode(dc, TRANSPARENT);
+ //int f = ComputeFormatFlags(flags, clamped_string);
+ //DoDrawText(dc, clamped_string, &text_bounds, f);
+ render_text.Draw(dc);
+ }
+
+ // TODO(msw): Necessary with Uniscribe?
+ // Windows will have cleared the alpha channel of the text we drew. Assume
+ // we're drawing to an opaque surface, or at least the text rect area is
+ // opaque.
+ skia::MakeOpaque(this, clip.fLeft, clip.fTop, clip.width(),
+ clip.height());
+}
+
// Checks each pixel immediately adjacent to the given pixel in the bitmap. If
// any of them are not the halo color, returns true. This defines the halo of
// pixels that will appear around the text. Note that we have to check each
« no previous file with comments | « ui/gfx/canvas_skia_mac.mm ('k') | ui/gfx/render_text.h » ('j') | ui/gfx/render_text.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698