mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Previously we were using the cull rect of the SkPicture to size the GPU buffer, but Skia is too smart and shrinkwraps the cull rect, which meant we weren't sizing the GPU buffer to the right size. Fixes #814
60 lines
1.5 KiB
C++
60 lines
1.5 KiB
C++
// Copyright 2015 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef SKY_SHELL_GPU_RASTERIZER_H_
|
|
#define SKY_SHELL_GPU_RASTERIZER_H_
|
|
|
|
#include "base/memory/ref_counted.h"
|
|
#include "base/memory/weak_ptr.h"
|
|
#include "skia/ext/refptr.h"
|
|
#include "sky/shell/gpu_delegate.h"
|
|
#include "ui/gfx/geometry/size.h"
|
|
#include "ui/gfx/native_widget_types.h"
|
|
|
|
class SkPicture;
|
|
|
|
namespace gfx {
|
|
class GLContext;
|
|
class GLShareGroup;
|
|
class GLSurface;
|
|
}
|
|
|
|
namespace sky {
|
|
namespace shell {
|
|
class GaneshContext;
|
|
class GaneshSurface;
|
|
|
|
class Rasterizer : public GPUDelegate {
|
|
public:
|
|
explicit Rasterizer();
|
|
~Rasterizer() override;
|
|
|
|
base::WeakPtr<Rasterizer> GetWeakPtr();
|
|
|
|
void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) override;
|
|
void OnOutputSurfaceDestroyed() override;
|
|
void Draw(PassRefPtr<SkPicture> picture, gfx::Size size) override;
|
|
|
|
private:
|
|
void EnsureGLContext();
|
|
void EnsureGaneshSurface(intptr_t window_fbo, const gfx::Size& size);
|
|
void DrawPicture(SkPicture* picture);
|
|
|
|
scoped_refptr<gfx::GLShareGroup> share_group_;
|
|
scoped_refptr<gfx::GLSurface> surface_;
|
|
scoped_refptr<gfx::GLContext> context_;
|
|
|
|
scoped_ptr<GaneshContext> ganesh_context_;
|
|
scoped_ptr<GaneshSurface> ganesh_surface_;
|
|
|
|
base::WeakPtrFactory<Rasterizer> weak_factory_;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(Rasterizer);
|
|
};
|
|
|
|
} // namespace shell
|
|
} // namespace sky
|
|
|
|
#endif // SKY_SHELL_GPU_RASTERIZER_H_
|