| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/ozone/platform/caca/caca_surface_factory.h" | 5 #include "ui/ozone/platform/caca/caca_surface_factory.h" |
| 6 | 6 |
| 7 #include "third_party/skia/include/core/SkBitmap.h" | 7 #include "third_party/skia/include/core/SkBitmap.h" |
| 8 #include "third_party/skia/include/core/SkCanvas.h" | 8 #include "third_party/skia/include/core/SkCanvas.h" |
| 9 #include "third_party/skia/include/core/SkSurface.h" | 9 #include "third_party/skia/include/core/SkSurface.h" |
| 10 #include "ui/gfx/ozone/surface_ozone_canvas.h" | 10 #include "ui/gfx/ozone/surface_ozone_canvas.h" |
| 11 #include "ui/gfx/skia_util.h" | 11 #include "ui/gfx/skia_util.h" |
| 12 #include "ui/gfx/vsync_provider.h" | 12 #include "ui/gfx/vsync_provider.h" |
| 13 #include "ui/ozone/platform/caca/caca_connection.h" | 13 #include "ui/ozone/platform/caca/caca_connection.h" |
| 14 | 14 |
| 15 namespace ui { | 15 namespace ui { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 const gfx::AcceleratedWidget kDefaultWidgetHandle = 1; | 19 const gfx::AcceleratedWidget kDefaultWidgetHandle = 1; |
| 20 | 20 |
| 21 class CacaSurface : public gfx::SurfaceOzoneCanvas { | 21 class CacaSurface : public gfx::SurfaceOzoneCanvas { |
| 22 public: | 22 public: |
| 23 CacaSurface(CacaConnection* connection); | 23 CacaSurface(CacaConnection* connection); |
| 24 virtual ~CacaSurface(); | 24 virtual ~CacaSurface(); |
| 25 | 25 |
| 26 // gfx::SurfaceOzoneCanvas overrides: | 26 // gfx::SurfaceOzoneCanvas overrides: |
| 27 virtual skia::RefPtr<SkCanvas> GetCanvas() OVERRIDE; | 27 virtual skia::RefPtr<SkCanvas> GetCanvas() OVERRIDE; |
| 28 virtual bool ResizeCanvas(const gfx::Size& viewport_size) OVERRIDE; | 28 virtual bool ResizeCanvas(const gfx::Size& viewport_size) OVERRIDE; |
| 29 virtual bool PresentCanvas() OVERRIDE; | 29 virtual bool PresentCanvas(const gfx::Rect& damage) OVERRIDE; |
| 30 virtual scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() OVERRIDE; | 30 virtual scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() OVERRIDE; |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 CacaConnection* connection_; // Not owned. | 33 CacaConnection* connection_; // Not owned. |
| 34 | 34 |
| 35 caca_dither_t* dither_; | 35 caca_dither_t* dither_; |
| 36 | 36 |
| 37 skia::RefPtr<SkSurface> surface_; | 37 skia::RefPtr<SkSurface> surface_; |
| 38 | 38 |
| 39 DISALLOW_COPY_AND_ASSIGN(CacaSurface); | 39 DISALLOW_COPY_AND_ASSIGN(CacaSurface); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 skia::RefPtr<SkCanvas> CacaSurface::GetCanvas() { | 74 skia::RefPtr<SkCanvas> CacaSurface::GetCanvas() { |
| 75 return skia::SharePtr<SkCanvas>(surface_->getCanvas()); | 75 return skia::SharePtr<SkCanvas>(surface_->getCanvas()); |
| 76 } | 76 } |
| 77 | 77 |
| 78 bool CacaSurface::ResizeCanvas(const gfx::Size& viewport_size) { | 78 bool CacaSurface::ResizeCanvas(const gfx::Size& viewport_size) { |
| 79 NOTIMPLEMENTED(); | 79 NOTIMPLEMENTED(); |
| 80 return false; | 80 return false; |
| 81 } | 81 } |
| 82 | 82 |
| 83 bool CacaSurface::PresentCanvas() { | 83 bool CacaSurface::PresentCanvas(const gfx::Rect& damage) { |
| 84 SkImageInfo info; | 84 SkImageInfo info; |
| 85 size_t row_bytes; | 85 size_t row_bytes; |
| 86 const void* pixels = surface_->peekPixels(&info, &row_bytes); | 86 const void* pixels = surface_->peekPixels(&info, &row_bytes); |
| 87 | 87 |
| 88 caca_canvas_t* canvas = caca_get_canvas(connection_->display()); | 88 caca_canvas_t* canvas = caca_get_canvas(connection_->display()); |
| 89 caca_dither_bitmap(canvas, 0, 0, | 89 caca_dither_bitmap(canvas, 0, 0, |
| 90 caca_get_canvas_width(canvas), | 90 caca_get_canvas_width(canvas), |
| 91 caca_get_canvas_height(canvas), | 91 caca_get_canvas_height(canvas), |
| 92 dither_, | 92 dither_, |
| 93 static_cast<const uint8_t*>(pixels)); | 93 static_cast<const uint8_t*>(pixels)); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 137 |
| 138 scoped_ptr<gfx::SurfaceOzoneCanvas> CacaSurfaceFactory::CreateCanvasForWidget( | 138 scoped_ptr<gfx::SurfaceOzoneCanvas> CacaSurfaceFactory::CreateCanvasForWidget( |
| 139 gfx::AcceleratedWidget widget) { | 139 gfx::AcceleratedWidget widget) { |
| 140 CHECK_EQ(INITIALIZED, state_); | 140 CHECK_EQ(INITIALIZED, state_); |
| 141 CHECK_EQ(kDefaultWidgetHandle, widget); | 141 CHECK_EQ(kDefaultWidgetHandle, widget); |
| 142 | 142 |
| 143 return make_scoped_ptr<gfx::SurfaceOzoneCanvas>(new CacaSurface(connection_)); | 143 return make_scoped_ptr<gfx::SurfaceOzoneCanvas>(new CacaSurface(connection_)); |
| 144 } | 144 } |
| 145 | 145 |
| 146 } // namespace ui | 146 } // namespace ui |
| OLD | NEW |