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

Side by Side Diff: ui/gfx/ozone/dri/dri_surface.cc

Issue 132543002: Not for review. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/ozone/dri/dri_surface.h" 5 #include "ui/gfx/ozone/dri/dri_surface.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <sys/mman.h> 8 #include <sys/mman.h>
9 #include <sys/types.h> 9 #include <sys/types.h>
10 #include <xf86drm.h> 10 #include <xf86drm.h>
(...skipping 30 matching lines...) Expand all
41 // DriSurface implementation 41 // DriSurface implementation
42 42
43 DriSurface::DriSurface( 43 DriSurface::DriSurface(
44 HardwareDisplayController* controller) 44 HardwareDisplayController* controller)
45 : controller_(controller), 45 : controller_(controller),
46 bitmaps_(), 46 bitmaps_(),
47 front_buffer_(0) { 47 front_buffer_(0) {
48 } 48 }
49 49
50 DriSurface::~DriSurface() { 50 DriSurface::~DriSurface() {
51 for (unsigned int i = 0; i < 2; ++i) {
52 // If the surface fails to initialize, it may not have all the buffers
53 // created. If we fail to register a framebuffer than there is no reason to
54 // unregister it.
55 if (bitmaps_[i] && bitmaps_[i]->get_framebuffer())
56 controller_->RemoveFramebuffer(bitmaps_[i]->get_framebuffer());
57 }
51 } 58 }
52 59
53 bool DriSurface::Initialize() { 60 bool DriSurface::Initialize() {
54 for (int i = 0; i < 2; ++i) { 61 for (int i = 0; i < 2; ++i) {
55 bitmaps_[i].reset(CreateBuffer()); 62 bitmaps_[i].reset(CreateBuffer());
56 // TODO(dnicoara) Should select the configuration based on what the 63 // TODO(dnicoara) Should select the configuration based on what the
57 // underlying system supports. 64 // underlying system supports.
58 bitmaps_[i]->setConfig(SkBitmap::kARGB_8888_Config, 65 bitmaps_[i]->setConfig(SkBitmap::kARGB_8888_Config,
59 controller_->get_mode().hdisplay, 66 controller_->get_mode().hdisplay,
60 controller_->get_mode().vdisplay); 67 controller_->get_mode().vdisplay);
61 68
62 if (!bitmaps_[i]->Initialize()) { 69 if (!bitmaps_[i]->Initialize()) {
63 return false; 70 return false;
64 } 71 }
72
73 uint32_t framebuffer = 0;
74 if (!controller_->AddFramebuffer(bitmaps_[i]->GetColorDepth(),
75 bitmaps_[i]->bytesPerPixel() << 3,
76 bitmaps_[i]->rowBytes(),
77 bitmaps_[i]->get_handle(),
78 &framebuffer)) {
79 return false;
80 }
81 bitmaps_[i]->set_framebuffer(framebuffer);
65 } 82 }
66 83
67 skia_device_ = skia::AdoptRef( 84 skia_device_ = skia::AdoptRef(
68 new CustomSkBitmapDevice(*bitmaps_[front_buffer_ ^ 1].get())); 85 new CustomSkBitmapDevice(*bitmaps_[front_buffer_ ^ 1].get()));
69 skia_canvas_ = skia::AdoptRef(new SkCanvas(skia_device_.get())); 86 skia_canvas_ = skia::AdoptRef(new SkCanvas(skia_device_.get()));
70 87
71 return true; 88 return true;
72 } 89 }
73 90
74 uint32_t DriSurface::GetFramebufferId() const { 91 uint32_t DriSurface::GetFramebufferId() const {
(...skipping 29 matching lines...) Expand all
104 121
105 SkCanvas* DriSurface::GetDrawableForWidget() { 122 SkCanvas* DriSurface::GetDrawableForWidget() {
106 return skia_canvas_.get(); 123 return skia_canvas_.get();
107 } 124 }
108 125
109 DriSkBitmap* DriSurface::CreateBuffer() { 126 DriSkBitmap* DriSurface::CreateBuffer() {
110 return new DriSkBitmap(controller_->get_fd()); 127 return new DriSkBitmap(controller_->get_fd());
111 } 128 }
112 129
113 } // namespace gfx 130 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698