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

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

Issue 9014030: Plumbs ::didCompleteSwapBuffers in CompositorCC (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nicer diff Created 8 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/gfx/compositor/compositor.h" 5 #include "ui/gfx/compositor/compositor.h"
6 6
7 #include "ui/gfx/compositor/compositor_observer.h" 7 #include "ui/gfx/compositor/compositor_observer.h"
8 #include "ui/gfx/compositor/layer.h" 8 #include "ui/gfx/compositor/layer.h"
9 9
10 namespace ui { 10 namespace ui {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 root_layer_->SetCompositor(this); 44 root_layer_->SetCompositor(this);
45 OnRootLayerChanged(); 45 OnRootLayerChanged();
46 } 46 }
47 47
48 void Compositor::Draw(bool force_clear) { 48 void Compositor::Draw(bool force_clear) {
49 if (!root_layer_) 49 if (!root_layer_)
50 return; 50 return;
51 51
52 NotifyStart(force_clear); 52 NotifyStart(force_clear);
53 DrawTree(); 53 DrawTree();
54 NotifyEnd(); 54 if (!CompositesAsynchronously()) {
55 NotifyEnd();
56 }
55 } 57 }
56 58
57 void Compositor::AddObserver(CompositorObserver* observer) { 59 void Compositor::AddObserver(CompositorObserver* observer) {
58 observer_list_.AddObserver(observer); 60 observer_list_.AddObserver(observer);
59 } 61 }
60 62
61 void Compositor::RemoveObserver(CompositorObserver* observer) { 63 void Compositor::RemoveObserver(CompositorObserver* observer) {
62 observer_list_.RemoveObserver(observer); 64 observer_list_.RemoveObserver(observer);
63 } 65 }
64 66
65 bool Compositor::HasObserver(CompositorObserver* observer) { 67 bool Compositor::HasObserver(CompositorObserver* observer) {
66 return observer_list_.HasObserver(observer); 68 return observer_list_.HasObserver(observer);
67 } 69 }
68 70
69 void Compositor::OnRootLayerChanged() { 71 void Compositor::OnRootLayerChanged() {
70 ScheduleDraw(); 72 ScheduleDraw();
71 } 73 }
72 74
73 void Compositor::DrawTree() { 75 void Compositor::DrawTree() {
74 root_layer_->DrawTree(); 76 root_layer_->DrawTree();
75 } 77 }
76 78
79 bool Compositor::CompositesAsynchronously() {
80 return false;
81 }
82
77 void Compositor::SwizzleRGBAToBGRAAndFlip(unsigned char* pixels, 83 void Compositor::SwizzleRGBAToBGRAAndFlip(unsigned char* pixels,
78 const gfx::Size& image_size) { 84 const gfx::Size& image_size) {
79 // Swizzle from RGBA to BGRA 85 // Swizzle from RGBA to BGRA
80 size_t bitmap_size = 4 * image_size.width() * image_size.height(); 86 size_t bitmap_size = 4 * image_size.width() * image_size.height();
81 for(size_t i = 0; i < bitmap_size; i += 4) 87 for(size_t i = 0; i < bitmap_size; i += 4)
82 std::swap(pixels[i], pixels[i + 2]); 88 std::swap(pixels[i], pixels[i + 2]);
83 89
84 // Vertical flip to transform from GL co-ords 90 // Vertical flip to transform from GL co-ords
85 size_t row_size = 4 * image_size.width(); 91 size_t row_size = 4 * image_size.width();
86 scoped_array<unsigned char> tmp_row(new unsigned char[row_size]); 92 scoped_array<unsigned char> tmp_row(new unsigned char[row_size]);
87 for(int row = 0; row < image_size.height() / 2; row++) { 93 for(int row = 0; row < image_size.height() / 2; row++) {
88 memcpy(tmp_row.get(), 94 memcpy(tmp_row.get(),
89 &pixels[row * row_size], 95 &pixels[row * row_size],
90 row_size); 96 row_size);
91 memcpy(&pixels[row * row_size], 97 memcpy(&pixels[row * row_size],
92 &pixels[bitmap_size - (row + 1) * row_size], 98 &pixels[bitmap_size - (row + 1) * row_size],
93 row_size); 99 row_size);
94 memcpy(&pixels[bitmap_size - (row + 1) * row_size], 100 memcpy(&pixels[bitmap_size - (row + 1) * row_size],
95 tmp_row.get(), 101 tmp_row.get(),
96 row_size); 102 row_size);
97 } 103 }
98 } 104 }
99 105
100 void Compositor::NotifyStart(bool clear) {
101 OnNotifyStart(clear);
102 }
103
104 void Compositor::NotifyEnd() { 106 void Compositor::NotifyEnd() {
105 OnNotifyEnd(); 107 OnNotifyEnd();
106 FOR_EACH_OBSERVER(CompositorObserver, 108 FOR_EACH_OBSERVER(CompositorObserver,
107 observer_list_, 109 observer_list_,
108 OnCompositingEnded(this)); 110 OnCompositingEnded(this));
109 } 111 }
110 112
113 void Compositor::NotifyStart(bool clear) {
114 OnNotifyStart(clear);
115 }
116
111 } // namespace ui 117 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698