OLD | NEW |
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 "base/at_exit.h" | 5 #include "base/at_exit.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/i18n/icu_util.h" | 8 #include "base/i18n/icu_util.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 #include "third_party/khronos/GLES2/gl2ext.h" | 37 #include "third_party/khronos/GLES2/gl2ext.h" |
38 | 38 |
39 #if defined(USE_X11) | 39 #if defined(USE_X11) |
40 #include "base/message_loop/message_pump_x11.h" | 40 #include "base/message_loop/message_pump_x11.h" |
41 #endif | 41 #endif |
42 | 42 |
43 using base::TimeTicks; | 43 using base::TimeTicks; |
44 using ui::Compositor; | 44 using ui::Compositor; |
45 using ui::Layer; | 45 using ui::Layer; |
46 using ui::LayerDelegate; | 46 using ui::LayerDelegate; |
47 using WebKit::WebGraphicsContext3D; | 47 using blink::WebGraphicsContext3D; |
48 | 48 |
49 namespace { | 49 namespace { |
50 | 50 |
51 class ColoredLayer : public Layer, public LayerDelegate { | 51 class ColoredLayer : public Layer, public LayerDelegate { |
52 public: | 52 public: |
53 explicit ColoredLayer(SkColor color) | 53 explicit ColoredLayer(SkColor color) |
54 : Layer(ui::LAYER_TEXTURED), | 54 : Layer(ui::LAYER_TEXTURED), |
55 color_(color), | 55 color_(color), |
56 draw_(true) { | 56 draw_(true) { |
57 set_delegate(this); | 57 set_delegate(this); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 if (!width || !height) { | 203 if (!width || !height) { |
204 width = 800; | 204 width = 800; |
205 height = 600; | 205 height = 600; |
206 } | 206 } |
207 gfx::Rect bounds(width, height); | 207 gfx::Rect bounds(width, height); |
208 webgl_.SetBounds(bounds); | 208 webgl_.SetBounds(bounds); |
209 parent_->Add(&webgl_); | 209 parent_->Add(&webgl_); |
210 | 210 |
211 context_provider_ = | 211 context_provider_ = |
212 ui::ContextFactory::GetInstance()->SharedMainThreadContextProvider(); | 212 ui::ContextFactory::GetInstance()->SharedMainThreadContextProvider(); |
213 WebKit::WebGraphicsContext3D* context = context_provider_->Context3d(); | 213 blink::WebGraphicsContext3D* context = context_provider_->Context3d(); |
214 context->makeContextCurrent(); | 214 context->makeContextCurrent(); |
215 texture_ = new WebGLTexture(context, bounds.size()); | 215 texture_ = new WebGLTexture(context, bounds.size()); |
216 fbo_ = context->createFramebuffer(); | 216 fbo_ = context->createFramebuffer(); |
217 compositor->AddObserver(this); | 217 compositor->AddObserver(this); |
218 webgl_.SetExternalTexture(texture_.get()); | 218 webgl_.SetExternalTexture(texture_.get()); |
219 context->bindFramebuffer(GL_FRAMEBUFFER, fbo_); | 219 context->bindFramebuffer(GL_FRAMEBUFFER, fbo_); |
220 context->framebufferTexture2D( | 220 context->framebufferTexture2D( |
221 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | 221 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
222 GL_TEXTURE_2D, texture_->PrepareTexture(), 0); | 222 GL_TEXTURE_2D, texture_->PrepareTexture(), 0); |
223 context->clearColor(0.f, 1.f, 0.f, 1.f); | 223 context->clearColor(0.f, 1.f, 0.f, 1.f); |
224 context->clear(GL_COLOR_BUFFER_BIT); | 224 context->clear(GL_COLOR_BUFFER_BIT); |
225 context->flush(); | 225 context->flush(); |
226 } | 226 } |
227 | 227 |
228 virtual ~WebGLBench() { | 228 virtual ~WebGLBench() { |
229 context_provider_->Context3d()->makeContextCurrent(); | 229 context_provider_->Context3d()->makeContextCurrent(); |
230 context_provider_->Context3d()->deleteFramebuffer(fbo_); | 230 context_provider_->Context3d()->deleteFramebuffer(fbo_); |
231 webgl_.SetShowPaintedContent(); | 231 webgl_.SetShowPaintedContent(); |
232 texture_ = NULL; | 232 texture_ = NULL; |
233 compositor_->RemoveObserver(this); | 233 compositor_->RemoveObserver(this); |
234 } | 234 } |
235 | 235 |
236 virtual void Draw() OVERRIDE { | 236 virtual void Draw() OVERRIDE { |
237 if (do_draw_) { | 237 if (do_draw_) { |
238 WebKit::WebGraphicsContext3D* context = context_provider_->Context3d(); | 238 blink::WebGraphicsContext3D* context = context_provider_->Context3d(); |
239 context->makeContextCurrent(); | 239 context->makeContextCurrent(); |
240 context->clearColor((frames() % kFrames)*1.0/kFrames, 1.f, 0.f, 1.f); | 240 context->clearColor((frames() % kFrames)*1.0/kFrames, 1.f, 0.f, 1.f); |
241 context->clear(GL_COLOR_BUFFER_BIT); | 241 context->clear(GL_COLOR_BUFFER_BIT); |
242 context->flush(); | 242 context->flush(); |
243 } | 243 } |
244 webgl_.SetExternalTexture(texture_.get()); | 244 webgl_.SetExternalTexture(texture_.get()); |
245 webgl_.SchedulePaint(gfx::Rect(webgl_.bounds().size())); | 245 webgl_.SchedulePaint(gfx::Rect(webgl_.bounds().size())); |
246 compositor_->ScheduleDraw(); | 246 compositor_->ScheduleDraw(); |
247 } | 247 } |
248 | 248 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 ui::PrintLayerHierarchy(root_window->layer(), gfx::Point(100, 100)); | 363 ui::PrintLayerHierarchy(root_window->layer(), gfx::Point(100, 100)); |
364 #endif | 364 #endif |
365 | 365 |
366 root_window->ShowRootWindow(); | 366 root_window->ShowRootWindow(); |
367 base::MessageLoopForUI::current()->Run(); | 367 base::MessageLoopForUI::current()->Run(); |
368 focus_client.reset(); | 368 focus_client.reset(); |
369 root_window.reset(); | 369 root_window.reset(); |
370 | 370 |
371 return 0; | 371 return 0; |
372 } | 372 } |
OLD | NEW |