| OLD | NEW |
| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 } | 61 } |
| 62 | 62 |
| 63 void Compositor::OnRootLayerChanged() { | 63 void Compositor::OnRootLayerChanged() { |
| 64 ScheduleDraw(); | 64 ScheduleDraw(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void Compositor::DrawTree() { | 67 void Compositor::DrawTree() { |
| 68 root_layer_->DrawTree(); | 68 root_layer_->DrawTree(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void Compositor::SwizzleRGBAToBGRAAndFlip(unsigned char* pixels, |
| 72 const gfx::Size& image_size) { |
| 73 // Swizzle from RGBA to BGRA |
| 74 size_t bitmap_size = 4 * image_size.width() * image_size.height(); |
| 75 for(size_t i = 0; i < bitmap_size; i += 4) |
| 76 std::swap(pixels[i], pixels[i + 2]); |
| 77 |
| 78 // Vertical flip to transform from GL co-ords |
| 79 size_t row_size = 4 * image_size.width(); |
| 80 scoped_array<unsigned char> tmp_row(new unsigned char[row_size]); |
| 81 for(int row = 0; row < image_size.height() / 2; row++) { |
| 82 memcpy(tmp_row.get(), |
| 83 &pixels[row * row_size], |
| 84 row_size); |
| 85 memcpy(&pixels[row * row_size], |
| 86 &pixels[bitmap_size - (row + 1) * row_size], |
| 87 row_size); |
| 88 memcpy(&pixels[bitmap_size - (row + 1) * row_size], |
| 89 tmp_row.get(), |
| 90 row_size); |
| 91 } |
| 92 } |
| 93 |
| 71 void Compositor::NotifyStart(bool clear) { | 94 void Compositor::NotifyStart(bool clear) { |
| 72 OnNotifyStart(clear); | 95 OnNotifyStart(clear); |
| 73 } | 96 } |
| 74 | 97 |
| 75 void Compositor::NotifyEnd() { | 98 void Compositor::NotifyEnd() { |
| 76 OnNotifyEnd(); | 99 OnNotifyEnd(); |
| 77 FOR_EACH_OBSERVER(CompositorObserver, | 100 FOR_EACH_OBSERVER(CompositorObserver, |
| 78 observer_list_, | 101 observer_list_, |
| 79 OnCompositingEnded(this)); | 102 OnCompositingEnded(this)); |
| 80 } | 103 } |
| 81 | 104 |
| 82 } // namespace ui | 105 } // namespace ui |
| OLD | NEW |