| Index: ui/compositor/compositor.cc
|
| diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc
|
| index 9e7c4d54496ee96db23b3253c0519a9e2c6d90a8..bfb0cdd2e89c5f732082ee5338a13ae3bed8f49e 100644
|
| --- a/ui/compositor/compositor.cc
|
| +++ b/ui/compositor/compositor.cc
|
| @@ -19,7 +19,10 @@
|
| #include "cc/layer_tree_host.h"
|
| #include "cc/output_surface.h"
|
| #include "cc/thread_impl.h"
|
| +#include "skia/ext/refptr.h"
|
| #include "third_party/skia/include/core/SkBitmap.h"
|
| +#include "third_party/skia/include/gpu/GrContext.h"
|
| +#include "third_party/skia/include/gpu/gl/GrGLInterface.h"
|
| #include "ui/compositor/compositor_observer.h"
|
| #include "ui/compositor/compositor_switches.h"
|
| #include "ui/compositor/dip_util.h"
|
| @@ -163,6 +166,55 @@ WebKit::WebGraphicsContext3D* DefaultContextFactory::CreateOffscreenContext() {
|
| return CreateContextCommon(NULL, true);
|
| }
|
|
|
| +WebKit::WebGraphicsContext3D* DefaultContextFactory::
|
| + CreateOrGetOffscreenSkiaContextForMainThread() {
|
| + CreateOrGetOffscreenContextCommon(
|
| + &offscreen_skia_context_main_thread_,
|
| + &offscreen_skia_gr_context_main_thread_);
|
| + return offscreen_skia_context_main_thread_.get();
|
| +}
|
| +
|
| +WebKit::WebGraphicsContext3D* DefaultContextFactory::
|
| + CreateOrGetOffscreenSkiaContextForCompositorThread() {
|
| + CreateOrGetOffscreenContextCommon(
|
| + &offscreen_skia_context_compositor_thread_,
|
| + &offscreen_skia_gr_context_compositor_thread_);
|
| + return offscreen_skia_context_compositor_thread_.get();
|
| +}
|
| +
|
| +GrContext* DefaultContextFactory::
|
| + CreateOrGetOffscreenSkiaGrContextForMainThread() {
|
| + CreateOrGetOffscreenSkiaContextForMainThread();
|
| + if (!offscreen_skia_context_main_thread_)
|
| + return NULL;
|
| +
|
| + if (!offscreen_skia_gr_context_main_thread_) {
|
| + skia::RefPtr<GrGLInterface> interface = skia::AdoptRef(
|
| + offscreen_skia_context_main_thread_->createGrGLInterface());
|
| + offscreen_skia_gr_context_main_thread_ = skia::AdoptRef(GrContext::Create(
|
| + kOpenGL_Shaders_GrEngine,
|
| + reinterpret_cast<GrPlatform3DContext>(interface.get())));
|
| + }
|
| + return offscreen_skia_gr_context_main_thread_.get();
|
| +}
|
| +
|
| +GrContext* DefaultContextFactory::
|
| + CreateOrGetOffscreenSkiaGrContextForCompositorThread() {
|
| + CreateOrGetOffscreenSkiaContextForCompositorThread();
|
| + if (!offscreen_skia_context_compositor_thread_)
|
| + return NULL;
|
| +
|
| + if (!offscreen_skia_gr_context_compositor_thread_) {
|
| + skia::RefPtr<GrGLInterface> interface = skia::AdoptRef(
|
| + offscreen_skia_context_compositor_thread_->createGrGLInterface());
|
| + offscreen_skia_gr_context_compositor_thread_ =
|
| + skia::AdoptRef(GrContext::Create(
|
| + kOpenGL_Shaders_GrEngine,
|
| + reinterpret_cast<GrPlatform3DContext>(interface.get())));
|
| + }
|
| + return offscreen_skia_gr_context_compositor_thread_.get();
|
| +}
|
| +
|
| void DefaultContextFactory::RemoveCompositor(Compositor* compositor) {
|
| }
|
|
|
| @@ -195,6 +247,23 @@ WebKit::WebGraphicsContext3D* DefaultContextFactory::CreateContextCommon(
|
| return context;
|
| }
|
|
|
| +void DefaultContextFactory::CreateOrGetOffscreenContextCommon(
|
| + scoped_ptr<WebKit::WebGraphicsContext3D>* context3d,
|
| + skia::RefPtr<GrContext>* gr_context) {
|
| + if ((*context3d)) {
|
| + if (!(*context3d)->makeContextCurrent() ||
|
| + (*context3d)->getGraphicsResetStatusARB()) {
|
| + if ((*gr_context))
|
| + (*gr_context)->contextDestroyed();
|
| + gr_context->clear();
|
| + context3d->reset();
|
| + }
|
| + }
|
| +
|
| + if (!(*context3d))
|
| + (*context3d) = make_scoped_ptr(CreateOffscreenContext());
|
| +}
|
| +
|
| Texture::Texture(bool flipped, const gfx::Size& size, float device_scale_factor)
|
| : size_(size),
|
| flipped_(flipped),
|
| @@ -521,6 +590,28 @@ scoped_ptr<cc::OutputSurface> Compositor::createOutputSurface() {
|
| void Compositor::didRecreateOutputSurface(bool success) {
|
| }
|
|
|
| +WebKit::WebGraphicsContext3D*
|
| + Compositor::createOrGetOffscreenContext3dForMainThread() {
|
| + return ContextFactory::GetInstance()->
|
| + CreateOrGetOffscreenSkiaContextForMainThread();
|
| +}
|
| +
|
| +WebKit::WebGraphicsContext3D*
|
| + Compositor::createOrGetOffscreenContext3dForCompositorThread() {
|
| + return ContextFactory::GetInstance()->
|
| + CreateOrGetOffscreenSkiaContextForCompositorThread();
|
| +}
|
| +
|
| +GrContext* Compositor::createOrGetOffscreenGrContextForMainThread() {
|
| + return ContextFactory::GetInstance()->
|
| + CreateOrGetOffscreenSkiaGrContextForMainThread();
|
| +}
|
| +
|
| +GrContext* Compositor::createOrGetOffscreenGrContextForCompositorThread() {
|
| + return ContextFactory::GetInstance()->
|
| + CreateOrGetOffscreenSkiaGrContextForCompositorThread();
|
| +}
|
| +
|
| scoped_ptr<cc::InputHandler> Compositor::createInputHandler() {
|
| return scoped_ptr<cc::InputHandler>();
|
| }
|
|
|