| 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
|
|
|
|
|