Flutter Engine
 
Loading...
Searching...
No Matches
dl_test_surface_gl.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter 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.
4
6
7#include "third_party/skia/include/core/SkSurface.h"
8#include "third_party/skia/include/gpu/ganesh/SkSurfaceGanesh.h"
9
10namespace flutter {
11namespace testing {
12
14
16 size_t height,
17 PixelFormat format) {
18 gl_surface_ = std::make_unique<TestGLSurface>(DlISize(width, height));
19 gl_surface_->MakeCurrent();
20
22 return true;
23}
24
25std::shared_ptr<DlSurfaceInstance> DlOpenGLSurfaceProvider::GetPrimarySurface()
26 const {
27 if (!gl_surface_->MakeCurrent()) {
28 return nullptr;
29 }
30 return primary_;
31}
32
33std::shared_ptr<DlSurfaceInstance>
35 size_t height,
36 PixelFormat format) const {
37 auto offscreen_surface = SkSurfaces::RenderTarget(
38 (GrRecordingContext*)gl_surface_->GetGrContext().get(),
39 skgpu::Budgeted::kNo, MakeInfo(format, width, height), 1,
40 kTopLeft_GrSurfaceOrigin, nullptr, false);
41
42 offscreen_surface->getCanvas()->clear(SK_ColorTRANSPARENT);
43 return std::make_shared<DlSurfaceInstanceBase>(offscreen_surface);
44}
45
46} // namespace testing
47} // namespace flutter
std::shared_ptr< DlSurfaceInstance > GetPrimarySurface() const override
bool InitializeSurface(size_t width, size_t height, PixelFormat format) override
std::shared_ptr< DlSurfaceInstance > MakeOffscreenSurface(size_t width, size_t height, PixelFormat format) const override
static SkImageInfo MakeInfo(PixelFormat format, int w, int h)
uint32_t uint32_t * format
DlSurfaceProvider::PixelFormat PixelFormat
impeller::ISize32 DlISize
int32_t height
int32_t width