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

Side by Side Diff: ui/aura/demo/demo_main.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/aura/bench/bench_main.cc ('k') | ui/aura/test/test_window_delegate.cc » ('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 (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 "base/at_exit.h" 5 #include "base/at_exit.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/i18n/icu_util.h" 7 #include "base/i18n/icu_util.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/power_monitor/power_monitor.h" 10 #include "base/power_monitor/power_monitor.h"
11 #include "base/power_monitor/power_monitor_device_source.h" 11 #include "base/power_monitor/power_monitor_device_source.h"
12 #include "third_party/skia/include/core/SkXfermode.h" 12 #include "third_party/skia/include/core/SkXfermode.h"
13 #include "ui/aura/client/default_capture_client.h" 13 #include "ui/aura/client/default_capture_client.h"
14 #include "ui/aura/client/window_tree_client.h" 14 #include "ui/aura/client/window_tree_client.h"
15 #include "ui/aura/env.h" 15 #include "ui/aura/env.h"
16 #include "ui/aura/test/test_focus_client.h" 16 #include "ui/aura/test/test_focus_client.h"
17 #include "ui/aura/test/test_screen.h" 17 #include "ui/aura/test/test_screen.h"
18 #include "ui/aura/window.h" 18 #include "ui/aura/window.h"
19 #include "ui/aura/window_delegate.h" 19 #include "ui/aura/window_delegate.h"
20 #include "ui/aura/window_tree_host.h" 20 #include "ui/aura/window_tree_host.h"
21 #include "ui/base/hit_test.h" 21 #include "ui/base/hit_test.h"
22 #include "ui/compositor/paint_context.h" 22 #include "ui/compositor/paint_recorder.h"
23 #include "ui/compositor/test/in_process_context_factory.h" 23 #include "ui/compositor/test/in_process_context_factory.h"
24 #include "ui/events/event.h" 24 #include "ui/events/event.h"
25 #include "ui/gfx/canvas.h" 25 #include "ui/gfx/canvas.h"
26 #include "ui/gfx/geometry/rect.h" 26 #include "ui/gfx/geometry/rect.h"
27 #include "ui/gfx/skia_util.h" 27 #include "ui/gfx/skia_util.h"
28 #include "ui/gl/gl_surface.h" 28 #include "ui/gl/gl_surface.h"
29 29
30 #if defined(USE_X11) 30 #if defined(USE_X11)
31 #include "ui/gfx/x/x11_connection.h" 31 #include "ui/gfx/x/x11_connection.h"
32 #endif 32 #endif
(...skipping 24 matching lines...) Expand all
57 return HTCAPTION; 57 return HTCAPTION;
58 } 58 }
59 bool ShouldDescendIntoChildForEventHandling( 59 bool ShouldDescendIntoChildForEventHandling(
60 aura::Window* child, 60 aura::Window* child,
61 const gfx::Point& location) override { 61 const gfx::Point& location) override {
62 return true; 62 return true;
63 } 63 }
64 bool CanFocus() override { return true; } 64 bool CanFocus() override { return true; }
65 void OnCaptureLost() override {} 65 void OnCaptureLost() override {}
66 void OnPaint(const ui::PaintContext& context) override { 66 void OnPaint(const ui::PaintContext& context) override {
67 gfx::Canvas* canvas = context.canvas(); 67 ui::PaintRecorder recorder(context);
68 canvas->DrawColor(color_, SkXfermode::kSrc_Mode); 68 recorder.canvas()->DrawColor(color_, SkXfermode::kSrc_Mode);
69 gfx::Rect r; 69 gfx::Rect r;
70 canvas->GetClipBounds(&r); 70 recorder.canvas()->GetClipBounds(&r);
71 // Fill with a non-solid color so that the compositor will exercise its 71 // Fill with a non-solid color so that the compositor will exercise its
72 // texture upload path. 72 // texture upload path.
73 while (!r.IsEmpty()) { 73 while (!r.IsEmpty()) {
74 r.Inset(2, 2); 74 r.Inset(2, 2);
75 canvas->FillRect(r, color_, SkXfermode::kXor_Mode); 75 recorder.canvas()->FillRect(r, color_, SkXfermode::kXor_Mode);
76 } 76 }
77 } 77 }
78 void OnDeviceScaleFactorChanged(float device_scale_factor) override {} 78 void OnDeviceScaleFactorChanged(float device_scale_factor) override {}
79 void OnWindowDestroying(aura::Window* window) override {} 79 void OnWindowDestroying(aura::Window* window) override {}
80 void OnWindowDestroyed(aura::Window* window) override {} 80 void OnWindowDestroyed(aura::Window* window) override {}
81 void OnWindowTargetVisibilityChanged(bool visible) override {} 81 void OnWindowTargetVisibilityChanged(bool visible) override {}
82 bool HasHitTestMask() const override { return false; } 82 bool HasHitTestMask() const override { return false; }
83 void GetHitTestMask(gfx::Path* mask) const override {} 83 void GetHitTestMask(gfx::Path* mask) const override {}
84 84
85 private: 85 private:
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 int main(int argc, char** argv) { 190 int main(int argc, char** argv) {
191 base::CommandLine::Init(argc, argv); 191 base::CommandLine::Init(argc, argv);
192 192
193 // The exit manager is in charge of calling the dtors of singleton objects. 193 // The exit manager is in charge of calling the dtors of singleton objects.
194 base::AtExitManager exit_manager; 194 base::AtExitManager exit_manager;
195 195
196 base::i18n::InitializeICU(); 196 base::i18n::InitializeICU();
197 197
198 return DemoMain(); 198 return DemoMain();
199 } 199 }
OLDNEW
« no previous file with comments | « ui/aura/bench/bench_main.cc ('k') | ui/aura/test/test_window_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698