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

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

Issue 2877483003: Implements core logic for Pixel Canvas (Closed)
Patch Set: Sync with ToT Created 3 years, 4 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
« no previous file with comments | « ui/compositor/canvas_painter.h ('k') | ui/compositor/compositor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 bool is_pixel_canvas)
15 : output_(output), 16 : output_(output),
16 paint_size_(paint_size), 17 paint_size_(paint_size),
17 raster_scale_(raster_scale), 18 raster_scale_(raster_scale),
18 clear_color_(clear_color), 19 clear_color_(clear_color),
19 list_(new cc::DisplayItemList), 20 list_(new cc::DisplayItemList),
20 context_(list_.get(), raster_scale, gfx::Rect(paint_size_)) {} 21 context_(list_.get(),
22 raster_scale,
23 gfx::Rect(paint_size_),
24 is_pixel_canvas) {}
21 25
22 CanvasPainter::~CanvasPainter() { 26 CanvasPainter::~CanvasPainter() {
23 gfx::Size pixel_size = gfx::ScaleToCeiledSize(paint_size_, raster_scale_); 27 gfx::Size pixel_size = gfx::ScaleToCeiledSize(paint_size_, raster_scale_);
24 SkImageInfo info = SkImageInfo::MakeN32( 28 SkImageInfo info = SkImageInfo::MakeN32(
25 pixel_size.width(), pixel_size.height(), kPremul_SkAlphaType); 29 pixel_size.width(), pixel_size.height(), kPremul_SkAlphaType);
26 if (!output_->tryAllocPixels(info)) 30 if (!output_->tryAllocPixels(info))
27 return; 31 return;
28 32
29 SkCanvas canvas(*output_); 33 SkCanvas canvas(*output_);
30 canvas.clear(clear_color_); 34 canvas.clear(clear_color_);
31 35
32 canvas.scale(raster_scale_, raster_scale_); 36 canvas.scale(raster_scale_, raster_scale_);
33 37
34 list_->Finalize(); 38 list_->Finalize();
35 list_->Raster(&canvas, nullptr); 39 list_->Raster(&canvas, nullptr);
36 } 40 }
37 41
38 } // namespace ui 42 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/canvas_painter.h ('k') | ui/compositor/compositor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698