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

Unified Diff: ui/gfx/ozone/dri/dri_surface_factory.cc

Issue 205433002: ozone: Add OzoneSurface object that is owned by compositor, GLSurface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 9 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/gfx/ozone/dri/dri_surface_factory.h ('k') | ui/gfx/ozone/dri/dri_surface_factory_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/ozone/dri/dri_surface_factory.cc
diff --git a/ui/gfx/ozone/dri/dri_surface_factory.cc b/ui/gfx/ozone/dri/dri_surface_factory.cc
index 661944a6aa1ab692d820772f35b6016435bc0eba..a6be37f125511ad1d51c9fb14d6cb3c0c5d8c343 100644
--- a/ui/gfx/ozone/dri/dri_surface_factory.cc
+++ b/ui/gfx/ozone/dri/dri_surface_factory.cc
@@ -17,6 +17,7 @@
#include "ui/gfx/ozone/dri/dri_vsync_provider.h"
#include "ui/gfx/ozone/dri/dri_wrapper.h"
#include "ui/gfx/ozone/dri/hardware_display_controller.h"
+#include "ui/gfx/ozone/surface_ozone_base.h"
namespace gfx {
@@ -114,6 +115,37 @@ void UpdateCursorImage(DriSurface* cursor, const SkBitmap& image) {
canvas->drawBitmapRectToRect(image, &damage, damage);
}
+// Adapter from SurfaceOzone to DriSurfaceFactory
+//
+// This class is derived from SurfaceOzone and owned by the compositor.
+//
+// For DRI the hadware surface & canvas are owned by the platform, so
+// the compositor merely owns this proxy object.
+//
+// TODO(spang): Should the compositor own any bits of the DriSurface?
+class DriSurfaceAdapter : public SurfaceOzoneBase {
+ public:
+ DriSurfaceAdapter(gfx::AcceleratedWidget w, DriSurfaceFactory* dri)
+ : widget_(w), dri_(dri) {}
+ virtual ~DriSurfaceAdapter() {}
+
+ // SurfaceOzone:
+ virtual bool InitializeCanvas() OVERRIDE { return true; }
+ virtual skia::RefPtr<SkCanvas> GetCanvas() OVERRIDE {
+ return skia::SharePtr(dri_->GetCanvasForWidget(widget_));
+ }
+ virtual bool PresentCanvas() OVERRIDE {
+ return dri_->SchedulePageFlip(widget_);
+ }
+ virtual scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() OVERRIDE {
+ return dri_->CreateVSyncProvider(widget_);
+ }
+
+ private:
+ gfx::AcceleratedWidget widget_;
+ DriSurfaceFactory* dri_;
+};
+
} // namespace
DriSurfaceFactory::DriSurfaceFactory()
@@ -176,7 +208,7 @@ gfx::AcceleratedWidget DriSurfaceFactory::GetAcceleratedWidget() {
return kDefaultWidgetHandle;
}
-gfx::AcceleratedWidget DriSurfaceFactory::RealizeAcceleratedWidget(
+scoped_ptr<SurfaceOzone> DriSurfaceFactory::CreateSurfaceForWidget(
gfx::AcceleratedWidget w) {
CHECK(state_ == INITIALIZED);
// TODO(dnicoara) Once we can handle multiple displays this needs to be
@@ -190,7 +222,7 @@ gfx::AcceleratedWidget DriSurfaceFactory::RealizeAcceleratedWidget(
// hardware display.
if (!InitializeControllerForPrimaryDisplay(drm_.get(), controller_.get())) {
LOG(ERROR) << "Failed to initialize controller";
- return gfx::kNullAcceleratedWidget;
+ return scoped_ptr<SurfaceOzone>();
}
// Create a surface suitable for the current controller.
@@ -200,7 +232,7 @@ gfx::AcceleratedWidget DriSurfaceFactory::RealizeAcceleratedWidget(
if (!surface->Initialize()) {
LOG(ERROR) << "Failed to initialize surface";
- return gfx::kNullAcceleratedWidget;
+ return scoped_ptr<SurfaceOzone>();
}
// Bind the surface to the controller. This will register the backing buffers
@@ -208,13 +240,13 @@ gfx::AcceleratedWidget DriSurfaceFactory::RealizeAcceleratedWidget(
// takes ownership of the surface.
if (!controller_->BindSurfaceToController(surface.Pass())) {
LOG(ERROR) << "Failed to bind surface to controller";
- return gfx::kNullAcceleratedWidget;
+ return scoped_ptr<SurfaceOzone>();
}
// Initial cursor set.
ResetCursor();
- return reinterpret_cast<gfx::AcceleratedWidget>(controller_->get_surface());
+ return make_scoped_ptr<SurfaceOzone>(new DriSurfaceAdapter(w, this));
}
bool DriSurfaceFactory::LoadEGLGLES2Bindings(
@@ -223,12 +255,6 @@ bool DriSurfaceFactory::LoadEGLGLES2Bindings(
return false;
}
-bool DriSurfaceFactory::AttemptToResizeAcceleratedWidget(
- gfx::AcceleratedWidget w,
- const gfx::Rect& bounds) {
- return false;
-}
-
bool DriSurfaceFactory::SchedulePageFlip(gfx::AcceleratedWidget w) {
CHECK(state_ == INITIALIZED);
// TODO(dnicoara) Change this CHECK once we're running with the threaded
@@ -264,7 +290,8 @@ bool DriSurfaceFactory::SchedulePageFlip(gfx::AcceleratedWidget w) {
SkCanvas* DriSurfaceFactory::GetCanvasForWidget(
gfx::AcceleratedWidget w) {
CHECK(state_ == INITIALIZED);
- return reinterpret_cast<DriSurface*>(w)->GetDrawableForWidget();
+ CHECK_EQ(kDefaultWidgetHandle, w);
+ return controller_->get_surface()->GetDrawableForWidget();
}
scoped_ptr<gfx::VSyncProvider> DriSurfaceFactory::CreateVSyncProvider(
« no previous file with comments | « ui/gfx/ozone/dri/dri_surface_factory.h ('k') | ui/gfx/ozone/dri/dri_surface_factory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698