Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Unified Diff: ui/aura/bench/bench_main.cc

Issue 21026005: aura: Remove CreateOffscreenContext from ui::ContextFactory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: offscreencontext: clang-format Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura/bench/DEPS ('k') | ui/compositor/compositor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..17ed068e60b97ed9c31cdd9bcb970c68ac08adc5 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,26 @@ 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();
+ 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 +235,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 +250,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.
« no previous file with comments | « ui/aura/bench/DEPS ('k') | ui/compositor/compositor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698