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" | 7 #include "third_party/skia/include/images/SkImageEncoder.h" |
8 #include "third_party/skia/include/core/SkBitmap.h" | 8 #include "third_party/skia/include/core/SkBitmap.h" |
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h" | 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h" |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFloatPoint.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFloatPoint.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 void CompositorCC::OnRootLayerChanged() { | 175 void CompositorCC::OnRootLayerChanged() { |
176 root_web_layer_.removeAllChildren(); | 176 root_web_layer_.removeAllChildren(); |
177 if (root_layer()) | 177 if (root_layer()) |
178 root_web_layer_.addChild(root_layer()->web_layer()); | 178 root_web_layer_.addChild(root_layer()->web_layer()); |
179 } | 179 } |
180 | 180 |
181 void CompositorCC::DrawTree() { | 181 void CompositorCC::DrawTree() { |
182 host_.composite(); | 182 host_.composite(); |
183 } | 183 } |
184 | 184 |
185 bool CompositorCC::ReadPixels(SkBitmap* bitmap, const gfx::Rect& bounds) { | 185 bool CompositorCC::ReadPixels(SkBitmap* bitmap) { |
186 if (bounds.right() > size().width() || bounds.bottom() > size().height()) | |
187 return false; | |
188 // Convert to OpenGL coordinates. | |
189 gfx::Point new_origin(bounds.x(), | |
190 size().height() - bounds.height() - bounds.y()); | |
191 | |
192 bitmap->setConfig(SkBitmap::kARGB_8888_Config, | 186 bitmap->setConfig(SkBitmap::kARGB_8888_Config, |
193 bounds.width(), bounds.height()); | 187 size().width(), size().height()); |
194 bitmap->allocPixels(); | 188 bitmap->allocPixels(); |
195 SkAutoLockPixels lock_image(*bitmap); | 189 SkAutoLockPixels lock_image(*bitmap); |
196 unsigned char* pixels = static_cast<unsigned char*>(bitmap->getPixels()); | 190 unsigned char* pixels = static_cast<unsigned char*>(bitmap->getPixels()); |
197 if (host_.compositeAndReadback(pixels, | 191 if (host_.compositeAndReadback(pixels, gfx::Rect(size()))) { |
198 gfx::Rect(new_origin, bounds.size()))) { | 192 SwizzleRGBAToBGRAAndFlip(pixels, size()); |
199 SwizzleRGBAToBGRAAndFlip(pixels, bounds.size()); | |
200 return true; | 193 return true; |
201 } | 194 } |
202 return false; | 195 return false; |
203 } | 196 } |
204 | 197 |
205 void CompositorCC::animateAndLayout(double frameBeginTime) { | 198 void CompositorCC::animateAndLayout(double frameBeginTime) { |
206 } | 199 } |
207 | 200 |
208 void CompositorCC::applyScrollAndScale(const WebKit::WebSize& scrollDelta, | 201 void CompositorCC::applyScrollAndScale(const WebKit::WebSize& scrollDelta, |
209 float scaleFactor) { | 202 float scaleFactor) { |
(...skipping 23 matching lines...) Expand all Loading... |
233 ScheduleDraw(); | 226 ScheduleDraw(); |
234 } | 227 } |
235 | 228 |
236 Compositor* Compositor::Create(CompositorDelegate* owner, | 229 Compositor* Compositor::Create(CompositorDelegate* owner, |
237 gfx::AcceleratedWidget widget, | 230 gfx::AcceleratedWidget widget, |
238 const gfx::Size& size) { | 231 const gfx::Size& size) { |
239 return new CompositorCC(owner, widget, size); | 232 return new CompositorCC(owner, widget, size); |
240 } | 233 } |
241 | 234 |
242 } // namespace ui | 235 } // namespace ui |
OLD | NEW |