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

Unified Diff: ui/gfx/canvas_skia_paint_win.cc

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/gfx/canvas_skia_paint_win.h ('k') | ui/gfx/canvas_skia_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/canvas_skia_paint_win.cc
===================================================================
--- ui/gfx/canvas_skia_paint_win.cc (revision 0)
+++ ui/gfx/canvas_skia_paint_win.cc (revision 0)
@@ -0,0 +1,62 @@
+// Copyright (c) 2011 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.
+
+#include "ui/gfx/canvas_skia_paint_win.h"
+
+#include "base/logging.h"
+#include "ui/gfx/canvas_skia.h"
+#include "ui/gfx/rect.h"
+
+namespace gfx {
+
+CanvasSkiaPaint::CanvasSkiaPaint(gfx::NativeView view) : hwnd_(view) {
+ memset(&ps_, 0, sizeof(ps_));
+
+ paint_dc_ = BeginPaint(hwnd_, &ps_);
+ CHECK(InitCanvas());
+}
+
+CanvasSkiaPaint::~CanvasSkiaPaint() {
+ canvas_->skia_canvas()->restoreToCount(1);
+
+ // Commit the drawing to the screen.
+ Rect rect = GetInvalidRect();
+ canvas_->BlitToNativeContext(
+ gfx::Rect(rect.size()), rect.origin(), paint_dc_);
+
+ EndPaint(hwnd_, &ps_);
+}
+
+bool CanvasSkiaPaint::IsValid() const {
+ return GetInvalidRect().IsEmpty();
+}
+
+gfx::Rect CanvasSkiaPaint::GetInvalidRect() const {
+ return gfx::Rect(ps_.rcPaint);
+}
+
+Canvas* CanvasSkiaPaint::AsCanvas() {
+ return canvas_.get();
+}
+
+bool CanvasSkiaPaint::InitCanvas() {
+ canvas_.reset(new CanvasSkia);
+ // FIXME(brettw) for ClearType, we probably want to expand the bounds of
+ // painting by one pixel so that the boundaries will be correct (ClearType
+ // text can depend on the adjacent pixel). Then we would paint just the
+ // inset pixels to the screen.
+ const int width = ps_.rcPaint.right - ps_.rcPaint.left;
+ const int height = ps_.rcPaint.bottom - ps_.rcPaint.top;
+ if (!canvas_->Init(width, height, true))
+ return false;
+
+ // This will bring the canvas into the screen coordinate system for the
+ // dirty rect
+ canvas_->skia_canvas()->translate(SkIntToScalar(-ps_.rcPaint.left),
+ SkIntToScalar(-ps_.rcPaint.top));
+ return true;
+}
+
+} // namespace gfx
+
Property changes on: ui\gfx\canvas_skia_paint_win.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « ui/gfx/canvas_skia_paint_win.h ('k') | ui/gfx/canvas_skia_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698