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

Side by Side Diff: ui/ozone/platform/cast/surface_factory_cast.cc

Issue 1478753003: [Chromecast] Support software rendering when disable-gpu used (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment on switch Created 5 years 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
« no previous file with comments | « ui/ozone/platform/cast/surface_factory_cast.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/cast/surface_factory_cast.h" 5 #include "ui/ozone/platform/cast/surface_factory_cast.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include <EGL/egl.h> 8 #include <EGL/egl.h>
9 9
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
11 #include "chromecast/public/cast_egl_platform.h" 11 #include "chromecast/public/cast_egl_platform.h"
12 #include "chromecast/public/graphics_types.h" 12 #include "chromecast/public/graphics_types.h"
13 #include "third_party/skia/include/core/SkSurface.h"
13 #include "ui/gfx/geometry/quad_f.h" 14 #include "ui/gfx/geometry/quad_f.h"
15 #include "ui/gfx/vsync_provider.h"
14 #include "ui/ozone/platform/cast/surface_ozone_egl_cast.h" 16 #include "ui/ozone/platform/cast/surface_ozone_egl_cast.h"
15 #include "ui/ozone/public/native_pixmap.h" 17 #include "ui/ozone/public/native_pixmap.h"
18 #include "ui/ozone/public/surface_ozone_canvas.h"
16 19
17 using chromecast::CastEglPlatform; 20 using chromecast::CastEglPlatform;
18 21
19 namespace ui { 22 namespace ui {
20 23
21 namespace { 24 namespace {
22 25
23 typedef EGLDisplay (*EGLGetDisplayFn)(NativeDisplayType); 26 typedef EGLDisplay (*EGLGetDisplayFn)(NativeDisplayType);
24 typedef EGLBoolean (*EGLTerminateFn)(EGLDisplay); 27 typedef EGLBoolean (*EGLTerminateFn)(EGLDisplay);
25 28
26 chromecast::Size FromGfxSize(const gfx::Size& size) { 29 chromecast::Size FromGfxSize(const gfx::Size& size) {
27 return chromecast::Size(size.width(), size.height()); 30 return chromecast::Size(size.width(), size.height());
28 } 31 }
29 32
30 // Initial display size to create, needed before first window is created. 33 // Initial display size to create, needed before first window is created.
31 gfx::Size GetInitialDisplaySize() { 34 gfx::Size GetInitialDisplaySize() {
32 return gfx::Size(1280, 720); 35 return gfx::Size(1280, 720);
33 } 36 }
34 37
35 // Hard lower bound on display resolution 38 // Hard lower bound on display resolution
36 gfx::Size GetMinDisplaySize() { 39 gfx::Size GetMinDisplaySize() {
37 return gfx::Size(1280, 720); 40 return gfx::Size(1280, 720);
38 } 41 }
39 42
43 class DummySurface : public SurfaceOzoneCanvas {
44 public:
45 DummySurface() {}
46 ~DummySurface() override {}
47
48 // SurfaceOzoneCanvas implementation:
49 skia::RefPtr<SkSurface> GetSurface() override { return surface_; }
50
51 void ResizeCanvas(const gfx::Size& viewport_size) override {
52 surface_ = skia::AdoptRef(SkSurface::NewRaster(SkImageInfo::MakeN32Premul(
53 viewport_size.width(), viewport_size.height())));
54 }
55
56 void PresentCanvas(const gfx::Rect& damage) override {}
57
58 scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() override {
59 return nullptr;
60 }
61
62 private:
63 skia::RefPtr<SkSurface> surface_;
64
65 DISALLOW_COPY_AND_ASSIGN(DummySurface);
66 };
67
40 } // namespace 68 } // namespace
41 69
70 SurfaceFactoryCast::SurfaceFactoryCast() : SurfaceFactoryCast(nullptr) {}
71
42 SurfaceFactoryCast::SurfaceFactoryCast(scoped_ptr<CastEglPlatform> egl_platform) 72 SurfaceFactoryCast::SurfaceFactoryCast(scoped_ptr<CastEglPlatform> egl_platform)
43 : state_(kUninitialized), 73 : state_(kUninitialized),
44 display_type_(0), 74 display_type_(0),
45 have_display_type_(false), 75 have_display_type_(false),
46 window_(0), 76 window_(0),
47 display_size_(GetInitialDisplaySize()), 77 display_size_(GetInitialDisplaySize()),
48 new_display_size_(GetInitialDisplaySize()), 78 new_display_size_(GetInitialDisplaySize()),
49 egl_platform_(egl_platform.Pass()) { 79 egl_platform_(egl_platform.Pass()) {
50 } 80 }
51 81
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 if (state_ != kInitialized) 120 if (state_ != kInitialized)
91 return; 121 return;
92 122
93 DestroyDisplayTypeAndWindow(); 123 DestroyDisplayTypeAndWindow();
94 124
95 egl_platform_->ShutdownHardware(); 125 egl_platform_->ShutdownHardware();
96 126
97 state_ = kUninitialized; 127 state_ = kUninitialized;
98 } 128 }
99 129
130 scoped_ptr<SurfaceOzoneCanvas> SurfaceFactoryCast::CreateCanvasForWidget(
131 gfx::AcceleratedWidget widget) {
132 // Software canvas support only in headless mode
133 if (egl_platform_)
134 return nullptr;
135 return make_scoped_ptr<SurfaceOzoneCanvas>(new DummySurface());
136 }
137
100 intptr_t SurfaceFactoryCast::GetNativeDisplay() { 138 intptr_t SurfaceFactoryCast::GetNativeDisplay() {
101 CreateDisplayTypeAndWindowIfNeeded(); 139 CreateDisplayTypeAndWindowIfNeeded();
102 return reinterpret_cast<intptr_t>(display_type_); 140 return reinterpret_cast<intptr_t>(display_type_);
103 } 141 }
104 142
105 void SurfaceFactoryCast::CreateDisplayTypeAndWindowIfNeeded() { 143 void SurfaceFactoryCast::CreateDisplayTypeAndWindowIfNeeded() {
106 if (state_ == kUninitialized) { 144 if (state_ == kUninitialized) {
107 InitializeHardware(); 145 InitializeHardware();
108 } 146 }
109 if (new_display_size_ != display_size_) { 147 if (new_display_size_ != display_size_) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 if (egl_platform_->MultipleSurfaceUnsupported()) 208 if (egl_platform_->MultipleSurfaceUnsupported())
171 DestroyWindow(); 209 DestroyWindow();
172 } 210 }
173 211
174 const int32* SurfaceFactoryCast::GetEGLSurfaceProperties( 212 const int32* SurfaceFactoryCast::GetEGLSurfaceProperties(
175 const int32* desired_list) { 213 const int32* desired_list) {
176 return egl_platform_->GetEGLSurfaceProperties(desired_list); 214 return egl_platform_->GetEGLSurfaceProperties(desired_list);
177 } 215 }
178 216
179 scoped_refptr<NativePixmap> SurfaceFactoryCast::CreateNativePixmap( 217 scoped_refptr<NativePixmap> SurfaceFactoryCast::CreateNativePixmap(
180 gfx::AcceleratedWidget w, 218 gfx::AcceleratedWidget widget,
181 gfx::Size size, 219 gfx::Size size,
182 gfx::BufferFormat format, 220 gfx::BufferFormat format,
183 gfx::BufferUsage usage) { 221 gfx::BufferUsage usage) {
184 class CastPixmap : public NativePixmap { 222 class CastPixmap : public NativePixmap {
185 public: 223 public:
186 CastPixmap() {} 224 CastPixmap() {}
187 225
188 void* GetEGLClientBuffer() const override { 226 void* GetEGLClientBuffer() const override {
189 // TODO(halliwell): try to implement this through CastEglPlatform. 227 // TODO(halliwell): try to implement this through CastEglPlatform.
190 return nullptr; 228 return nullptr;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 return false; 277 return false;
240 } 278 }
241 279
242 set_gl_get_proc_address.Run(gl_proc); 280 set_gl_get_proc_address.Run(gl_proc);
243 add_gl_library.Run(lib_egl); 281 add_gl_library.Run(lib_egl);
244 add_gl_library.Run(lib_gles2); 282 add_gl_library.Run(lib_gles2);
245 return true; 283 return true;
246 } 284 }
247 285
248 } // namespace ui 286 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/cast/surface_factory_cast.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698