| 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.h" | 10 #include "base/message_loop.h" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 } | 205 } |
| 206 gfx::Rect bounds(width, height); | 206 gfx::Rect bounds(width, height); |
| 207 webgl_.SetBounds(bounds); | 207 webgl_.SetBounds(bounds); |
| 208 parent_->Add(&webgl_); | 208 parent_->Add(&webgl_); |
| 209 | 209 |
| 210 context_.reset(ui::ContextFactory::GetInstance()->CreateOffscreenContext()); | 210 context_.reset(ui::ContextFactory::GetInstance()->CreateOffscreenContext()); |
| 211 context_->makeContextCurrent(); | 211 context_->makeContextCurrent(); |
| 212 texture_ = new WebGLTexture(context_.get(), bounds.size()); | 212 texture_ = new WebGLTexture(context_.get(), bounds.size()); |
| 213 fbo_ = context_->createFramebuffer(); | 213 fbo_ = context_->createFramebuffer(); |
| 214 compositor->AddObserver(this); | 214 compositor->AddObserver(this); |
| 215 webgl_.SetExternalTexture(texture_); | 215 webgl_.SetExternalTexture(texture_.get()); |
| 216 context_->bindFramebuffer(GL_FRAMEBUFFER, fbo_); | 216 context_->bindFramebuffer(GL_FRAMEBUFFER, fbo_); |
| 217 context_->framebufferTexture2D( | 217 context_->framebufferTexture2D( |
| 218 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | 218 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
| 219 GL_TEXTURE_2D, texture_->PrepareTexture(), 0); | 219 GL_TEXTURE_2D, texture_->PrepareTexture(), 0); |
| 220 context_->clearColor(0.f, 1.f, 0.f, 1.f); | 220 context_->clearColor(0.f, 1.f, 0.f, 1.f); |
| 221 context_->clear(GL_COLOR_BUFFER_BIT); | 221 context_->clear(GL_COLOR_BUFFER_BIT); |
| 222 context_->flush(); | 222 context_->flush(); |
| 223 } | 223 } |
| 224 | 224 |
| 225 virtual ~WebGLBench() { | 225 virtual ~WebGLBench() { |
| 226 context_->makeContextCurrent(); | 226 context_->makeContextCurrent(); |
| 227 context_->deleteFramebuffer(fbo_); | 227 context_->deleteFramebuffer(fbo_); |
| 228 webgl_.SetExternalTexture(NULL); | 228 webgl_.SetExternalTexture(NULL); |
| 229 texture_ = NULL; | 229 texture_ = NULL; |
| 230 compositor_->RemoveObserver(this); | 230 compositor_->RemoveObserver(this); |
| 231 } | 231 } |
| 232 | 232 |
| 233 virtual void Draw() OVERRIDE { | 233 virtual void Draw() OVERRIDE { |
| 234 if (do_draw_) { | 234 if (do_draw_) { |
| 235 context_->makeContextCurrent(); | 235 context_->makeContextCurrent(); |
| 236 context_->clearColor((frames() % kFrames)*1.0/kFrames, 1.f, 0.f, 1.f); | 236 context_->clearColor((frames() % kFrames)*1.0/kFrames, 1.f, 0.f, 1.f); |
| 237 context_->clear(GL_COLOR_BUFFER_BIT); | 237 context_->clear(GL_COLOR_BUFFER_BIT); |
| 238 context_->flush(); | 238 context_->flush(); |
| 239 } | 239 } |
| 240 webgl_.SetExternalTexture(texture_); | 240 webgl_.SetExternalTexture(texture_.get()); |
| 241 webgl_.SchedulePaint(gfx::Rect(webgl_.bounds().size())); | 241 webgl_.SchedulePaint(gfx::Rect(webgl_.bounds().size())); |
| 242 compositor_->ScheduleDraw(); | 242 compositor_->ScheduleDraw(); |
| 243 } | 243 } |
| 244 | 244 |
| 245 private: | 245 private: |
| 246 Layer* parent_; | 246 Layer* parent_; |
| 247 Layer webgl_; | 247 Layer webgl_; |
| 248 Compositor* compositor_; | 248 Compositor* compositor_; |
| 249 scoped_ptr<WebGraphicsContext3D> context_; | 249 scoped_ptr<WebGraphicsContext3D> context_; |
| 250 scoped_refptr<WebGLTexture> texture_; | 250 scoped_refptr<WebGLTexture> texture_; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 ui::PrintLayerHierarchy(root_window->layer(), gfx::Point(100, 100)); | 354 ui::PrintLayerHierarchy(root_window->layer(), gfx::Point(100, 100)); |
| 355 #endif | 355 #endif |
| 356 | 356 |
| 357 root_window->ShowRootWindow(); | 357 root_window->ShowRootWindow(); |
| 358 base::MessageLoopForUI::current()->Run(); | 358 base::MessageLoopForUI::current()->Run(); |
| 359 focus_client.reset(); | 359 focus_client.reset(); |
| 360 root_window.reset(); | 360 root_window.reset(); |
| 361 | 361 |
| 362 return 0; | 362 return 0; |
| 363 } | 363 } |
| OLD | NEW |