~kdub/mir/fix-1663062-0.26.1

« back to all changes in this revision

Viewing changes to src/server/graphics/nested/platform.cpp

  • Committer: Kevin DuBois
  • Date: 2017-02-09 17:41:12 UTC
  • Revision ID: kevin.dubois@canonical.com-20170209174112-aiuhmf7qdo8smgb3
disallow using ShmBuffers as passthrough targets, as the nested server cannot map them properly as textures yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
 
76
76
    std::shared_ptr<mg::Buffer> alloc_buffer(mg::BufferProperties const& properties) override
77
77
    {
78
 
        if (passthrough_candidate(properties.size))
 
78
        if (passthrough_candidate(properties.size, properties.usage))
79
79
            return std::make_shared<mgn::Buffer>(connection, properties);
80
80
        else
81
81
            return guest_allocator->alloc_buffer(properties);
84
84
    std::shared_ptr<mg::Buffer> alloc_buffer(
85
85
        mir::geometry::Size size, uint32_t native_format, uint32_t native_flags) override
86
86
    {
87
 
        if (passthrough_candidate(size))
 
87
        if (passthrough_candidate(size, mg::BufferUsage::hardware))
88
88
            return std::make_shared<mgn::Buffer>(connection, size, native_format, native_flags);
89
89
        else
90
90
            return guest_allocator->alloc_buffer(size, native_format, native_flags);
92
92
 
93
93
    std::shared_ptr<mg::Buffer> alloc_software_buffer(mir::geometry::Size size, MirPixelFormat format) override
94
94
    {
95
 
        if (passthrough_candidate(size))
 
95
        if (passthrough_candidate(size, mg::BufferUsage::software))
96
96
            return std::make_shared<mgn::Buffer>(connection, size, format);
97
97
        else
98
98
            return guest_allocator->alloc_software_buffer(size, format);
104
104
    }
105
105
 
106
106
private:
107
 
    bool passthrough_candidate(mir::geometry::Size size)
 
107
    bool passthrough_candidate(mir::geometry::Size size, mg::BufferUsage usage)
108
108
    {
109
 
        return (size.width >= mir::geometry::Width{480}) && (size.height >= mir::geometry::Height{480});
 
109
        return connection->supports_passthrough(usage) &&
 
110
            (size.width >= mir::geometry::Width{480}) && (size.height >= mir::geometry::Height{480});
110
111
    }
111
112
    std::shared_ptr<mgn::HostConnection> const connection;
112
113
    std::shared_ptr<mg::GraphicBufferAllocator> const guest_allocator;
115
116
 
116
117
mir::UniqueModulePtr<mg::GraphicBufferAllocator> mgn::Platform::create_buffer_allocator()
117
118
{
118
 
    if (connection->supports_passthrough())
 
119
    if (connection->supports_passthrough(mg::BufferUsage::software) ||
 
120
        connection->supports_passthrough(mg::BufferUsage::hardware))
119
121
    {
120
122
        return mir::make_module_ptr<BufferAllocator>(connection, guest_platform->create_buffer_allocator());
121
123
    }