1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/ozone/platform/dri/dri_surface.h"
12 #include "base/logging.h"
13 #include "third_party/skia/include/core/SkCanvas.h"
14 #include "ui/gfx/geometry/rect.h"
15 #include "ui/gfx/skia_util.h"
16 #include "ui/ozone/platform/dri/dri_buffer.h"
17 #include "ui/ozone/platform/dri/dri_wrapper.h"
21 DriSurface::DriSurface(
22 DriWrapper* dri, const gfx::Size& size)
29 DriSurface::~DriSurface() {
32 bool DriSurface::Initialize() {
33 for (size_t i = 0; i < arraysize(bitmaps_); ++i) {
34 bitmaps_[i].reset(CreateBuffer());
35 // TODO(dnicoara) Should select the configuration based on what the
36 // underlying system supports.
37 SkImageInfo info = SkImageInfo::Make(size_.width(),
41 if (!bitmaps_[i]->Initialize(info)) {
49 uint32_t DriSurface::GetFramebufferId() const {
51 return backbuffer()->framebuffer();
54 uint32_t DriSurface::GetHandle() const {
56 return backbuffer()->handle();
59 // This call is made after the hardware just started displaying our back buffer.
60 // We need to update our pointer reference and synchronize the two buffers.
61 void DriSurface::SwapBuffers() {
65 // Update our front buffer pointer.
69 SkCanvas* DriSurface::GetDrawableForWidget() {
71 return backbuffer()->canvas();
74 DriBuffer* DriSurface::CreateBuffer() { return new DriBuffer(dri_); }