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

Unified Diff: ui/ozone/platform/dri/gbm_surface.cc

Issue 325133003: Refactor BufferData class into a separate file to be later used by individual gbm_bo's in EGLImage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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
« ui/ozone/platform/dri/buffer_data.cc ('K') | « ui/ozone/platform/dri/gbm.gypi ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/platform/dri/gbm_surface.cc
diff --git a/ui/ozone/platform/dri/gbm_surface.cc b/ui/ozone/platform/dri/gbm_surface.cc
index ce25072a410cf70fd06871d229080ed40da42573..99f0ae7016f9cafc6b49c4fc2605b804337dd009 100644
--- a/ui/ozone/platform/dri/gbm_surface.cc
+++ b/ui/ozone/platform/dri/gbm_surface.cc
@@ -8,107 +8,13 @@
#include "base/logging.h"
#include "third_party/skia/include/core/SkImageInfo.h"
+#include "ui/ozone/platform/dri/buffer_data.h"
#include "ui/ozone/platform/dri/dri_buffer.h"
#include "ui/ozone/platform/dri/dri_wrapper.h"
-#include "ui/ozone/platform/dri/gbm_surface.h"
#include "ui/ozone/platform/dri/hardware_display_controller.h"
namespace ui {
-namespace {
-
-// Pixel configuration for the current buffer format.
-// TODO(dnicoara) These will need to change once we'll query the hardware for
-// supported configurations.
-const uint8_t kColorDepth = 24;
-const uint8_t kPixelDepth = 32;
-
-class BufferData {
- public:
- // When we create the BufferData we need to register the buffer. Once
- // successfully registered, the |framebuffer_| field will hold the ID of the
- // buffer. The controller will use this ID when scanning out the buffer. On
- // creation we will also associate the BufferData with the buffer.
- static BufferData* CreateData(DriWrapper* dri, gbm_bo* buffer);
-
- // Callback used by GBM to destory the BufferData associated with a buffer.
- static void Destroy(gbm_bo* buffer, void* data);
-
- // Returns the BufferData associated with |buffer|. NULL if no data is
- // associated.
- static BufferData* GetData(gbm_bo* buffer);
-
- uint32_t framebuffer() const { return framebuffer_; }
- uint32_t handle() const { return handle_; }
-
- private:
- BufferData(DriWrapper* dri, gbm_bo* buffer);
- ~BufferData();
-
- DriWrapper* dri_;
-
- uint32_t handle_;
-
- // ID provided by the controller when the buffer is registered. This ID is
- // used when scanning out the buffer.
- uint32_t framebuffer_;
-
- DISALLOW_COPY_AND_ASSIGN(BufferData);
-};
-
-BufferData::BufferData(DriWrapper* dri, gbm_bo* buffer)
- : dri_(dri),
- handle_(gbm_bo_get_handle(buffer).u32),
- framebuffer_(0) {
- // Register the buffer with the controller. This will allow us to scan out the
- // buffer once we're done drawing into it. If we can't register the buffer
- // then there's no point in having BufferData associated with it.
- if (!dri_->AddFramebuffer(gbm_bo_get_width(buffer),
- gbm_bo_get_height(buffer),
- kColorDepth,
- kPixelDepth,
- gbm_bo_get_stride(buffer),
- handle_,
- &framebuffer_)) {
- LOG(ERROR) << "Failed to register buffer";
- }
-}
-
-BufferData::~BufferData() {
- if (framebuffer_)
- dri_->RemoveFramebuffer(framebuffer_);
-}
-
-// static
-BufferData* BufferData::CreateData(DriWrapper* dri,
- gbm_bo* buffer) {
- BufferData* data = new BufferData(dri, buffer);
- if (!data->framebuffer()) {
- delete data;
- return NULL;
- }
-
- // GBM can destroy the buffers at any time as long as they aren't locked. This
- // sets a callback such that we can clean up all our state when GBM destroys
- // the buffer.
- gbm_bo_set_user_data(buffer, data, BufferData::Destroy);
-
- return data;
-}
-
-// static
-void BufferData::Destroy(gbm_bo* buffer, void* data) {
- BufferData* bd = static_cast<BufferData*>(data);
- delete bd;
-}
-
-// static
-BufferData* BufferData::GetData(gbm_bo* buffer) {
- return static_cast<BufferData*>(gbm_bo_get_user_data(buffer));
-}
-
-} // namespace
-
GbmSurface::GbmSurface(gbm_device* device,
DriWrapper* dri,
const gfx::Size& size)
« ui/ozone/platform/dri/buffer_data.cc ('K') | « ui/ozone/platform/dri/gbm.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698