[M50_2661] Delegated Rendering using Surfaces and Surface Layer.
authorChandan Padhi <c.padhi@samsung.com>
Wed, 20 Apr 2016 09:29:58 +0000 (14:59 +0530)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 07:55:23 +0000 (07:55 +0000)
Delegated rendering was implemented with DelegatedRendererLayer.
DelegatedRendererLayer has been removed in M50 and Surfaces and
Surface Layer have been enabled by default. Due to this, rendering
failed and black screen was observed. With this commit, we adapt
delegated rendering accordingly.

This commit also removes dead code under TIZEN_DISABLE_GPU_THREAD.

Together with: Idd982f5731c82eb1fa689cc631643f157f67c957

Bug: http://suprem.sec.samsung.net/jira/browse/TWF-893

Reviewed by: dhyuna.ko, sm.venugopal, sns.park, venu.musham

Change-Id: Ic181ab6fe0bb691cc18e167c77169753c3f83b3c
Signed-off-by: Chandan Padhi <c.padhi@samsung.com>
12 files changed:
tizen_src/chromium_impl/content/browser/compositor/context_factory_efl.cc [new file with mode: 0644]
tizen_src/chromium_impl/content/browser/compositor/context_factory_efl.h [new file with mode: 0644]
tizen_src/chromium_impl/content/browser/compositor/mailbox_output_surface_efl.cc [new file with mode: 0644]
tizen_src/chromium_impl/content/browser/compositor/mailbox_output_surface_efl.h [new file with mode: 0644]
tizen_src/chromium_impl/content/browser/renderer_host/context_factory_efl.cc [deleted file]
tizen_src/chromium_impl/content/browser/renderer_host/context_factory_efl.h [deleted file]
tizen_src/chromium_impl/content/browser/renderer_host/render_widget_host_view_efl.cc
tizen_src/chromium_impl/content/browser/renderer_host/render_widget_host_view_efl.h
tizen_src/chromium_impl/content/content_browser_efl.gypi
tizen_src/chromium_impl/ui/gl/gl_shared_context_efl.cc
tizen_src/chromium_impl/ui/gl/gl_shared_context_efl.h
tizen_src/supplement.gypi

diff --git a/tizen_src/chromium_impl/content/browser/compositor/context_factory_efl.cc b/tizen_src/chromium_impl/content/browser/compositor/context_factory_efl.cc
new file mode 100644 (file)
index 0000000..bf2396d
--- /dev/null
@@ -0,0 +1,209 @@
+// Copyright 2016 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/compositor/context_factory_efl.h"
+
+#include "cc/raster/single_thread_task_graph_runner.h"
+#include "cc/surfaces/onscreen_display_client.h"
+#include "cc/surfaces/surface_display_output_surface.h"
+#include "content/browser/compositor/mailbox_output_surface_efl.h"
+#include "content/browser/gpu/browser_gpu_channel_host_factory.h"
+#include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
+#include "content/common/gpu/client/gl_helper.h"
+#include "content/common/host_shared_bitmap_manager.h"
+#include "ui/compositor/reflector.h"
+
+namespace content {
+
+namespace {
+
+class FakeReflector : public ui::Reflector {
+ public:
+  FakeReflector() {}
+  ~FakeReflector() override {}
+  void OnMirroringCompositorResized() override {}
+  void AddMirroringLayer(ui::Layer* layer) override {}
+  void RemoveMirroringLayer(ui::Layer* layer) override {}
+};
+}
+
+static scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
+CreateGpuProcessViewContext(
+    const scoped_refptr<GpuChannelHost>& gpu_channel_host,
+    const blink::WebGraphicsContext3D::Attributes attributes,
+    int surface_id) {
+  DCHECK(gpu_channel_host.get());
+
+  GURL url("chrome://gpu/Compositor::createContext3D");
+  bool lose_context_when_out_of_memory = true;
+  return make_scoped_ptr(new WebGraphicsContext3DCommandBufferImpl(
+      surface_id, url, gpu_channel_host.get(), attributes,
+      lose_context_when_out_of_memory,
+      WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), NULL));
+}
+
+ContextFactoryEfl::ContextFactoryEfl()
+    : next_surface_id_namespace_(1u),
+      task_graph_runner_(new cc::SingleThreadTaskGraphRunner) {
+  surface_manager_ = make_scoped_ptr(new cc::SurfaceManager);
+  task_graph_runner_->Start("CompositorTileWorker1",
+                            base::SimpleThread::Options());
+}
+
+ContextFactoryEfl::~ContextFactoryEfl() {
+  task_graph_runner_->Shutdown();
+}
+
+void ContextFactoryEfl::CreateOutputSurface(
+    base::WeakPtr<ui::Compositor> compositor) {
+  blink::WebGraphicsContext3D::Attributes attrs;
+  attrs.depth = false;
+  attrs.stencil = false;
+  attrs.antialias = false;
+  attrs.shareResources = true;
+  attrs.noAutomaticFlushes = true;
+
+  scoped_refptr<content::ContextProviderCommandBuffer> context_provider;
+  content::BrowserGpuChannelHostFactory* factory =
+      content::BrowserGpuChannelHostFactory::instance();
+  content::CauseForGpuLaunch cause = content::
+      CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE;
+  scoped_refptr<content::GpuChannelHost> gpu_channel_host(
+      factory->EstablishGpuChannelSync(cause));
+  if (gpu_channel_host.get() && !gpu_channel_host->IsLost()) {
+    context_provider = content::ContextProviderCommandBuffer::Create(
+        CreateGpuProcessViewContext(gpu_channel_host, attrs, 0),
+        content::BROWSER_COMPOSITOR_ONSCREEN_CONTEXT);
+  }
+  if (!context_provider.get()) {
+    LOG(ERROR) << "Failed to create 3D context for compositor.";
+    compositor->SetOutputSurface(scoped_ptr<cc::OutputSurface>());
+  }
+
+  scoped_ptr<MailboxOutputSurfaceEfl> real_output_surface = make_scoped_ptr(
+      new MailboxOutputSurfaceEfl(context_provider, cc::RGBA_8888));
+  real_output_surface->SetCompositorClient(compositor->client());
+
+  cc::SurfaceManager* surface_manager = surface_manager_.get();
+
+  display_client_.reset(new cc::OnscreenDisplayClient(
+      std::move(real_output_surface), surface_manager, GetSharedBitmapManager(),
+      GetGpuMemoryBufferManager(), compositor->GetRendererSettings(),
+      compositor->task_runner()));
+  scoped_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface(
+      new cc::SurfaceDisplayOutputSurface(surface_manager,
+                                          compositor->surface_id_allocator(),
+                                          context_provider, nullptr));
+  display_client_->set_surface_output_surface(surface_output_surface.get());
+  surface_output_surface->set_display_client(display_client_.get());
+  display_client_->display()->Resize(compositor->size());
+  compositor->SetOutputSurface(std::move(surface_output_surface));
+}
+
+scoped_ptr<ui::Reflector> ContextFactoryEfl::CreateReflector(
+    ui::Compositor* mirrored_compositor,
+    ui::Layer* mirroring_layer) {
+  return make_scoped_ptr(new FakeReflector);
+}
+
+void ContextFactoryEfl::RemoveReflector(ui::Reflector* reflector) {}
+
+scoped_refptr<cc::ContextProvider>
+ContextFactoryEfl::SharedMainThreadContextProvider() {
+  if (shared_main_thread_contexts_.get())
+    return shared_main_thread_contexts_;
+
+  blink::WebGraphicsContext3D::Attributes attrs;
+  attrs.depth = false;
+  attrs.stencil = false;
+  attrs.antialias = false;
+  attrs.shareResources = true;
+  attrs.noAutomaticFlushes = true;
+
+  scoped_refptr<content::ContextProviderCommandBuffer> context_provider;
+  content::BrowserGpuChannelHostFactory* factory =
+      content::BrowserGpuChannelHostFactory::instance();
+  content::CauseForGpuLaunch cause = content::
+      CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE;
+  scoped_refptr<content::GpuChannelHost> gpu_channel_host(
+      factory->EstablishGpuChannelSync(cause));
+  if (gpu_channel_host.get() && !gpu_channel_host->IsLost()) {
+    shared_main_thread_contexts_ =
+        content::ContextProviderCommandBuffer::Create(
+            CreateGpuProcessViewContext(gpu_channel_host, attrs, 0),
+            content::BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT);
+  }
+
+  if (!shared_main_thread_contexts_->BindToCurrentThread())
+    shared_main_thread_contexts_ = NULL;
+  return shared_main_thread_contexts_;
+}
+
+void ContextFactoryEfl::RemoveCompositor(ui::Compositor* compositor) {}
+
+bool ContextFactoryEfl::DoesCreateTestContexts() {
+  return false;
+}
+
+uint32_t ContextFactoryEfl::GetImageTextureTarget(gfx::BufferFormat format,
+                                                  gfx::BufferUsage usage) {
+  return GL_TEXTURE_2D;
+}
+
+cc::SharedBitmapManager* ContextFactoryEfl::GetSharedBitmapManager() {
+  return content::HostSharedBitmapManager::current();
+}
+
+gpu::GpuMemoryBufferManager* ContextFactoryEfl::GetGpuMemoryBufferManager() {
+  return content::BrowserGpuMemoryBufferManager::current();
+}
+
+cc::TaskGraphRunner* ContextFactoryEfl::GetTaskGraphRunner() {
+  return task_graph_runner_.get();
+}
+
+scoped_ptr<cc::SurfaceIdAllocator>
+ContextFactoryEfl::CreateSurfaceIdAllocator() {
+  scoped_ptr<cc::SurfaceIdAllocator> allocator =
+      make_scoped_ptr(new cc::SurfaceIdAllocator(next_surface_id_namespace_++));
+  if (GetSurfaceManager())
+    allocator->RegisterSurfaceIdNamespace(GetSurfaceManager());
+  return allocator;
+}
+
+void ContextFactoryEfl::ResizeDisplay(ui::Compositor* compositor,
+                                      const gfx::Size& size) {
+  if (display_client_)
+    display_client_->display()->Resize(size);
+}
+
+ui::ContextFactory* ContextFactoryEfl::GetContextFactory() {
+  return this;
+}
+
+cc::SurfaceManager* ContextFactoryEfl::GetSurfaceManager() {
+  return surface_manager_.get();
+}
+
+GLHelper* ContextFactoryEfl::GetGLHelper() {
+  if (!gl_helper_) {
+    scoped_refptr<cc::ContextProvider> provider =
+        SharedMainThreadContextProvider();
+    if (provider.get())
+      gl_helper_.reset(
+          new GLHelper(provider->ContextGL(), provider->ContextSupport()));
+  }
+  return gl_helper_.get();
+}
+
+void ContextFactoryEfl::AddObserver(ImageTransportFactoryObserver* observer) {
+  observer_list_.AddObserver(observer);
+}
+
+void ContextFactoryEfl::RemoveObserver(
+    ImageTransportFactoryObserver* observer) {
+  observer_list_.RemoveObserver(observer);
+}
+
+}  // namespace content
diff --git a/tizen_src/chromium_impl/content/browser/compositor/context_factory_efl.h b/tizen_src/chromium_impl/content/browser/compositor/context_factory_efl.h
new file mode 100644 (file)
index 0000000..5049b57
--- /dev/null
@@ -0,0 +1,64 @@
+// Copyright 2016 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_COMPOSITOR_CONTEXT_FACTORY_EFL_H_
+#define CONTENT_BROWSER_COMPOSITOR_CONTEXT_FACTORY_EFL_H_
+
+#include "content/browser/compositor/image_transport_factory.h"
+#include "ui/compositor/compositor.h"
+
+namespace cc {
+class OnscreenDisplayClient;
+class SingleThreadTaskGraphRunner;
+class SurfaceManager;
+}
+
+namespace content {
+class ContextProviderCommandBuffer;
+
+class ContextFactoryEfl : public ui::ContextFactory,
+                          public ImageTransportFactory {
+ public:
+  ContextFactoryEfl();
+  ~ContextFactoryEfl() override;
+
+  // ui::ContextFactory implementation.
+  void CreateOutputSurface(base::WeakPtr<ui::Compositor> compositor) override;
+  scoped_ptr<ui::Reflector> CreateReflector(ui::Compositor* source,
+                                            ui::Layer* target) override;
+  void RemoveReflector(ui::Reflector* reflector) override;
+  void RemoveCompositor(ui::Compositor* compositor) override;
+  scoped_refptr<cc::ContextProvider> SharedMainThreadContextProvider() override;
+  bool DoesCreateTestContexts() override;
+  uint32_t GetImageTextureTarget(gfx::BufferFormat format,
+                                 gfx::BufferUsage usage) override;
+  cc::SharedBitmapManager* GetSharedBitmapManager() override;
+  gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override;
+  cc::TaskGraphRunner* GetTaskGraphRunner() override;
+  scoped_ptr<cc::SurfaceIdAllocator> CreateSurfaceIdAllocator() override;
+  void ResizeDisplay(ui::Compositor* compositor,
+                     const gfx::Size& size) override;
+
+  // ImageTransportFactory implementation.
+  ui::ContextFactory* GetContextFactory() override;
+  cc::SurfaceManager* GetSurfaceManager() override;
+  GLHelper* GetGLHelper() override;
+  void AddObserver(ImageTransportFactoryObserver* observer) override;
+  void RemoveObserver(ImageTransportFactoryObserver* observer) override;
+
+ private:
+  scoped_ptr<GLHelper> gl_helper_;
+  base::ObserverList<ImageTransportFactoryObserver> observer_list_;
+  scoped_ptr<cc::SurfaceManager> surface_manager_;
+  uint32_t next_surface_id_namespace_;
+  scoped_ptr<cc::OnscreenDisplayClient> display_client_;
+  scoped_ptr<cc::SingleThreadTaskGraphRunner> task_graph_runner_;
+  scoped_refptr<ContextProviderCommandBuffer> shared_main_thread_contexts_;
+
+  DISALLOW_COPY_AND_ASSIGN(ContextFactoryEfl);
+};
+
+}  // namespace content
+
+#endif  // CONTENT_BROWSER_COMPOSITOR_CONTEXT_FACTORY_EFL_H_
diff --git a/tizen_src/chromium_impl/content/browser/compositor/mailbox_output_surface_efl.cc b/tizen_src/chromium_impl/content/browser/compositor/mailbox_output_surface_efl.cc
new file mode 100644 (file)
index 0000000..838977e
--- /dev/null
@@ -0,0 +1,273 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/compositor/mailbox_output_surface_efl.h"
+
+#include "base/thread_task_runner_handle.h"
+#include "build/tizen_version.h"
+#include "cc/output/output_surface_client.h"
+#include "cc/raster/single_thread_task_graph_runner.h"
+#include "content/browser/renderer_host/render_widget_host_impl.h"
+#include "gpu/command_buffer/client/context_support.h"
+#include "gpu/command_buffer/client/gles2_interface.h"
+#include "third_party/khronos/GLES2/gl2.h"
+#include "third_party/khronos/GLES2/gl2ext.h"
+
+using gpu::gles2::GLES2Interface;
+
+namespace content {
+
+MailboxOutputSurfaceEfl::MailboxOutputSurfaceEfl(
+    const scoped_refptr<ContextProviderCommandBuffer>& context_provider,
+    cc::ResourceFormat format)
+    : cc::OutputSurface(context_provider),
+      swap_buffers_completion_callback_(
+          base::Bind(&MailboxOutputSurfaceEfl::OnSwapBuffersCompleted,
+                     base::Unretained(this))),
+      fbo_(0),
+      is_backbuffer_discarded_(false),
+      texture_upload_pending_(false),
+      format_(format) {
+  capabilities_.max_frames_pending = 1;
+  capabilities_.uses_default_gl_framebuffer = false;
+  capabilities_.adjust_deadline_for_parent = false;
+}
+
+MailboxOutputSurfaceEfl::~MailboxOutputSurfaceEfl() {}
+
+void MailboxOutputSurfaceEfl::DetachFromClient() {
+  DiscardBackbuffer();
+  while (!pending_textures_.empty()) {
+    if (pending_textures_.front().texture_id) {
+      context_provider_->ContextGL()->DeleteTextures(
+          1, &pending_textures_.front().texture_id);
+    }
+    pending_textures_.pop_front();
+  }
+  cc::OutputSurface::DetachFromClient();
+}
+
+void MailboxOutputSurfaceEfl::EnsureBackbuffer() {
+  is_backbuffer_discarded_ = false;
+
+  GLES2Interface* gl = context_provider_->ContextGL();
+
+  if (!current_backing_.texture_id) {
+    // Find a texture of matching size to recycle.
+    while (!returned_textures_.empty()) {
+      TransferableFrame& texture = returned_textures_.front();
+      if (texture.size == surface_size_) {
+        current_backing_ = texture;
+        if (current_backing_.sync_token.HasData())
+          gl->WaitSyncTokenCHROMIUM(current_backing_.sync_token.GetConstData());
+        returned_textures_.pop();
+        break;
+      }
+
+      gl->DeleteTextures(1, &texture.texture_id);
+      returned_textures_.pop();
+    }
+
+    if (!current_backing_.texture_id) {
+      gl->GenTextures(1, &current_backing_.texture_id);
+      current_backing_.size = surface_size_;
+      gl->BindTexture(GL_TEXTURE_2D, current_backing_.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, GLInternalFormat(format_),
+                     surface_size_.width(), surface_size_.height(), 0,
+                     GLDataFormat(format_), GLDataType(format_), NULL);
+      gl->GenMailboxCHROMIUM(current_backing_.mailbox.name);
+      gl->ProduceTextureCHROMIUM(GL_TEXTURE_2D, current_backing_.mailbox.name);
+      texture_upload_pending_ = true;
+    }
+  }
+}
+
+void MailboxOutputSurfaceEfl::DiscardBackbuffer() {
+  is_backbuffer_discarded_ = true;
+
+  GLES2Interface* gl = context_provider_->ContextGL();
+
+  if (current_backing_.texture_id) {
+    gl->DeleteTextures(1, &current_backing_.texture_id);
+    current_backing_ = TransferableFrame();
+  }
+
+  while (!returned_textures_.empty()) {
+    const TransferableFrame& frame = returned_textures_.front();
+    gl->DeleteTextures(1, &frame.texture_id);
+    returned_textures_.pop();
+  }
+
+  if (fbo_) {
+    gl->BindFramebuffer(GL_FRAMEBUFFER, fbo_);
+    gl->DeleteFramebuffers(1, &fbo_);
+    fbo_ = 0;
+  }
+}
+
+void MailboxOutputSurfaceEfl::Reshape(const gfx::Size& size,
+                                      float scale_factor,
+                                      bool alpha) {
+  if (size == surface_size_)
+    return;
+
+  surface_size_ = size;
+  device_scale_factor_ = scale_factor;
+  DiscardBackbuffer();
+  EnsureBackbuffer();
+}
+
+void MailboxOutputSurfaceEfl::BindFramebuffer() {
+  EnsureBackbuffer();
+  DCHECK(current_backing_.texture_id);
+
+  GLES2Interface* gl = context_provider_->ContextGL();
+
+  if (!fbo_)
+    gl->GenFramebuffers(1, &fbo_);
+  gl->BindFramebuffer(GL_FRAMEBUFFER, fbo_);
+  gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
+                           current_backing_.texture_id, 0);
+}
+
+void MailboxOutputSurfaceEfl::DrawTexture(
+    scoped_ptr<cc::GLFrameData> gl_frame_data) {
+  // Draw texture on RWHV
+  if (gl_frame_data) {
+    compositor_client_->GetTextureFromMailbox(&gl_frame_data->mailbox,
+                                              surface_size_);
+  }
+}
+
+void MailboxOutputSurfaceEfl::OnSwapAck(
+    scoped_ptr<cc::GLFrameData> gl_frame_data) {
+  // Ignore message if it's a stale one coming from a different output surface
+  // (e.g. after a lost context).
+  if (!gl_frame_data->mailbox.IsZero()) {
+    DCHECK(!gl_frame_data->size.IsEmpty());
+    // The browser could be returning the oldest or any other pending texture
+    // if it decided to skip a frame.
+    std::deque<TransferableFrame>::iterator it;
+    for (it = pending_textures_.begin(); it != pending_textures_.end(); it++) {
+      DCHECK(!it->mailbox.IsZero());
+      if (!memcmp(it->mailbox.name, gl_frame_data->mailbox.name,
+                  sizeof(it->mailbox.name))) {
+        DCHECK(it->size == gl_frame_data->size);
+        break;
+      }
+    }
+    DCHECK(it != pending_textures_.end());
+    it->sync_token = gl_frame_data->sync_token;
+
+    if (!is_backbuffer_discarded_) {
+      returned_textures_.push(*it);
+    } else {
+      context_provider_->ContextGL()->DeleteTextures(1, &it->texture_id);
+    }
+
+    pending_textures_.erase(it);
+  } else {
+    DCHECK(!pending_textures_.empty());
+    // The browser always keeps one texture as the frontbuffer.
+    // If it does not return a mailbox, it discarded the frontbuffer which is
+    // the oldest texture we sent.
+    uint32_t texture_id = pending_textures_.front().texture_id;
+    if (texture_id)
+      context_provider_->ContextGL()->DeleteTextures(1, &texture_id);
+    pending_textures_.pop_front();
+  }
+
+  if (gl_frame_data) {
+    base::Closure closure =
+        base::Bind(&MailboxOutputSurfaceEfl::DrawTexture,
+                   base::Unretained(this), base::Passed(&gl_frame_data));
+    base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure);
+  }
+  client_->DidSwapBuffersComplete();
+}
+
+void MailboxOutputSurfaceEfl::SwapBuffers(cc::CompositorFrame* frame) {
+  DCHECK(frame->gl_frame_data);
+  DCHECK(!surface_size_.IsEmpty());
+  DCHECK(surface_size_ == current_backing_.size);
+  DCHECK(frame->gl_frame_data->size == current_backing_.size);
+  DCHECK(!current_backing_.mailbox.IsZero() ||
+         context_provider_->ContextGL()->GetGraphicsResetStatusKHR() !=
+             GL_NO_ERROR);
+
+  frame->gl_frame_data->mailbox = current_backing_.mailbox;
+
+// Using glFinish call instead of glFlush, fixes black screen issue with
+// static pages and IE Fish page.
+// Black screen issue is seen on page in Tizen 2.4 product TV.
+#if TIZEN_VERSION_EQ(2, 4, 0) && defined(OS_TIZEN_TV)
+  context_provider_->ContextGL()->Finish();
+#else
+  if (texture_upload_pending_) {
+    context_provider_->ContextGL()->Finish();
+    texture_upload_pending_ = false;
+  } else {
+    context_provider_->ContextGL()->Flush();
+  }
+#endif
+
+  gpu::gles2::GLES2Interface* gl = context_provider()->ContextGL();
+  const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM();
+  gl->Flush();
+
+  gpu::SyncToken sync_token;
+  gl->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData());
+
+  frame->gl_frame_data->sync_token = sync_token;
+
+  base::Closure closure =
+      base::Bind(&MailboxOutputSurfaceEfl::OnSwapAck, base::Unretained(this),
+                 base::Passed(&frame->gl_frame_data));
+
+  context_provider()->ContextSupport()->SignalSyncToken(sync_token, closure);
+
+  client_->DidSwapBuffers();
+
+  pending_textures_.push_back(current_backing_);
+  current_backing_ = TransferableFrame();
+}
+
+bool MailboxOutputSurfaceEfl::BindToClient(cc::OutputSurfaceClient* client) {
+  if (!OutputSurface::BindToClient(client))
+    return false;
+  GetCommandBufferProxy()->SetSwapBuffersCompletionCallback(
+      swap_buffers_completion_callback_.callback());
+  return true;
+}
+
+CommandBufferProxyImpl* MailboxOutputSurfaceEfl::GetCommandBufferProxy() {
+  ContextProviderCommandBuffer* provider_command_buffer =
+      static_cast<ContextProviderCommandBuffer*>(context_provider_.get());
+  CommandBufferProxyImpl* command_buffer_proxy =
+      provider_command_buffer->GetCommandBufferProxy();
+  DCHECK(command_buffer_proxy);
+  return command_buffer_proxy;
+}
+
+void MailboxOutputSurfaceEfl::OnSwapBuffersCompleted(
+    const std::vector<ui::LatencyInfo>& latency_info,
+    gfx::SwapResult result) {
+  RenderWidgetHostImpl::CompositorFrameDrawn(latency_info);
+  OutputSurface::OnSwapBuffersComplete();
+}
+
+MailboxOutputSurfaceEfl::TransferableFrame::TransferableFrame()
+    : texture_id(0) {}
+
+MailboxOutputSurfaceEfl::TransferableFrame::TransferableFrame(
+    uint32_t texture_id,
+    const gpu::Mailbox& mailbox,
+    const gfx::Size size)
+    : texture_id(texture_id), mailbox(mailbox), size(size) {}
+
+}  // namespace content
diff --git a/tizen_src/chromium_impl/content/browser/compositor/mailbox_output_surface_efl.h b/tizen_src/chromium_impl/content/browser/compositor/mailbox_output_surface_efl.h
new file mode 100644 (file)
index 0000000..c7f9641
--- /dev/null
@@ -0,0 +1,76 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_COMPOSITOR_MAILBOX_OUTPUT_SURFACE_EFL_H_
+#define CONTENT_BROWSER_COMPOSITOR_MAILBOX_OUTPUT_SURFACE_EFL_H_
+
+#include "base/cancelable_callback.h"
+#include "cc/output/gl_frame_data.h"
+#include "cc/output/output_surface.h"
+#include "cc/resources/resource_format.h"
+#include "content/common/gpu/client/command_buffer_proxy_impl.h"
+#include "content/common/gpu/client/context_provider_command_buffer.h"
+#include "ui/gfx/swap_result.h"
+#include "ui/compositor/compositor.h"
+
+namespace content {
+
+class MailboxOutputSurfaceEfl : public cc::OutputSurface {
+ public:
+  MailboxOutputSurfaceEfl(
+      const scoped_refptr<ContextProviderCommandBuffer>& context_provider,
+      cc::ResourceFormat format);
+  ~MailboxOutputSurfaceEfl() override;
+
+  // cc::OutputSurface implementation.
+  bool BindToClient(cc::OutputSurfaceClient* client) override;
+  void DetachFromClient() override;
+  void EnsureBackbuffer() override;
+  void DiscardBackbuffer() override;
+  void Reshape(const gfx::Size& size, float scale_factor, bool alpha) override;
+  void BindFramebuffer() override;
+  void SwapBuffers(cc::CompositorFrame* frame) override;
+
+  void SetCompositorClient(ui::CompositorClient* client) {
+    compositor_client_ = client;
+  }
+
+ private:
+  void OnSwapAck(scoped_ptr<cc::GLFrameData> gl_frame_data);
+  void DrawTexture(scoped_ptr<cc::GLFrameData> gl_frame_data);
+  CommandBufferProxyImpl* GetCommandBufferProxy();
+  void OnSwapBuffersCompleted(const std::vector<ui::LatencyInfo>& latency_info,
+                              gfx::SwapResult result);
+
+  struct TransferableFrame {
+    TransferableFrame();
+    TransferableFrame(uint32_t texture_id,
+                      const gpu::Mailbox& mailbox,
+                      const gfx::Size size);
+
+    uint32_t texture_id;
+    gpu::Mailbox mailbox;
+    gpu::SyncToken sync_token;
+    gfx::Size size;
+  };
+
+  base::CancelableCallback<void(const std::vector<ui::LatencyInfo>&,
+                                gfx::SwapResult)>
+      swap_buffers_completion_callback_;
+
+  ui::CompositorClient* compositor_client_;
+
+  TransferableFrame current_backing_;
+  std::deque<TransferableFrame> pending_textures_;
+  std::queue<TransferableFrame> returned_textures_;
+
+  uint32_t fbo_;
+  bool is_backbuffer_discarded_;
+  bool texture_upload_pending_;
+  cc::ResourceFormat format_;
+};
+
+}  // namespace content
+
+#endif  // CONTENT_BROWSER_COMPOSITOR_MAILBOX_OUTPUT_SURFACE_EFL_H_
\ No newline at end of file
diff --git a/tizen_src/chromium_impl/content/browser/renderer_host/context_factory_efl.cc b/tizen_src/chromium_impl/content/browser/renderer_host/context_factory_efl.cc
deleted file mode 100644 (file)
index ef394ab..0000000
+++ /dev/null
@@ -1,581 +0,0 @@
-// Copyright 2015 Samsung Electronics. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/browser/renderer_host/context_factory_efl.h"
-
-#include "base/bind.h"
-#include "base/cancelable_callback.h"
-#include "base/memory/ref_counted.h"
-#include "base/thread_task_runner_handle.h"
-#include "base/threading/simple_thread.h"
-#include "build/tizen_version.h"
-#include "cc/blink/context_provider_web_context.h"
-#include "cc/output/gl_frame_data.h"
-#include "cc/output/compositor_frame.h"
-#include "cc/output/output_surface.h"
-#include "cc/output/output_surface_client.h"
-#include "cc/raster/single_thread_task_graph_runner.h"
-#include "cc/resources/resource_format.h"
-#include "cc/resources/resource_provider.h"
-#include "cc/surfaces/surface_id_allocator.h"
-#include "cc/raster/task_graph_runner.h"
-#include "cc/resources/transferable_resource.h"
-#include "content/public/common/content_switches.h"
-#include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
-#include "content/browser/gpu/gpu_surface_tracker.h"
-#include "content/browser/renderer_host/render_widget_host_impl.h"
-#include "content/browser/gpu/browser_gpu_channel_host_factory.h"
-#include "content/browser/gpu/browser_gpu_channel_host_factory.h"
-#if defined(TIZEN_DISABLE_GPU_THREAD)
-#include "content/browser/gpu/gpu_data_manager_impl.h"
-#endif
-#include "content/common/gpu/gpu_process_launch_causes.h"
-#include "content/common/gpu/client/command_buffer_proxy_impl.h"
-#include "content/common/gpu/client/context_provider_command_buffer.h"
-#include "content/common/host_shared_bitmap_manager.h"
-#include "ui/gl/gl_shared_context_efl.h"
-#include "gpu/command_buffer/client/context_support.h"
-#include "gpu/command_buffer/client/gles2_interface.h"
-#include "ui/compositor/reflector.h"
-
-using gpu::gles2::GLES2Interface;
-
-namespace {
-
-#if defined(TIZEN_DISABLE_GPU_THREAD)
-class NativeOutputSurfaceEfl : public cc::OutputSurface {
- public:
-  NativeOutputSurfaceEfl(
-      const scoped_refptr<cc::ContextProvider>& context_provider)
-      : cc::OutputSurface(context_provider),
-        swap_buffers_completion_callback_(
-            base::Bind(&NativeOutputSurfaceEfl::OnSwapBuffersCompleted,
-                       base::Unretained(this))) {
-    capabilities_.max_frames_pending = 1;
-    capabilities_.uses_default_gl_framebuffer = false;
-    capabilities_.adjust_deadline_for_parent = false;
-  }
-
-  virtual ~NativeOutputSurfaceEfl() {
-  }
-
-  void Reshape(const gfx::Size& size, float scale_factor) {
-    if (size == surface_size_)
-      return;
-
-    surface_size_ = size;
-    device_scale_factor_ = scale_factor;
-  }
-
-  void BindFramebuffer() {
-  }
-
-  void OnSwapAck(scoped_ptr<cc::GLFrameData> gl_frame_data) {
-    client_->DidSwapBuffersComplete();
-  }
-
-  virtual void SwapBuffers(cc::CompositorFrame* frame) override {
-    // Using glFinish call instead of glFlush it fixes black screen issue with
-    // static pages and IE Fish page. (black screen issue was seen on Tizen TV
-    context_provider_->ContextGL()->Flush();
-
-    uint32 sync_point =
-        context_provider_->ContextGL()->InsertSyncPointCHROMIUM();
-
-    frame->gl_frame_data->sync_token = gpu::SyncToken(sync_point);
-
-    base::Closure closure =
-        base::Bind(&NativeOutputSurfaceEfl::OnSwapAck, base::Unretained(this),
-                   base::Passed(&frame->gl_frame_data));
-
-    context_provider()->ContextSupport()->SignalSyncPoint(sync_point, closure);
-
-    client_->DidSwapBuffers();
-  }
-
-  virtual bool BindToClient(cc::OutputSurfaceClient* client) override {
-    if (!OutputSurface::BindToClient(client))
-      return false;
-    GetCommandBufferProxy()->SetSwapBuffersCompletionCallback(
-        swap_buffers_completion_callback_.callback());
-    return true;
-  }
-
-  size_t GetNumAcksPending() {
-    return 0;
-  }
-
- private:
-  content::CommandBufferProxyImpl* GetCommandBufferProxy() {
-    content::ContextProviderCommandBuffer* provider_command_buffer =
-        static_cast<content::ContextProviderCommandBuffer*>(
-            context_provider_.get());
-    content::CommandBufferProxyImpl* command_buffer_proxy =
-        provider_command_buffer->GetCommandBufferProxy();
-    DCHECK(command_buffer_proxy);
-    return command_buffer_proxy;
-  }
-
-  void OnSwapBuffersCompleted(
-      const std::vector<ui::LatencyInfo>& latency_info) {
-    content::RenderWidgetHostImpl::CompositorFrameDrawn(latency_info);
-    OutputSurface::OnSwapBuffersComplete();
-  }
-  base::CancelableCallback<void(const std::vector<ui::LatencyInfo>&)>
-      swap_buffers_completion_callback_;
-};
-#endif
-
-// TODO(venu.musham): Move this class into separate file.
-class MailboxOutputSurfaceEfl : public cc::OutputSurface {
- public:
-  MailboxOutputSurfaceEfl(
-      const scoped_refptr<cc::ContextProvider>& context_provider,
-      base::WeakPtr<ui::ContextFactoryEfl> context_factory_efl,
-      cc::ResourceFormat format)
-      : cc::OutputSurface(context_provider),
-        swap_buffers_completion_callback_(
-            base::Bind(&MailboxOutputSurfaceEfl::OnSwapBuffersCompleted,
-                       base::Unretained(this))),
-        context_factory_efl_(context_factory_efl),
-        fbo_(0),
-        is_backbuffer_discarded_(false),
-        texture_upload_pending_(false),
-        format_(format) {
-    capabilities_.max_frames_pending = 1;
-    capabilities_.uses_default_gl_framebuffer = false;
-    capabilities_.adjust_deadline_for_parent = false;
-  }
-
-  virtual ~MailboxOutputSurfaceEfl() {}
-
-  void DetachFromClient() override {
-    DiscardBackbuffer();
-    while (!pending_textures_.empty()) {
-      if (pending_textures_.front().texture_id) {
-        context_provider_->ContextGL()->DeleteTextures(
-            1, &pending_textures_.front().texture_id);
-      }
-      pending_textures_.pop_front();
-    }
-    cc::OutputSurface::DetachFromClient();
-  }
-  virtual void EnsureBackbuffer() override {
-    is_backbuffer_discarded_ = false;
-
-    GLES2Interface* gl = context_provider_->ContextGL();
-
-    if (!current_backing_.texture_id) {
-      // Find a texture of matching size to recycle.
-      while (!returned_textures_.empty()) {
-        TransferableFrame& texture = returned_textures_.front();
-        if (texture.size == surface_size_) {
-          current_backing_ = texture;
-          if (current_backing_.sync_token.HasData())
-            gl->WaitSyncTokenCHROMIUM(
-                current_backing_.sync_token.GetConstData());
-          returned_textures_.pop();
-          break;
-        }
-
-        gl->DeleteTextures(1, &texture.texture_id);
-        returned_textures_.pop();
-      }
-
-      if (!current_backing_.texture_id) {
-        gl->GenTextures(1, &current_backing_.texture_id);
-        current_backing_.size = surface_size_;
-        gl->BindTexture(GL_TEXTURE_2D, current_backing_.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, GLInternalFormat(format_),
-                       surface_size_.width(), surface_size_.height(), 0,
-                       GLDataFormat(format_), GLDataType(format_), NULL);
-        gl->GenMailboxCHROMIUM(current_backing_.mailbox.name);
-        gl->ProduceTextureCHROMIUM(GL_TEXTURE_2D,
-                                   current_backing_.mailbox.name);
-        texture_upload_pending_ = true;
-      }
-    }
-  }
-
-  virtual void DiscardBackbuffer() override {
-    is_backbuffer_discarded_ = true;
-
-    GLES2Interface* gl = context_provider_->ContextGL();
-
-    if (current_backing_.texture_id) {
-      gl->DeleteTextures(1, &current_backing_.texture_id);
-      current_backing_ = TransferableFrame();
-    }
-
-    while (!returned_textures_.empty()) {
-      const TransferableFrame& frame = returned_textures_.front();
-      gl->DeleteTextures(1, &frame.texture_id);
-      returned_textures_.pop();
-    }
-
-    if (fbo_) {
-      gl->BindFramebuffer(GL_FRAMEBUFFER, fbo_);
-      gl->DeleteFramebuffers(1, &fbo_);
-      fbo_ = 0;
-    }
-  }
-
-  void Reshape(const gfx::Size& size, float scale_factor) {
-    if (size == surface_size_)
-      return;
-
-    surface_size_ = size;
-    device_scale_factor_ = scale_factor;
-    DiscardBackbuffer();
-    EnsureBackbuffer();
-  }
-
-  void BindFramebuffer() {
-    EnsureBackbuffer();
-    DCHECK(current_backing_.texture_id);
-
-    GLES2Interface* gl = context_provider_->ContextGL();
-
-    if (!fbo_)
-      gl->GenFramebuffers(1, &fbo_);
-    gl->BindFramebuffer(GL_FRAMEBUFFER, fbo_);
-    gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
-                             GL_TEXTURE_2D, current_backing_.texture_id, 0);
-  }
-
-  void DrawTexture(scoped_ptr<cc::GLFrameData> gl_frame_data) {
-    // Draw texture on RWHV
-    if (gl_frame_data) {
-      context_factory_efl_->GetFrameFromMailbox(&gl_frame_data->mailbox,
-                                                surface_size_);
-    }
-  }
-
-  void OnSwapAck(scoped_ptr<cc::GLFrameData> gl_frame_data) {
-    // Ignore message if it's a stale one coming from a different output surface
-    // (e.g. after a lost context).
-    if (!gl_frame_data->mailbox.IsZero()) {
-      DCHECK(!gl_frame_data->size.IsEmpty());
-      // The browser could be returning the oldest or any other pending texture
-      // if it decided to skip a frame.
-      std::deque<TransferableFrame>::iterator it;
-      for (it = pending_textures_.begin(); it != pending_textures_.end();
-           it++) {
-        DCHECK(!it->mailbox.IsZero());
-        if (!memcmp(it->mailbox.name, gl_frame_data->mailbox.name,
-                    sizeof(it->mailbox.name))) {
-          DCHECK(it->size == gl_frame_data->size);
-          break;
-        }
-      }
-      DCHECK(it != pending_textures_.end());
-      it->sync_token = gl_frame_data->sync_token;
-
-      if (!is_backbuffer_discarded_) {
-        returned_textures_.push(*it);
-      } else {
-        context_provider_->ContextGL()->DeleteTextures(1, &it->texture_id);
-      }
-
-      pending_textures_.erase(it);
-    } else {
-      DCHECK(!pending_textures_.empty());
-      // The browser always keeps one texture as the frontbuffer.
-      // If it does not return a mailbox, it discarded the frontbuffer which is
-      // the oldest texture we sent.
-      uint32_t texture_id = pending_textures_.front().texture_id;
-      if (texture_id)
-        context_provider_->ContextGL()->DeleteTextures(1, &texture_id);
-      pending_textures_.pop_front();
-    }
-
-    if (gl_frame_data) {
-      base::Closure closure =
-          base::Bind(&MailboxOutputSurfaceEfl::DrawTexture,
-                     base::Unretained(this), base::Passed(&gl_frame_data));
-      base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure);
-    }
-    client_->DidSwapBuffersComplete();
-  }
-
-  virtual void SwapBuffers(cc::CompositorFrame* frame) override {
-    DCHECK(frame->gl_frame_data);
-    DCHECK(!surface_size_.IsEmpty());
-    DCHECK(surface_size_ == current_backing_.size);
-    DCHECK(frame->gl_frame_data->size == current_backing_.size);
-    DCHECK(!current_backing_.mailbox.IsZero() ||
-           context_provider_->ContextGL()->GetGraphicsResetStatusKHR() !=
-               GL_NO_ERROR);
-
-    frame->gl_frame_data->mailbox = current_backing_.mailbox;
-
-    // Using glFinish call instead of glFlush, fixes black screen issue with
-    // static pages and IE Fish page.
-
-    // Black screen issue is seen on page in Tizen 2.4 product TV.
-#if TIZEN_VERSION_EQ(2,4,0) && defined(OS_TIZEN_TV)
-    context_provider_->ContextGL()->Finish();
-#else
-    if (texture_upload_pending_) {
-      context_provider_->ContextGL()->Finish();
-      texture_upload_pending_ = false;
-    } else {
-      context_provider_->ContextGL()->Flush();
-    }
-#endif
-
-#if !defined(EWK_BRINGUP)
-    // [M50_2661] This file will be removed with another patch. To avoid build
-    //            break, the following code is commented.
-    //            FIXME: http://165.213.149.170/jira/browse/TWF-893
-    uint32_t sync_point =
-        context_provider_->ContextGL()->InsertSyncPointCHROMIUM();
-
-    frame->gl_frame_data->sync_token = gpu::SyncToken(sync_point);
-
-    base::Closure closure =
-        base::Bind(&MailboxOutputSurfaceEfl::OnSwapAck, base::Unretained(this),
-                   base::Passed(&frame->gl_frame_data));
-
-    context_provider()->ContextSupport()->SignalSyncPoint(sync_point, closure);
-#endif
-
-    client_->DidSwapBuffers();
-
-    pending_textures_.push_back(current_backing_);
-    current_backing_ = TransferableFrame();
-  }
-
-  virtual bool BindToClient(cc::OutputSurfaceClient* client) override {
-    if (!OutputSurface::BindToClient(client))
-      return false;
-    GetCommandBufferProxy()->SetSwapBuffersCompletionCallback(
-        swap_buffers_completion_callback_.callback());
-    return true;
-  }
-
-  size_t GetNumAcksPending() {
-    DCHECK(pending_textures_.size());
-    return pending_textures_.size() - 1;
-  }
-
- private:
-  struct TransferableFrame {
-    TransferableFrame() : texture_id(0) {}
-
-    TransferableFrame(uint32_t texture_id,
-                      const gpu::Mailbox& mailbox,
-                      const gfx::Size size)
-        : texture_id(texture_id), mailbox(mailbox), size(size) {}
-
-    uint32_t texture_id;
-    gpu::Mailbox mailbox;
-    gfx::Size size;
-    gpu::SyncToken sync_token;
-  };
-  content::CommandBufferProxyImpl* GetCommandBufferProxy() {
-    content::ContextProviderCommandBuffer* provider_command_buffer =
-        static_cast<content::ContextProviderCommandBuffer*>(
-            context_provider_.get());
-    content::CommandBufferProxyImpl* command_buffer_proxy =
-        provider_command_buffer->GetCommandBufferProxy();
-    DCHECK(command_buffer_proxy);
-    return command_buffer_proxy;
-  }
-
-  void OnSwapBuffersCompleted(
-      const std::vector<ui::LatencyInfo>& latency_info,
-      gfx::SwapResult result) {
-    content::RenderWidgetHostImpl::CompositorFrameDrawn(latency_info);
-    OutputSurface::OnSwapBuffersComplete();
-  }
-  base::CancelableCallback<void(const std::vector<ui::LatencyInfo>&,
-                                gfx::SwapResult)>
-      swap_buffers_completion_callback_;
-
-  base::WeakPtr<ui::ContextFactoryEfl> context_factory_efl_;
-
-  TransferableFrame current_backing_;
-  std::deque<TransferableFrame> pending_textures_;
-  std::queue<TransferableFrame> returned_textures_;
-
-  uint32_t fbo_;
-  bool is_backbuffer_discarded_;
-  bool texture_upload_pending_;
-  cc::ResourceFormat format_;
-};
-}  // namespace
-
-namespace content {
-
-static scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
-CreateGpuProcessViewContext(
-    const scoped_refptr<GpuChannelHost>& gpu_channel_host,
-    const blink::WebGraphicsContext3D::Attributes attributes,
-    int surface_id) {
-  DCHECK(gpu_channel_host.get());
-
-  GURL url("chrome://gpu/Compositor::createContext3D");
-  bool lose_context_when_out_of_memory = true;
-  return make_scoped_ptr(new WebGraphicsContext3DCommandBufferImpl(
-      surface_id, url, gpu_channel_host.get(), attributes,
-      lose_context_when_out_of_memory,
-      WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), NULL));
-}
-}  // namespace content
-
-namespace ui {
-namespace {
-
-class FakeReflector : public Reflector {
- public:
-  FakeReflector() {}
-  ~FakeReflector() override {}
-  void OnMirroringCompositorResized() override {}
-  void AddMirroringLayer(Layer* layer) override {}
-  void RemoveMirroringLayer(Layer* layer) override {}
-};
-
-class SingleThreadTaskGraphRunner : public cc::SingleThreadTaskGraphRunner {
- public:
-  SingleThreadTaskGraphRunner() {
-    Start("CompositorTileWorker1", base::SimpleThread::Options());
-  }
-
-  ~SingleThreadTaskGraphRunner() override { Shutdown(); }
-};
-base::LazyInstance<SingleThreadTaskGraphRunner> g_task_graph_runner = LAZY_INSTANCE_INITIALIZER;
-
-}
-
-
-ContextFactoryEfl::ContextFactoryEfl(content::ContextFactoryDelegate* delegate)
-    : delegate_(delegate),
-      next_surface_id_namespace_(1),
-      schedule_draw_factory_(this) {
-}
-
-void ContextFactoryEfl::GetFrameFromMailbox(gpu::Mailbox* mailbox,
-                                            gfx::Size size) {
-  delegate_->GetTextureFromMailbox(mailbox, size);
-}
-
-void ContextFactoryEfl::CreateOutputSurface(base::WeakPtr<Compositor> compositor) {
-  blink::WebGraphicsContext3D::Attributes attrs;
-  attrs.depth = false;
-  attrs.stencil = false;
-  attrs.antialias = false;
-  attrs.shareResources = true;
-  attrs.noAutomaticFlushes = true;
-
-  scoped_refptr<content::ContextProviderCommandBuffer> context_provider;
-  content::BrowserGpuChannelHostFactory* factory =
-      content::BrowserGpuChannelHostFactory::instance();
-  content::CauseForGpuLaunch cause = content::
-      CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE;
-  scoped_refptr<content::GpuChannelHost> gpu_channel_host(
-      factory->EstablishGpuChannelSync(cause));
-  if (gpu_channel_host.get() && !gpu_channel_host->IsLost()) {
-    context_provider = content::ContextProviderCommandBuffer::Create(
-        CreateGpuProcessViewContext(gpu_channel_host, attrs, 0),
-        content::BROWSER_COMPOSITOR_ONSCREEN_CONTEXT);
-  }
-  if (!context_provider.get()) {
-    LOG(ERROR) << "Failed to create 3D context for compositor.";
-    compositor->SetOutputSurface(scoped_ptr<cc::OutputSurface>());
-  }
-
-  cc::ResourceFormat format = cc::RGBA_8888;
-
-#if defined(TIZEN_DISABLE_GPU_THREAD)
-  if (content::GpuDataManagerImpl::GetInstance()->GpuThreadDisabled()) {
-    compositor->SetOutputSurface(make_scoped_ptr(new NativeOutputSurfaceEfl(
-        context_provider)));
-  } else {
-    compositor->SetOutputSurface(make_scoped_ptr(new MailboxOutputSurfaceEfl(
-        context_provider, schedule_draw_factory_.GetWeakPtr(), format)));
-  }
-#else
-  compositor->SetOutputSurface(make_scoped_ptr(new MailboxOutputSurfaceEfl(
-      context_provider, schedule_draw_factory_.GetWeakPtr(), format)));
-#endif
-}
-
-scoped_ptr<Reflector> ContextFactoryEfl::CreateReflector(
-    Compositor* mirrored_compositor,
-    Layer* mirroring_layer) {
-  return make_scoped_ptr(new FakeReflector);
-}
-
-void ContextFactoryEfl::RemoveReflector(Reflector* reflector) {
-}
-
-void ContextFactoryEfl::OnLostMainThreadSharedContextInsideCallback() {
-}
-
-scoped_refptr<cc::ContextProvider>
-ContextFactoryEfl::SharedMainThreadContextProvider() {
-  if (shared_main_thread_contexts_.get())
-    return shared_main_thread_contexts_;
-
-  blink::WebGraphicsContext3D::Attributes attrs;
-  attrs.depth = false;
-  attrs.stencil = false;
-  attrs.antialias = false;
-  attrs.shareResources = true;
-  attrs.noAutomaticFlushes = true;
-
-  scoped_refptr<content::ContextProviderCommandBuffer> context_provider;
-  content::BrowserGpuChannelHostFactory* factory =
-      content::BrowserGpuChannelHostFactory::instance();
-  content::CauseForGpuLaunch cause = content::
-      CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE;
-  scoped_refptr<content::GpuChannelHost> gpu_channel_host(
-      factory->EstablishGpuChannelSync(cause));
-  if (gpu_channel_host.get() && !gpu_channel_host->IsLost()) {
-  shared_main_thread_contexts_ = content::ContextProviderCommandBuffer::Create(
-        CreateGpuProcessViewContext(gpu_channel_host, attrs, 0),
-        content::BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT);
-  }
-
-  if (!shared_main_thread_contexts_->BindToCurrentThread())
-    shared_main_thread_contexts_ = NULL;
-  return shared_main_thread_contexts_;
-}
-
-void ContextFactoryEfl::RemoveCompositor(Compositor* compositor) {
-}
-
-bool ContextFactoryEfl::DoesCreateTestContexts() {
-  return false;
-}
-
-uint32_t ContextFactoryEfl::GetImageTextureTarget(gfx::BufferFormat format,
-                                                gfx::BufferUsage usage) {
-  return GL_TEXTURE_2D;
-}
-
-cc::SharedBitmapManager* ContextFactoryEfl::GetSharedBitmapManager() {
-  return content::HostSharedBitmapManager::current();
-}
-
-gpu::GpuMemoryBufferManager* ContextFactoryEfl::GetGpuMemoryBufferManager() {
-  return content::BrowserGpuMemoryBufferManager::current();
-}
-
-cc::TaskGraphRunner* ContextFactoryEfl::GetTaskGraphRunner() {
-  return g_task_graph_runner.Pointer();
-}
-
-scoped_ptr<cc::SurfaceIdAllocator>
-ContextFactoryEfl::CreateSurfaceIdAllocator() {
-  return make_scoped_ptr(
-      new cc::SurfaceIdAllocator(next_surface_id_namespace_++));
-}
-
-}  // namespace ui
diff --git a/tizen_src/chromium_impl/content/browser/renderer_host/context_factory_efl.h b/tizen_src/chromium_impl/content/browser/renderer_host/context_factory_efl.h
deleted file mode 100644 (file)
index f89b5e1..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright 2015 Samsung Electronics. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef COMPOSITOR_CONTEXT_FACTORY_EFL_H_
-#define COMPOSITOR_CONTEXT_FACTORY_EFL_H_
-
-#include "ui/compositor/compositor.h"
-
-namespace content {
-class ContextProviderCommandBuffer;
-struct ContextFactoryDelegate {
-  // Updates new texture received from mailbox on evas gl surface
-  virtual void GetTextureFromMailbox(gpu::Mailbox* mailbox, gfx::Size size) = 0;
-};
-
-class RenderWidgetHostViewEfl;
-}
-
-namespace webkit {
-namespace gpu {
-class ContextProviderInProcess;
-}
-}
-
-namespace cc_blink{
-class ContextProviderWebContext;
-}
-
-namespace ui {
-
-class ContextFactoryEfl : public ContextFactory {
- public:
-  ContextFactoryEfl(content::ContextFactoryDelegate* delegate);
-
-  void CreateOutputSurface(base::WeakPtr<Compositor> compositor) override;
-
-  scoped_ptr<Reflector> CreateReflector(Compositor* mirrored_compositor,
-                                        Layer* mirroring_layer) override;
-
-  void RemoveReflector(Reflector* reflector) override;
-
-  scoped_refptr<cc::ContextProvider> SharedMainThreadContextProvider() override;
-
-  void RemoveCompositor(Compositor* compositor) override;
-
-  bool DoesCreateTestContexts() override;
-
-  uint32_t GetImageTextureTarget(gfx::BufferFormat format,
-                                 gfx::BufferUsage usage) override;
-
-  cc::SharedBitmapManager* GetSharedBitmapManager() override;
-
-  gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override;
-
-  cc::TaskGraphRunner* GetTaskGraphRunner() override;
-
-  scoped_ptr<cc::SurfaceIdAllocator> CreateSurfaceIdAllocator() override;
-
-  void SetSurfaceID(int surface_id, gfx::AcceleratedWidget widget);
-
-  void GetFrameFromMailbox(gpu::Mailbox* mailbox, gfx::Size size);
-
-  void OnLostMainThreadSharedContextInsideCallback();
-
-  // Resize the display corresponding to this compositor to a particular size.
-  void ResizeDisplay(ui::Compositor* compositor,
-                             const gfx::Size& size) override {};
-
- private:
-  content::ContextFactoryDelegate* delegate_;
-  int surface_id_;
-  uint32_t next_surface_id_namespace_;
-  base::WeakPtrFactory<ContextFactoryEfl> schedule_draw_factory_;
-  scoped_refptr<content::ContextProviderCommandBuffer> shared_main_thread_contexts_;
-};
-
-}  // namespace ui
-
-#endif  // COMPOSITOR_CONTEXT_FACTORY_EFL_H_
index 7fe2aef..9a13cd0 100644 (file)
 #include "content/browser/compositor/resize_lock.h"
 #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
 #include "content/browser/gpu/compositor_util.h"
-#if defined(TIZEN_DISABLE_GPU_THREAD)
-#include "content/browser/gpu/gpu_data_manager_impl.h"
-#endif
 #include "content/browser/renderer_host/render_widget_host_impl.h"
 #include "content/browser/renderer_host/ui_events_helper.h"
 #include "content/browser/renderer_host/im_context_efl.h"
 #include "content/browser/renderer_host/edge_effect.h"
 #include "content/browser/renderer_host/event_with_latency_info.h"
-#include "content/browser/renderer_host/context_factory_efl.h"
 #include "content/browser/renderer_host/disambiguation_popup_efl.h"
 #include "content/browser/renderer_host/web_event_factory_efl.h"
 #include "content/browser/renderer_host/input/web_input_event_util.h"
@@ -198,7 +194,6 @@ RenderWidgetHostViewEfl::RenderWidgetHostViewEfl(RenderWidgetHost* widget,
     compositor_(NULL),
     root_layer_(new ui::Layer(ui::LAYER_SOLID_COLOR)),
     delegated_frame_host_(new DelegatedFrameHost(this)),
-    context_factory_(NULL),
     weak_factory_(this) {
   EnsureDeviceDisplayInfoInitialized();
 
@@ -291,7 +286,6 @@ void RenderWidgetHostViewEfl::InitAsChild(gfx::NativeView parent_view) {
   // IMContext calls evas() getter on 'this' so it needs to be
   // initialized after evas_ is valid
   im_context_ = IMContextEfl::Create(this);
-
   Init_EvasGL(width, height);
 }
 
@@ -351,9 +345,6 @@ RenderWidgetHostViewEfl::~RenderWidgetHostViewEfl() {
   if (compositor_)
     delete compositor_;
 
-  if (context_factory_)
-    delete context_factory_;
-
   if (evas_gl_api_)
     GL_CHECK(evas_gl_api_->glDeleteProgram(program_id_));
 }
@@ -478,26 +469,6 @@ bool RenderWidgetHostViewEfl::MakeCurrent() {
   return evas_gl_make_current(evas_gl_, evas_gl_surface_, evas_gl_context_);
 }
 
-#if defined(TIZEN_DISABLE_GPU_THREAD)
-void RenderWidgetHostViewEfl::DoCompositeNow() {
-  evas_object_image_pixels_dirty_set(content_image_, true);
-  evas_render(evas_);
-}
-
-void RenderWidgetHostViewEfl::PaintToSurface() {
-  Evas_GL_API* gl_api = evasGlApi();
-  evas_gl_make_current(evas_gl_, evas_gl_surface_, evas_gl_context_);
-  gfx::Rect bounds = GetViewBoundsInPix();
-
-  GL_CHECK(gl_api->glViewport(0, 0, bounds.width(), bounds.height()));
-  GL_CHECK(gl_api->glClearColor(1.0, 1.0, 1.0, 1.0));
-  GL_CHECK(gl_api->glClear(GL_COLOR_BUFFER_BIT));
-
-  if (BrowserGpuChannelHostFactory::instance()->GetGpuChannel())
-    compositor_->DoDraw();
-}
-#endif
-
 void RenderWidgetHostViewEfl::UpdateRotationDegrees(int rotation_degrees) {
   gfx::DeviceDisplayInfoEfl display_info;
   display_info.SetRotationDegrees(rotation_degrees);
@@ -576,12 +547,6 @@ void RenderWidgetHostViewEfl::PaintTextureToSurface(GLuint texture_id) {
 
 void RenderWidgetHostViewEfl::EvasObjectImagePixelsGetCallback(void* data, Evas_Object* obj) {
   RenderWidgetHostViewEfl* rwhv_efl = reinterpret_cast<RenderWidgetHostViewEfl*>(data);
-#if defined(TIZEN_DISABLE_GPU_THREAD)
-  if (GpuDataManagerImpl::GetInstance()->GpuThreadDisabled()) {
-    rwhv_efl->PaintToSurface();
-    return;
-  }
-#endif
   if (rwhv_efl->texture_id_)
     rwhv_efl->PaintTextureToSurface(rwhv_efl->texture_id_);
 }
@@ -615,20 +580,12 @@ void RenderWidgetHostViewEfl::Init_EvasGL(int width, int height) {
 
   evas_gl_initialized_ = true;
 
-  context_factory_ = new ui::ContextFactoryEfl(this);
-
-  compositor_ = new ui::Compositor(context_factory_,
+  compositor_ = new ui::Compositor(GetContextFactory(),
                                    base::ThreadTaskRunnerHandle::Get());
   compositor_->SetAcceleratedWidget(GetNativeViewId());
+  compositor_->SetCompositorClient(this);
   delegated_frame_host_->SetCompositor(compositor_);
 
-#if defined(TIZEN_DISABLE_GPU_THREAD)
-  if (gpu_thread_disabled) {
-    compositor_->SetCompositorClient(this);
-    GLSharedContextEfl::SetDelegate(this);
-  }
-#endif
-
   compositor_->SetRootLayer(root_layer_.get());
   gfx::Size size = GetViewBoundsInPix().size();
   root_layer_->SetBounds(gfx::Rect(0, 0, size.width(), size.height()));
@@ -782,6 +739,7 @@ bool RenderWidgetHostViewEfl::IsSurfaceAvailableForCopy() const {
 void RenderWidgetHostViewEfl::Show() {
   evas_object_show(content_image_elm_host_);
   host_->WasShown(ui::LatencyInfo());
+  delegated_frame_host_->WasShown(ui::LatencyInfo());
 }
 
 void RenderWidgetHostViewEfl::Hide() {
index df48c15..932ff67 100644 (file)
@@ -28,7 +28,6 @@
 #include "content/browser/compositor/delegated_frame_host.h"
 #include "content/browser/compositor/image_transport_factory.h"
 #include "content/browser/compositor/owned_mailbox.h"
-#include "content/browser/renderer_host/context_factory_efl.h"
 #include "content/browser/renderer_host/render_widget_host_view_base.h"
 #include "content/browser/selection/selection_controller_efl.h"
 #include "gpu/command_buffer/common/mailbox.h"
 #include "ui/events/gestures/gesture_recognizer.h"
 #include "ui/events/gestures/motion_event_aura.h"
 #include "ipc/ipc_sender.h"
-#if defined(TIZEN_DISABLE_GPU_THREAD)
-#include "ui/compositor/compositor.h"
-#include "ui/gl/gl_shared_context_efl.h"
-#endif
 
 #if (EVAS_GL_API_VERSION == 1)
 // For desktop build using efl-1.9.x ~ efl-1.11.x
@@ -84,14 +79,10 @@ class ScreenshotCapturedCallback;
 class CONTENT_EXPORT RenderWidgetHostViewEfl
     : public RenderWidgetHostViewBase,
       public DelegatedFrameHostClient,
-      public ContextFactoryDelegate,
       public ui::LayerOwner,
       public ui::GestureConsumer,
       public ui::GestureEventHelper,
-#if defined(TIZEN_DISABLE_GPU_THREAD)
       public ui::CompositorClient,
-      public GLSharedContextDelegate,
-#endif
       public base::SupportsWeakPtr<RenderWidgetHostViewEfl>,
       public IPC::Sender {
  public:
@@ -259,10 +250,6 @@ class CONTENT_EXPORT RenderWidgetHostViewEfl
       const base::TimeDelta& interval) override;
   bool MakeCurrent();
 
-#if defined(TIZEN_DISABLE_GPU_THREAD)
-  void DoCompositeNow();
-#endif
-
   SelectionControllerEfl* GetSelectionController() const {
     return selection_controller_.get();
   }
@@ -340,12 +327,9 @@ class CONTENT_EXPORT RenderWidgetHostViewEfl
   Ecore_X_Window GetEcoreXWindow() const;
 #endif
 
-#if defined(TIZEN_DISABLE_GPU_THREAD)
-  void PaintToSurface();
-#endif
   void PaintTextureToSurface(GLuint texture_id);
 
-  // overrides ContextFactoryDelegate
+  // overrides CompositorClient
   void GetTextureFromMailbox(gpu::Mailbox* mailbox,
                              gfx::Size surface_size) override;
 
@@ -422,7 +406,6 @@ class CONTENT_EXPORT RenderWidgetHostViewEfl
   ui::Compositor* compositor_;
   scoped_ptr<ui::Layer> root_layer_;
   scoped_ptr<DelegatedFrameHost> delegated_frame_host_;
-  ui::ContextFactory* context_factory_;
 
   scoped_ptr<SelectionControllerEfl> selection_controller_;
 
index 3bf85d9..c86927c 100644 (file)
@@ -4,6 +4,10 @@
 
 {
   'sources': [
+    'browser/compositor/context_factory_efl.cc',
+    'browser/compositor/context_factory_efl.h',
+    'browser/compositor/mailbox_output_surface_efl.cc',
+    'browser/compositor/mailbox_output_surface_efl.h',
     'browser/web_contents/web_contents_view_efl.h',
     'browser/web_contents/web_contents_view_efl.cc',
     'browser/web_contents/web_contents_impl_efl.h',
@@ -14,8 +18,6 @@
     'browser/web_contents/web_drag_source_efl.cc',
     'browser/tracing/tracing_controller_efl.h',
     'browser/tracing/tracing_controller_efl.cc',
-    'browser/renderer_host/context_factory_efl.h',
-    'browser/renderer_host/context_factory_efl.cc',
     'browser/renderer_host/disambiguation_popup_efl.h',
     'browser/renderer_host/disambiguation_popup_efl.cc',
     'browser/renderer_host/edge_effect.h',
index 27e756c..35fd115 100644 (file)
 #include "ui/gl/gl_context.h"
 #include "ui/gl/gl_share_group.h"
 #include "ui/gl/gpu_timing.h"
-#if defined(TIZEN_DISABLE_GPU_THREAD)
-#include "base/command_line.h"
-#endif
 
 // Defined in gl_current_context_efl.cc because of conflict in chromium
 // and efl gl includes.
 extern void* GLGetCurentContext();
 
-#if defined(TIZEN_DISABLE_GPU_THREAD)
-class GLSharedContextEflPrivate
-    : public gfx::GLContext,
-      public gfx::GLCustomApi {
- public:
-#else
 struct GLSharedContextEflPrivate : public gfx::GLContext {
-#endif
   GLSharedContextEflPrivate(Evas_Object* object)
       : GLContext(GLSharedContextEfl::GetShareGroup()) {
     Evas* evas =  evas_object_evas_get(object);
@@ -52,80 +42,18 @@ struct GLSharedContextEflPrivate : public gfx::GLContext {
     handle_ = GLGetCurentContext();
     CHECK(handle_ != EGL_NO_CONTEXT);
     evas_gl_make_current(evas_gl_, 0, 0);
-
-#if defined(TIZEN_DISABLE_GPU_THREAD)
-    use_native_surface_ =
-        base::CommandLine::ForCurrentProcess()->HasSwitch("disable-gpu-thread");
-
-    if (use_native_surface_) {
-      evas_gl_api_ = evas_gl_api_get(evas_gl_);
-      GLSharedContextEfl::GetShareGroup()->SetSharedContext(this);
-    }
-    delegate_ = 0;
-#endif
   }
 
   bool Initialize(
       gfx::GLSurface*, gfx::GpuPreference) override {
-#if defined(TIZEN_DISABLE_GPU_THREAD)
-    return use_native_surface_;
-#else
     NOTREACHED();
     return false;
-#endif
-  }
-
-#if defined(TIZEN_DISABLE_GPU_THREAD)
-  bool MakeCurrent(gfx::GLSurface* surface) override {
-    if (use_native_surface_) {
-      if (delegate_)
-        delegate_->MakeCurrent();
-
-      SetRealGLApi(this);
-      GLContext::SetCurrent(surface);
-      return true;
-    } else
-      return false;
-  }
-
-  void GetIntegerv(GLenum pname, GLint* params) override {
-    evas_gl_api_->glGetIntegerv(pname, params);
   }
 
-  void Clear(GLbitfield mask) override {
-    evas_gl_api_->glClear(mask);
-  }
-
-  void ClearColor(
-    GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) override {
-    evas_gl_api_->glClearColor(red, green, blue, alpha);
-  }
-
-  void Viewport(GLint x, GLint y, GLsizei width, GLsizei height) override {
-    evas_gl_api_->glViewport(x, y, width, height);
-  }
-
-  void BindFramebufferEXT(GLenum target, GLuint framebuffer) override {
-    evas_gl_api_->glBindFramebuffer(target, framebuffer);
-  }
-
-  void Scissor(GLint x, GLint y, GLsizei width, GLsizei height) override {
-    evas_gl_api_->glScissor(x, y, width, height);
-  }
-
-  void Disable(GLenum cap) {
-    evas_gl_api_->glDisable(cap);
-  }
-
-  void Enable(GLenum cap) {
-    evas_gl_api_->glEnable(cap);
-  }
-#else
   bool MakeCurrent(gfx::GLSurface*) override {
     NOTREACHED();
     return false;
   }
-#endif
 
   void ReleaseCurrent(gfx::GLSurface*) override {
     NOTREACHED();
@@ -163,11 +91,6 @@ struct GLSharedContextEflPrivate : public gfx::GLContext {
   Evas_GL_Context* evas_gl_context_;
   Evas_GL_Surface* evas_gl_surface_;
   Evas_GL_Config* evas_gl_config_;
-#if defined(TIZEN_DISABLE_GPU_THREAD)
-  Evas_GL_API* evas_gl_api_;
-  bool use_native_surface_;
-  GLSharedContextDelegate* delegate_;
-#endif
 };
 
 namespace {
@@ -198,9 +121,3 @@ gfx::GLShareGroup* GLSharedContextEfl::GetShareGroup() {
       new gfx::GLShareGroup();
   return share_group_.get();
 }
-
-#if defined(TIZEN_DISABLE_GPU_THREAD)
-void GLSharedContextEfl::SetDelegate(GLSharedContextDelegate* delegate) {
-  g_private_part->delegate_ = delegate;
-}
-#endif
index 29e002f..fa6cf68 100644 (file)
@@ -16,21 +16,11 @@ namespace gfx {
   class GLShareGroup;
 }
 
-#if defined(TIZEN_DISABLE_GPU_THREAD)
-class GLSharedContextDelegate {
- public:
-  virtual bool MakeCurrent() = 0;
-};
-#endif
-
 struct GL_EXPORT GLSharedContextEfl {
   static void Initialize(Evas_Object* object);
   static gfx::GLContext* GetInstance();
   static Evas_GL_Context* GetEvasGLContext();
   static gfx::GLShareGroup* GetShareGroup();
-#if defined(TIZEN_DISABLE_GPU_THREAD)
-  static void SetDelegate(GLSharedContextDelegate*);
-#endif
 };
 
 #endif
index 509d9d2..d7aca67 100644 (file)
     'enable_web_speech%': 0,
     'rtc_use_h264%' : 0, # override value in third_party/webrtc/build/common.gypi
 
-# [M44_2403] Temporary disabling the tizen_disable_gpu_thread for switching to new chromium
-#            FIXME: http://web.sec.samsung.net/bugzilla/show_bug.cgi?id=14046
-    'tizen_disable_gpu_thread%': 0,
-
     'data_dir%'  : '/usr/share/chromium-efl/',
     'exe_dir%'   : '/usr/lib/chromium-efl/',
     'edje_dir%'  : '/usr/share/chromium-efl/themes/',
         ], # conditions
       }],
 
-      ['tizen_disable_gpu_thread==1', {
-        'defines': [
-          'TIZEN_DISABLE_GPU_THREAD=1',
-        ],
-      }],
-
       ['building_for_tizen==1', {
         'defines': [
           'OS_TIZEN=1',