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 5 #include "flutter/shell/common/surface.h" 6 7 #include "flutter/fml/logging.h" 8 #include "third_party/skia/include/core/SkSurface.h" 9 10 namespace flutter { 11 SurfaceFrame(sk_sp<SkSurface> surface,SubmitCallback submit_callback)12SurfaceFrame::SurfaceFrame(sk_sp<SkSurface> surface, 13 SubmitCallback submit_callback) 14 : submitted_(false), surface_(surface), submit_callback_(submit_callback) { 15 FML_DCHECK(submit_callback_); 16 } 17 ~SurfaceFrame()18SurfaceFrame::~SurfaceFrame() { 19 if (submit_callback_ && !submitted_) { 20 // Dropping without a Submit. 21 submit_callback_(*this, nullptr); 22 } 23 } 24 Submit()25bool SurfaceFrame::Submit() { 26 if (submitted_) { 27 return false; 28 } 29 30 submitted_ = PerformSubmit(); 31 32 return submitted_; 33 } 34 SkiaCanvas()35SkCanvas* SurfaceFrame::SkiaCanvas() { 36 return surface_ != nullptr ? surface_->getCanvas() : nullptr; 37 } 38 SkiaSurface() const39sk_sp<SkSurface> SurfaceFrame::SkiaSurface() const { 40 return surface_; 41 } 42 PerformSubmit()43bool SurfaceFrame::PerformSubmit() { 44 if (submit_callback_ == nullptr) { 45 return false; 46 } 47 48 if (submit_callback_(*this, SkiaCanvas())) { 49 return true; 50 } 51 52 return false; 53 } 54 55 Surface::Surface() = default; 56 57 Surface::~Surface() = default; 58 GetExternalViewEmbedder()59flutter::ExternalViewEmbedder* Surface::GetExternalViewEmbedder() { 60 return nullptr; 61 } 62 MakeRenderContextCurrent()63bool Surface::MakeRenderContextCurrent() { 64 return true; 65 } 66 67 } // namespace flutter 68