| Index: ui/aura/bench/bench_main.cc
|
| diff --git a/ui/aura/bench/bench_main.cc b/ui/aura/bench/bench_main.cc
|
| index ff0d32dee897ded309c82cabca9f8e2958b486e4..337da8da037916c03844011840bb2e089b2dc836 100644
|
| --- a/ui/aura/bench/bench_main.cc
|
| +++ b/ui/aura/bench/bench_main.cc
|
| @@ -138,36 +138,15 @@ class BenchCompositorObserver : public ui::CompositorObserver {
|
| DISALLOW_COPY_AND_ASSIGN(BenchCompositorObserver);
|
| };
|
|
|
| -class WebGLTexture : public ui::Texture {
|
| - public:
|
| - WebGLTexture(gpu::gles2::GLES2Interface* gl, const gfx::Size& size)
|
| - : ui::Texture(false, size, 1.0f),
|
| - gl_(gl),
|
| - texture_id_(0u) {
|
| - gl->GenTextures(1, &texture_id_);
|
| - gl->BindTexture(GL_TEXTURE_2D, texture_id_);
|
| - gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
| - gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
| - gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
| - gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
| - gl->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size.width(), size.height(),
|
| - 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
| - }
|
| -
|
| - virtual unsigned int PrepareTexture() OVERRIDE {
|
| - return texture_id_;
|
| - }
|
| -
|
| - private:
|
| - virtual ~WebGLTexture() {
|
| - gl_->DeleteTextures(1, &texture_id_);
|
| - }
|
| -
|
| - gpu::gles2::GLES2Interface* gl_;
|
| - GLuint texture_id_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(WebGLTexture);
|
| -};
|
| +void ReturnMailbox(scoped_refptr<cc::ContextProvider> context_provider,
|
| + GLuint texture,
|
| + GLuint sync_point,
|
| + bool is_lost) {
|
| + gpu::gles2::GLES2Interface* gl = context_provider->ContextGL();
|
| + gl->WaitSyncPointCHROMIUM(sync_point);
|
| + gl->DeleteTextures(1, &texture);
|
| + gl->ShallowFlushCHROMIUM();
|
| +}
|
|
|
| // A benchmark that adds a texture layer that is updated every frame.
|
| class WebGLBench : public BenchCompositorObserver {
|
| @@ -177,7 +156,6 @@ class WebGLBench : public BenchCompositorObserver {
|
| parent_(parent),
|
| webgl_(ui::LAYER_TEXTURED),
|
| compositor_(compositor),
|
| - texture_(),
|
| fbo_(0),
|
| do_draw_(true) {
|
| CommandLine* command_line = CommandLine::ForCurrentProcess();
|
| @@ -205,23 +183,47 @@ class WebGLBench : public BenchCompositorObserver {
|
| context_provider_ =
|
| ui::ContextFactory::GetInstance()->SharedMainThreadContextProvider();
|
| gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
|
| - texture_ = new WebGLTexture(gl, bounds.size());
|
| + GLuint texture = 0;
|
| + gl->GenTextures(1, &texture);
|
| + gl->BindTexture(GL_TEXTURE_2D, texture);
|
| + gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
| + gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
| + gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
| + gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
| + gl->TexImage2D(GL_TEXTURE_2D,
|
| + 0,
|
| + GL_RGBA,
|
| + width,
|
| + height,
|
| + 0,
|
| + GL_RGBA,
|
| + GL_UNSIGNED_BYTE,
|
| + NULL);
|
| + gpu::Mailbox mailbox;
|
| + gl->GenMailboxCHROMIUM(mailbox.name);
|
| + gl->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
|
| +
|
| gl->GenFramebuffers(1, &fbo_);
|
| - compositor->AddObserver(this);
|
| - webgl_.SetExternalTexture(texture_.get());
|
| gl->BindFramebuffer(GL_FRAMEBUFFER, fbo_);
|
| gl->FramebufferTexture2D(
|
| - GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
| - GL_TEXTURE_2D, texture_->PrepareTexture(), 0);
|
| + GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
|
| gl->ClearColor(0.f, 1.f, 0.f, 1.f);
|
| gl->Clear(GL_COLOR_BUFFER_BIT);
|
| gl->Flush();
|
| +
|
| + GLuint sync_point = gl->InsertSyncPointCHROMIUM();
|
| + webgl_.SetTextureMailbox(
|
| + cc::TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point),
|
| + cc::SingleReleaseCallback::Create(
|
| + base::Bind(ReturnMailbox, context_provider_, texture)),
|
| + bounds.size());
|
| + compositor->AddObserver(this);
|
| }
|
|
|
| virtual ~WebGLBench() {
|
| - context_provider_->ContextGL()->DeleteFramebuffers(1, &fbo_);
|
| webgl_.SetShowPaintedContent();
|
| - texture_ = NULL;
|
| + gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
|
| + gl->DeleteFramebuffers(1, &fbo_);
|
| compositor_->RemoveObserver(this);
|
| }
|
|
|
| @@ -232,7 +234,6 @@ class WebGLBench : public BenchCompositorObserver {
|
| gl->Clear(GL_COLOR_BUFFER_BIT);
|
| gl->Flush();
|
| }
|
| - webgl_.SetExternalTexture(texture_.get());
|
| webgl_.SchedulePaint(gfx::Rect(webgl_.bounds().size()));
|
| compositor_->ScheduleDraw();
|
| }
|
| @@ -242,7 +243,6 @@ class WebGLBench : public BenchCompositorObserver {
|
| Layer webgl_;
|
| Compositor* compositor_;
|
| scoped_refptr<cc::ContextProvider> context_provider_;
|
| - scoped_refptr<WebGLTexture> texture_;
|
|
|
| // The FBO that is used to render to the texture.
|
| unsigned int fbo_;
|
|
|