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

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

Issue 276753003: [Ozone-DRI] Move framebuffer initialization into the buffer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 7 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/ozone/platform/dri/dri_buffer.h ('k') | ui/ozone/platform/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/ozone/platform/dri/dri_buffer.cc
diff --git a/ui/ozone/platform/dri/dri_buffer.cc b/ui/ozone/platform/dri/dri_buffer.cc
index 11b40038ef42f30cf207ea878bd1e77db9ff6933..f3dc1b903f343619cc04e2f6ed53c650e6f59708 100644
--- a/ui/ozone/platform/dri/dri_buffer.cc
+++ b/ui/ozone/platform/dri/dri_buffer.cc
@@ -17,6 +17,27 @@ namespace ui {
namespace {
+// Modesetting cannot happen from a buffer with transparencies. Return the size
+// of a pixel without alpha.
+uint8_t GetColorDepth(SkColorType type) {
+ switch (type) {
+ case kUnknown_SkColorType:
+ case kAlpha_8_SkColorType:
+ return 0;
+ case kIndex_8_SkColorType:
+ return 8;
+ case kRGB_565_SkColorType:
+ return 16;
+ case kARGB_4444_SkColorType:
+ return 12;
+ case kPMColor_SkColorType:
+ return 24;
+ default:
+ NOTREACHED();
+ return 0;
+ }
+}
+
void DestroyDumbBuffer(int fd, uint32_t handle) {
struct drm_mode_destroy_dumb destroy_request;
destroy_request.handle = handle;
@@ -77,6 +98,9 @@ DriBuffer::~DriBuffer() {
if (!surface_)
return;
+ if (framebuffer_)
+ dri_->RemoveFramebuffer(framebuffer_);
+
SkImageInfo info;
void* pixels = const_cast<void*>(surface_->peekPixels(&info, NULL));
if (!pixels)
@@ -93,6 +117,17 @@ bool DriBuffer::Initialize(const SkImageInfo& info) {
return false;
}
+ if (!dri_->AddFramebuffer(info.width(),
+ info.height(),
+ GetColorDepth(info.colorType()),
+ info.bytesPerPixel() << 3,
+ stride_,
+ handle_,
+ &framebuffer_)) {
+ DLOG(ERROR) << "Failed to register framebuffer: " << strerror(errno);
+ return false;
+ }
+
surface_ = skia::AdoptRef(SkSurface::NewRasterDirect(info, pixels, stride_));
if (!surface_) {
DLOG(ERROR) << "Cannot install Skia pixels for drm buffer";
@@ -102,23 +137,4 @@ bool DriBuffer::Initialize(const SkImageInfo& info) {
return true;
}
-uint8_t DriBuffer::GetColorDepth() const {
- switch (surface_->getCanvas()->imageInfo().colorType()) {
- case kUnknown_SkColorType:
- case kAlpha_8_SkColorType:
- return 0;
- case kIndex_8_SkColorType:
- return 8;
- case kRGB_565_SkColorType:
- return 16;
- case kARGB_4444_SkColorType:
- return 12;
- case kPMColor_SkColorType:
- return 24;
- default:
- NOTREACHED();
- return 0;
- }
-}
-
} // namespace ui
« no previous file with comments | « ui/ozone/platform/dri/dri_buffer.h ('k') | ui/ozone/platform/dri/dri_surface_factory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698