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

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

Issue 148243013: Add shared bitmap managers for browser and renderer processes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
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/compositor/compositor.h" 5 #include "ui/compositor/compositor.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <deque> 8 #include <deque>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 27 matching lines...) Expand all
38 38
39 const double kDefaultRefreshRate = 60.0; 39 const double kDefaultRefreshRate = 60.0;
40 const double kTestRefreshRate = 200.0; 40 const double kTestRefreshRate = 200.0;
41 41
42 enum SwapType { 42 enum SwapType {
43 DRAW_SWAP, 43 DRAW_SWAP,
44 }; 44 };
45 45
46 bool g_compositor_initialized = false; 46 bool g_compositor_initialized = false;
47 base::Thread* g_compositor_thread = NULL; 47 base::Thread* g_compositor_thread = NULL;
48 cc::SharedBitmapManager* g_shared_bitmap_manager;
48 49
49 ui::ContextFactory* g_context_factory = NULL; 50 ui::ContextFactory* g_context_factory = NULL;
50 51
51 const int kCompositorLockTimeoutMs = 67; 52 const int kCompositorLockTimeoutMs = 67;
52 53
53 class PendingSwap { 54 class PendingSwap {
54 public: 55 public:
55 PendingSwap(SwapType type, ui::PostedSwapQueue* posted_swaps); 56 PendingSwap(SwapType type, ui::PostedSwapQueue* posted_swaps);
56 ~PendingSwap(); 57 ~PendingSwap();
57 58
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 command_line->HasSwitch(cc::switches::kUIShowOccludingRects); 238 command_line->HasSwitch(cc::switches::kUIShowOccludingRects);
238 settings.initial_debug_state.show_non_occluding_rects = 239 settings.initial_debug_state.show_non_occluding_rects =
239 command_line->HasSwitch(cc::switches::kUIShowNonOccludingRects); 240 command_line->HasSwitch(cc::switches::kUIShowNonOccludingRects);
240 241
241 settings.initial_debug_state.SetRecordRenderingStats( 242 settings.initial_debug_state.SetRecordRenderingStats(
242 command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking)); 243 command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking));
243 244
244 base::TimeTicks before_create = base::TimeTicks::Now(); 245 base::TimeTicks before_create = base::TimeTicks::Now();
245 if (!!g_compositor_thread) { 246 if (!!g_compositor_thread) {
246 host_ = cc::LayerTreeHost::CreateThreaded( 247 host_ = cc::LayerTreeHost::CreateThreaded(
247 this, NULL, settings, g_compositor_thread->message_loop_proxy()); 248 this,
249 g_shared_bitmap_manager,
250 settings,
251 g_compositor_thread->message_loop_proxy());
248 } else { 252 } else {
249 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, this, NULL, settings); 253 host_ = cc::LayerTreeHost::CreateSingleThreaded(
254 this, this, g_shared_bitmap_manager, settings);
250 } 255 }
251 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", 256 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor",
252 base::TimeTicks::Now() - before_create); 257 base::TimeTicks::Now() - before_create);
253 host_->SetRootLayer(root_web_layer_); 258 host_->SetRootLayer(root_web_layer_);
254 host_->SetLayerTreeHostClientReady(); 259 host_->SetLayerTreeHostClientReady();
255 } 260 }
256 261
257 Compositor::~Compositor() { 262 Compositor::~Compositor() {
258 TRACE_EVENT0("shutdown", "Compositor::destructor"); 263 TRACE_EVENT0("shutdown", "Compositor::destructor");
259 264
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 if (g_compositor_thread) { 317 if (g_compositor_thread) {
313 g_compositor_thread->Stop(); 318 g_compositor_thread->Stop();
314 delete g_compositor_thread; 319 delete g_compositor_thread;
315 g_compositor_thread = NULL; 320 g_compositor_thread = NULL;
316 } 321 }
317 322
318 DCHECK(g_compositor_initialized) << "Compositor::Initialize() didn't happen."; 323 DCHECK(g_compositor_initialized) << "Compositor::Initialize() didn't happen.";
319 g_compositor_initialized = false; 324 g_compositor_initialized = false;
320 } 325 }
321 326
327 // static
328 void Compositor::SetSharedBitmapManager(cc::SharedBitmapManager* manager) {
329 g_shared_bitmap_manager = manager;
330 }
331
322 void Compositor::ScheduleDraw() { 332 void Compositor::ScheduleDraw() {
323 if (g_compositor_thread) { 333 if (g_compositor_thread) {
324 host_->Composite(gfx::FrameTime::Now()); 334 host_->Composite(gfx::FrameTime::Now());
325 } else if (!defer_draw_scheduling_) { 335 } else if (!defer_draw_scheduling_) {
326 defer_draw_scheduling_ = true; 336 defer_draw_scheduling_ = true;
327 base::MessageLoop::current()->PostTask( 337 base::MessageLoop::current()->PostTask(
328 FROM_HERE, 338 FROM_HERE,
329 base::Bind(&Compositor::Draw, schedule_draw_factory_.GetWeakPtr())); 339 base::Bind(&Compositor::Draw, schedule_draw_factory_.GetWeakPtr()));
330 } 340 }
331 } 341 }
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 // CompositorObservers to be notified before starting another 569 // CompositorObservers to be notified before starting another
560 // draw cycle. 570 // draw cycle.
561 ScheduleDraw(); 571 ScheduleDraw();
562 } 572 }
563 FOR_EACH_OBSERVER(CompositorObserver, 573 FOR_EACH_OBSERVER(CompositorObserver,
564 observer_list_, 574 observer_list_,
565 OnCompositingEnded(this)); 575 OnCompositingEnded(this));
566 } 576 }
567 577
568 } // namespace ui 578 } // namespace ui
OLDNEW
« content/common/host_shared_bitmap_manager_unittest.cc ('K') | « ui/compositor/compositor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698