| Index: ui/gfx/compositor/compositor_cc.cc
|
| diff --git a/ui/gfx/compositor/compositor_cc.cc b/ui/gfx/compositor/compositor_cc.cc
|
| index 1aaddab1d8f08deb661067cae3b8f0a9bf1c938b..d8b8e5a5f3701988d1669a26d4adf7b243c935b8 100644
|
| --- a/ui/gfx/compositor/compositor_cc.cc
|
| +++ b/ui/gfx/compositor/compositor_cc.cc
|
| @@ -8,6 +8,9 @@
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebFloatPoint.h"
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h"
|
| #include "ui/gfx/compositor/layer.h"
|
| +#include "ui/gfx/gl/gl_context.h"
|
| +#include "ui/gfx/gl/gl_surface.h"
|
| +#include "ui/gfx/gl/gl_implementation.h"
|
| #include "webkit/glue/webthread_impl.h"
|
| #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h"
|
|
|
| @@ -17,16 +20,91 @@ webkit_glue::WebThreadImpl* g_compositor_thread = NULL;
|
|
|
| namespace ui {
|
|
|
| -TextureCC::TextureCC() {
|
| +SharedResourcesCC::SharedResourcesCC() : initialized_(false) {
|
| +}
|
| +
|
| +
|
| +SharedResourcesCC::~SharedResourcesCC() {
|
| +}
|
| +
|
| +// static
|
| +SharedResourcesCC* SharedResourcesCC::GetInstance() {
|
| + // We use LeakySingletonTraits so that we don't race with
|
| + // the tear down of the gl_bindings.
|
| + SharedResourcesCC* instance = Singleton<SharedResourcesCC,
|
| + LeakySingletonTraits<SharedResourcesCC> >::get();
|
| + if (instance->Initialize()) {
|
| + return instance;
|
| + } else {
|
| + instance->Destroy();
|
| + return NULL;
|
| + }
|
| +}
|
| +
|
| +bool SharedResourcesCC::Initialize() {
|
| + if (initialized_)
|
| + return true;
|
| +
|
| + {
|
| + // The following line of code exists soley to disable IO restrictions
|
| + // on this thread long enough to perform the GL bindings.
|
| + // TODO(wjmaclean) Remove this when GL initialisation cleaned up.
|
| + base::ThreadRestrictions::ScopedAllowIO allow_io;
|
| + if (!gfx::GLSurface::InitializeOneOff() ||
|
| + gfx::GetGLImplementation() == gfx::kGLImplementationNone) {
|
| + LOG(ERROR) << "Could not load the GL bindings";
|
| + return false;
|
| + }
|
| + }
|
| +
|
| + surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false, gfx::Size(1, 1));
|
| + if (!surface_.get()) {
|
| + LOG(ERROR) << "Unable to create offscreen GL surface.";
|
| + return false;
|
| + }
|
| +
|
| + context_ = gfx::GLContext::CreateGLContext(
|
| + NULL, surface_.get(), gfx::PreferIntegratedGpu);
|
| + if (!context_.get()) {
|
| + LOG(ERROR) << "Unable to create GL context.";
|
| + return false;
|
| + }
|
| +
|
| + initialized_ = true;
|
| + return true;
|
| +}
|
| +
|
| +void SharedResourcesCC::Destroy() {
|
| + context_ = NULL;
|
| + surface_ = NULL;
|
| +
|
| + initialized_ = false;
|
| +}
|
| +
|
| +bool SharedResourcesCC::MakeSharedContextCurrent() {
|
| + DCHECK(initialized_);
|
| + return context_->MakeCurrent(surface_.get());
|
| +}
|
| +
|
| +gfx::GLShareGroup* SharedResourcesCC::GetShareGroup() {
|
| + DCHECK(initialized_);
|
| + return context_->share_group();
|
| +}
|
| +
|
| +TextureCC::TextureCC()
|
| + : texture_id_(0),
|
| + flipped_(false) {
|
| }
|
|
|
| void TextureCC::SetCanvas(const SkCanvas& canvas,
|
| const gfx::Point& origin,
|
| const gfx::Size& overall_size) {
|
| + NOTREACHED();
|
| }
|
|
|
| void TextureCC::Draw(const ui::TextureDrawParams& params,
|
| const gfx::Rect& clip_bounds_in_texture) {
|
| + NOTREACHED();
|
| }
|
|
|
| CompositorCC::CompositorCC(CompositorDelegate* delegate,
|
| @@ -57,7 +135,8 @@ void CompositorCC::TerminateThread() {
|
| }
|
|
|
| Texture* CompositorCC::CreateTexture() {
|
| - return new TextureCC();
|
| + NOTREACHED();
|
| + return NULL;
|
| }
|
|
|
| void CompositorCC::Blur(const gfx::Rect& bounds) {
|
| @@ -98,8 +177,10 @@ void CompositorCC::applyScrollDelta(const WebKit::WebSize&) {
|
| }
|
|
|
| WebKit::WebGraphicsContext3D* CompositorCC::createContext3D() {
|
| + gfx::GLShareGroup* share_group =
|
| + SharedResourcesCC::GetInstance()->GetShareGroup();
|
| WebKit::WebGraphicsContext3D* context =
|
| - new webkit::gpu::WebGraphicsContext3DInProcessImpl(widget_, NULL);
|
| + new webkit::gpu::WebGraphicsContext3DInProcessImpl(widget_, share_group);
|
| WebKit::WebGraphicsContext3D::Attributes attrs;
|
| context->initialize(attrs, 0, true);
|
| return context;
|
|
|