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

Side by Side Diff: ui/wm/core/image_grid.cc

Issue 1064133003: ui: Use a PaintRecorder to access the Canvas for painting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ui-recorder: . Created 5 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
« no previous file with comments | « ui/views/view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/wm/core/image_grid.h" 5 #include "ui/wm/core/image_grid.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "third_party/skia/include/core/SkColor.h" 9 #include "third_party/skia/include/core/SkColor.h"
10 #include "third_party/skia/include/core/SkXfermode.h" 10 #include "third_party/skia/include/core/SkXfermode.h"
11 #include "ui/compositor/dip_util.h" 11 #include "ui/compositor/dip_util.h"
12 #include "ui/compositor/paint_context.h" 12 #include "ui/compositor/paint_recorder.h"
13 #include "ui/gfx/canvas.h" 13 #include "ui/gfx/canvas.h"
14 #include "ui/gfx/geometry/rect.h" 14 #include "ui/gfx/geometry/rect.h"
15 #include "ui/gfx/geometry/rect_conversions.h" 15 #include "ui/gfx/geometry/rect_conversions.h"
16 #include "ui/gfx/geometry/size.h" 16 #include "ui/gfx/geometry/size.h"
17 #include "ui/gfx/geometry/size_conversions.h" 17 #include "ui/gfx/geometry/size_conversions.h"
18 #include "ui/gfx/image/image.h" 18 #include "ui/gfx/image/image.h"
19 #include "ui/gfx/image/image_skia_operations.h" 19 #include "ui/gfx/image/image_skia_operations.h"
20 #include "ui/gfx/transform.h" 20 #include "ui/gfx/transform.h"
21 21
22 using std::max; 22 using std::max;
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 261
262 void ImageGrid::ImagePainter::SetClipRect(const gfx::Rect& clip_rect, 262 void ImageGrid::ImagePainter::SetClipRect(const gfx::Rect& clip_rect,
263 ui::Layer* layer) { 263 ui::Layer* layer) {
264 if (clip_rect != clip_rect_) { 264 if (clip_rect != clip_rect_) {
265 clip_rect_ = clip_rect; 265 clip_rect_ = clip_rect;
266 layer->SchedulePaint(layer->bounds()); 266 layer->SchedulePaint(layer->bounds());
267 } 267 }
268 } 268 }
269 269
270 void ImageGrid::ImagePainter::OnPaintLayer(const ui::PaintContext& context) { 270 void ImageGrid::ImagePainter::OnPaintLayer(const ui::PaintContext& context) {
271 ui::PaintRecorder recorder(context);
271 if (!clip_rect_.IsEmpty()) 272 if (!clip_rect_.IsEmpty())
272 context.canvas()->ClipRect(clip_rect_); 273 recorder.canvas()->ClipRect(clip_rect_);
273 context.canvas()->DrawImageInt(image_, 0, 0); 274 recorder.canvas()->DrawImageInt(image_, 0, 0);
274 } 275 }
275 276
276 void ImageGrid::ImagePainter::OnDelegatedFrameDamage( 277 void ImageGrid::ImagePainter::OnDelegatedFrameDamage(
277 const gfx::Rect& damage_rect_in_dip) { 278 const gfx::Rect& damage_rect_in_dip) {
278 } 279 }
279 280
280 void ImageGrid::ImagePainter::OnDeviceScaleFactorChanged( 281 void ImageGrid::ImagePainter::OnDeviceScaleFactorChanged(
281 float device_scale_factor) { 282 float device_scale_factor) {
282 // Redrawing will take care of scale factor change. 283 // Redrawing will take care of scale factor change.
283 } 284 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 layer_ptr->get()->SetBounds(gfx::Rect(0, 0, size.width(), size.height())); 335 layer_ptr->get()->SetBounds(gfx::Rect(0, 0, size.width(), size.height()));
335 336
336 painter_ptr->reset(new ImagePainter(image_skia)); 337 painter_ptr->reset(new ImagePainter(image_skia));
337 layer_ptr->get()->set_delegate(painter_ptr->get()); 338 layer_ptr->get()->set_delegate(painter_ptr->get());
338 layer_ptr->get()->SetFillsBoundsOpaquely(false); 339 layer_ptr->get()->SetFillsBoundsOpaquely(false);
339 layer_ptr->get()->SetVisible(true); 340 layer_ptr->get()->SetVisible(true);
340 layer_->Add(layer_ptr->get()); 341 layer_->Add(layer_ptr->get());
341 } 342 }
342 343
343 } // namespace wm 344 } // namespace wm
OLDNEW
« no previous file with comments | « ui/views/view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698