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

Side by Side Diff: ui/compositor/canvas_painter.cc

Issue 2877483003: Implements core logic for Pixel Canvas (Closed)
Patch Set: nits Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/compositor/canvas_painter.h" 5 #include "ui/compositor/canvas_painter.h"
6 6
7 #include "cc/paint/display_item_list.h" 7 #include "cc/paint/display_item_list.h"
8 8
9 namespace ui { 9 namespace ui {
10 10
11 CanvasPainter::CanvasPainter(SkBitmap* output, 11 CanvasPainter::CanvasPainter(SkBitmap* output,
12 const gfx::Size& paint_size, 12 const gfx::Size& paint_size,
13 float raster_scale, 13 float raster_scale,
14 SkColor clear_color) 14 SkColor clear_color)
15 : output_(output), 15 : output_(output),
16 paint_size_(paint_size), 16 paint_size_(paint_size),
17 raster_scale_(raster_scale), 17 raster_scale_(raster_scale),
18 clear_color_(clear_color), 18 clear_color_(clear_color),
19 list_(new cc::DisplayItemList), 19 list_(new cc::DisplayItemList),
20 context_(list_.get(), raster_scale, gfx::Rect(paint_size_)) {} 20 context_(list_.get(), raster_scale, gfx::Rect(paint_size_), paint_size_) {
21 }
21 22
22 CanvasPainter::~CanvasPainter() { 23 CanvasPainter::~CanvasPainter() {
23 gfx::Size pixel_size = gfx::ScaleToCeiledSize(paint_size_, raster_scale_); 24 gfx::Size pixel_size = gfx::ScaleToCeiledSize(paint_size_, raster_scale_);
24 SkImageInfo info = SkImageInfo::MakeN32( 25 SkImageInfo info = SkImageInfo::MakeN32(
25 pixel_size.width(), pixel_size.height(), kPremul_SkAlphaType); 26 pixel_size.width(), pixel_size.height(), kPremul_SkAlphaType);
26 if (!output_->tryAllocPixels(info)) 27 if (!output_->tryAllocPixels(info))
27 return; 28 return;
28 29
29 SkCanvas canvas(*output_); 30 SkCanvas canvas(*output_);
30 canvas.clear(clear_color_); 31 canvas.clear(clear_color_);
31 32
32 canvas.scale(raster_scale_, raster_scale_); 33 canvas.scale(raster_scale_, raster_scale_);
33 34
34 list_->Finalize(); 35 list_->Finalize();
35 list_->Raster(&canvas, nullptr); 36 list_->Raster(&canvas, nullptr);
36 } 37 }
37 38
38 } // namespace ui 39 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698