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

Unified Diff: ui/compositor/canvas_painter.cc

Issue 1161933007: ui: Introduce CanvasPainter, remove PaintContext(gfx::Canvas*). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: canvaspainter: . Created 5 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
« no previous file with comments | « ui/compositor/canvas_painter.h ('k') | ui/compositor/compositor.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/canvas_painter.cc
diff --git a/ui/compositor/canvas_painter.cc b/ui/compositor/canvas_painter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ff187d96eebc421b412bf8591910f77d858c4805
--- /dev/null
+++ b/ui/compositor/canvas_painter.cc
@@ -0,0 +1,29 @@
+// Copyright 2015 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/compositor/canvas_painter.h"
+
+#include "cc/playback/display_item_list.h"
+#include "cc/playback/display_item_list_settings.h"
+#include "ui/gfx/canvas.h"
+
+namespace ui {
+
+CanvasPainter::CanvasPainter(gfx::Canvas* canvas, float raster_scale_factor)
+ : canvas_(canvas),
+ raster_scale_factor_(raster_scale_factor),
+ rect_(gfx::ScaleToEnclosedRect(
+ gfx::Rect(canvas_->sk_canvas()->getBaseLayerSize().width(),
+ canvas_->sk_canvas()->getBaseLayerSize().height()),
+ 1.f / raster_scale_factor)),
+ list_(cc::DisplayItemList::Create(rect_, cc::DisplayItemListSettings())),
+ context_(list_.get(), raster_scale_factor_, rect_, rect_) {
+}
+
+CanvasPainter::~CanvasPainter() {
+ list_->Finalize();
+ list_->Raster(canvas_->sk_canvas(), nullptr, rect_, raster_scale_factor_);
+}
+
+} // namespace ui
« no previous file with comments | « ui/compositor/canvas_painter.h ('k') | ui/compositor/compositor.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698