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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/gfx/canvas_skia_paint_win.h"
6
7 #include "base/logging.h"
8 #include "ui/gfx/canvas_skia.h"
9 #include "ui/gfx/rect.h"
10
11 namespace gfx {
12
13 CanvasSkiaPaint::CanvasSkiaPaint(gfx::NativeView view) : hwnd_(view) {
14 memset(&ps_, 0, sizeof(ps_));
15
16 paint_dc_ = BeginPaint(hwnd_, &ps_);
17 CHECK(InitCanvas());
18 }
19
20 CanvasSkiaPaint::~CanvasSkiaPaint() {
21 canvas_->skia_canvas()->restoreToCount(1);
22
23 // Commit the drawing to the screen.
24 Rect rect = GetInvalidRect();
25 canvas_->BlitToNativeContext(
26 gfx::Rect(rect.size()), rect.origin(), paint_dc_);
27
28 EndPaint(hwnd_, &ps_);
29 }
30
31 bool CanvasSkiaPaint::IsValid() const {
32 return GetInvalidRect().IsEmpty();
33 }
34
35 gfx::Rect CanvasSkiaPaint::GetInvalidRect() const {
36 return gfx::Rect(ps_.rcPaint);
37 }
38
39 Canvas* CanvasSkiaPaint::AsCanvas() {
40 return canvas_.get();
41 }
42
43 bool CanvasSkiaPaint::InitCanvas() {
44 canvas_.reset(new CanvasSkia);
45 // FIXME(brettw) for ClearType, we probably want to expand the bounds of
46 // painting by one pixel so that the boundaries will be correct (ClearType
47 // text can depend on the adjacent pixel). Then we would paint just the
48 // inset pixels to the screen.
49 const int width = ps_.rcPaint.right - ps_.rcPaint.left;
50 const int height = ps_.rcPaint.bottom - ps_.rcPaint.top;
51 if (!canvas_->Init(width, height, true))
52 return false;
53
54 // This will bring the canvas into the screen coordinate system for the
55 // dirty rect
56 canvas_->skia_canvas()->translate(SkIntToScalar(-ps_.rcPaint.left),
57 SkIntToScalar(-ps_.rcPaint.top));
58 return true;
59 }
60
61 } // namespace gfx
62
OLDNEW
« 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