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_cc.h" | 5 #include "ui/gfx/compositor/compositor_cc.h" |
6 | 6 |
| 7 #include "third_party/skia/include/images/SkImageEncoder.h" |
| 8 #include "third_party/skia/include/core/SkBitmap.h" |
7 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h" | 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h" |
8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFloatPoint.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFloatPoint.h" |
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" | 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" |
10 #include "ui/gfx/compositor/layer.h" | 12 #include "ui/gfx/compositor/layer.h" |
11 #include "ui/gfx/gl/gl_context.h" | 13 #include "ui/gfx/gl/gl_context.h" |
12 #include "ui/gfx/gl/gl_surface.h" | 14 #include "ui/gfx/gl/gl_surface.h" |
13 #include "ui/gfx/gl/gl_implementation.h" | 15 #include "ui/gfx/gl/gl_implementation.h" |
14 #include "webkit/glue/webthread_impl.h" | 16 #include "webkit/glue/webthread_impl.h" |
15 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" | 17 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" |
16 | 18 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 169 |
168 void CompositorCC::OnRootLayerChanged() { | 170 void CompositorCC::OnRootLayerChanged() { |
169 root_web_layer_.removeAllChildren(); | 171 root_web_layer_.removeAllChildren(); |
170 root_web_layer_.addChild(root_layer()->web_layer()); | 172 root_web_layer_.addChild(root_layer()->web_layer()); |
171 } | 173 } |
172 | 174 |
173 void CompositorCC::DrawTree() { | 175 void CompositorCC::DrawTree() { |
174 host_.composite(); | 176 host_.composite(); |
175 } | 177 } |
176 | 178 |
177 void CompositorCC::ReadPixels(SkBitmap* bitmap) { | 179 bool CompositorCC::ReadPixels(SkBitmap* bitmap) { |
178 NOTIMPLEMENTED(); | 180 bitmap->setConfig(SkBitmap::kARGB_8888_Config, |
| 181 size().width(), size().height()); |
| 182 bitmap->allocPixels(); |
| 183 SkAutoLockPixels lock_image(*bitmap); |
| 184 unsigned char* pixels = static_cast<unsigned char*>(bitmap->getPixels()); |
| 185 if (host_.compositeAndReadback(pixels)) { |
| 186 SwizzleRGBAToBGRAAndFlip(pixels, size()); |
| 187 return true; |
| 188 } |
| 189 return false; |
179 } | 190 } |
180 | 191 |
181 void CompositorCC::animateAndLayout(double frameBeginTime) { | 192 void CompositorCC::animateAndLayout(double frameBeginTime) { |
182 } | 193 } |
183 | 194 |
184 void CompositorCC::applyScrollAndScale(const WebKit::WebSize& scrollDelta, | 195 void CompositorCC::applyScrollAndScale(const WebKit::WebSize& scrollDelta, |
185 float scaleFactor) { | 196 float scaleFactor) { |
186 } | 197 } |
187 | 198 |
188 void CompositorCC::applyScrollDelta(const WebKit::WebSize&) { | 199 void CompositorCC::applyScrollDelta(const WebKit::WebSize&) { |
(...skipping 20 matching lines...) Expand all Loading... |
209 ScheduleDraw(); | 220 ScheduleDraw(); |
210 } | 221 } |
211 | 222 |
212 Compositor* Compositor::Create(CompositorDelegate* owner, | 223 Compositor* Compositor::Create(CompositorDelegate* owner, |
213 gfx::AcceleratedWidget widget, | 224 gfx::AcceleratedWidget widget, |
214 const gfx::Size& size) { | 225 const gfx::Size& size) { |
215 return new CompositorCC(owner, widget, size); | 226 return new CompositorCC(owner, widget, size); |
216 } | 227 } |
217 | 228 |
218 } // namespace ui | 229 } // namespace ui |
OLD | NEW |