Chromium Code Reviews| Index: ui/aura/bench/bench_main.cc |
| diff --git a/ui/aura/bench/bench_main.cc b/ui/aura/bench/bench_main.cc |
| index aee7e79c83a417a9ffbc5865163e438e4fdd4e5f..6b1a8a9d7a871b6335f8cc904fbae055f963bf3c 100644 |
| --- a/ui/aura/bench/bench_main.cc |
| +++ b/ui/aura/bench/bench_main.cc |
| @@ -10,6 +10,7 @@ |
| #include "base/message_loop/message_loop.h" |
| #include "base/strings/string_split.h" |
| #include "base/time/time.h" |
| +#include "cc/output/context_provider.h" |
| #include "third_party/khronos/GLES2/gl2.h" |
| #include "third_party/skia/include/core/SkXfermode.h" |
| #include "ui/aura/client/default_capture_client.h" |
| @@ -181,7 +182,7 @@ class WebGLBench : public BenchCompositorObserver { |
| parent_(parent), |
| webgl_(ui::LAYER_TEXTURED), |
| compositor_(compositor), |
| - context_(), |
| + context_provider_(), |
| texture_(), |
| fbo_(0), |
| do_draw_(true) { |
| @@ -207,24 +208,27 @@ class WebGLBench : public BenchCompositorObserver { |
| webgl_.SetBounds(bounds); |
| parent_->Add(&webgl_); |
| - context_ = ui::ContextFactory::GetInstance()->CreateOffscreenContext(); |
| - context_->makeContextCurrent(); |
| - texture_ = new WebGLTexture(context_.get(), bounds.size()); |
| - fbo_ = context_->createFramebuffer(); |
| + context_provider_ = |
| + ui::ContextFactory::GetInstance()-> |
| + OffscreenContextProviderForMainThread(); |
|
sadrul
2013/08/13 01:18:17
I assume this follows any special indentation rule
danakj
2013/08/13 01:21:09
I clang-formatted it now just in case.
|
| + WebKit::WebGraphicsContext3D* context = context_provider_->Context3d(); |
| + context->makeContextCurrent(); |
| + texture_ = new WebGLTexture(context, bounds.size()); |
| + fbo_ = context->createFramebuffer(); |
| compositor->AddObserver(this); |
| webgl_.SetExternalTexture(texture_.get()); |
| - context_->bindFramebuffer(GL_FRAMEBUFFER, fbo_); |
| - context_->framebufferTexture2D( |
| + context->bindFramebuffer(GL_FRAMEBUFFER, fbo_); |
| + context->framebufferTexture2D( |
| GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
| GL_TEXTURE_2D, texture_->PrepareTexture(), 0); |
| - context_->clearColor(0.f, 1.f, 0.f, 1.f); |
| - context_->clear(GL_COLOR_BUFFER_BIT); |
| - context_->flush(); |
| + context->clearColor(0.f, 1.f, 0.f, 1.f); |
| + context->clear(GL_COLOR_BUFFER_BIT); |
| + context->flush(); |
| } |
| virtual ~WebGLBench() { |
| - context_->makeContextCurrent(); |
| - context_->deleteFramebuffer(fbo_); |
| + context_provider_->Context3d()->makeContextCurrent(); |
| + context_provider_->Context3d()->deleteFramebuffer(fbo_); |
| webgl_.SetExternalTexture(NULL); |
| texture_ = NULL; |
| compositor_->RemoveObserver(this); |
| @@ -232,10 +236,11 @@ class WebGLBench : public BenchCompositorObserver { |
| virtual void Draw() OVERRIDE { |
| if (do_draw_) { |
| - context_->makeContextCurrent(); |
| - context_->clearColor((frames() % kFrames)*1.0/kFrames, 1.f, 0.f, 1.f); |
| - context_->clear(GL_COLOR_BUFFER_BIT); |
| - context_->flush(); |
| + WebKit::WebGraphicsContext3D* context = context_provider_->Context3d(); |
| + context->makeContextCurrent(); |
| + context->clearColor((frames() % kFrames)*1.0/kFrames, 1.f, 0.f, 1.f); |
| + context->clear(GL_COLOR_BUFFER_BIT); |
| + context->flush(); |
| } |
| webgl_.SetExternalTexture(texture_.get()); |
| webgl_.SchedulePaint(gfx::Rect(webgl_.bounds().size())); |
| @@ -246,7 +251,7 @@ class WebGLBench : public BenchCompositorObserver { |
| Layer* parent_; |
| Layer webgl_; |
| Compositor* compositor_; |
| - scoped_ptr<WebGraphicsContext3D> context_; |
| + scoped_refptr<cc::ContextProvider> context_provider_; |
| scoped_refptr<WebGLTexture> texture_; |
| // The FBO that is used to render to the texture. |