forked from flutter/flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use display list images. (flutter#102)
- Loading branch information
1 parent
cbd14ba
commit 9886da8
Showing
20 changed files
with
227 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "impeller/display_list/display_list_image_impeller.h" | ||
|
||
namespace impeller { | ||
|
||
sk_sp<DlImageImpeller> DlImageImpeller::Make(std::shared_ptr<Texture> texture) { | ||
if (!texture) { | ||
return nullptr; | ||
} | ||
return sk_sp<DlImageImpeller>(new DlImageImpeller(std::move(texture))); | ||
} | ||
|
||
DlImageImpeller::DlImageImpeller(std::shared_ptr<Texture> texture) | ||
: texture_(std::move(texture)) {} | ||
|
||
// |DlImage| | ||
DlImageImpeller::~DlImageImpeller() = default; | ||
|
||
// |DlImage| | ||
sk_sp<SkImage> DlImageImpeller::skia_image() const { | ||
return nullptr; | ||
}; | ||
|
||
// |DlImage| | ||
std::shared_ptr<impeller::Texture> DlImageImpeller::impeller_texture() const { | ||
return texture_; | ||
} | ||
|
||
// |DlImage| | ||
bool DlImageImpeller::isTextureBacked() const { | ||
// Impeller textures are always ... textures :/ | ||
return true; | ||
} | ||
|
||
// |DlImage| | ||
SkISize DlImageImpeller::dimensions() const { | ||
const auto size = texture_ ? texture_->GetSize() : ISize{}; | ||
return SkISize::Make(size.width, size.height); | ||
} | ||
|
||
// |DlImage| | ||
size_t DlImageImpeller::GetApproximateByteSize() const { | ||
auto size = sizeof(this); | ||
if (texture_) { | ||
size += texture_->GetTextureDescriptor().GetByteSizeOfBaseMipLevel(); | ||
} | ||
return size; | ||
} | ||
|
||
} // namespace impeller |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#pragma once | ||
|
||
#include "flutter/display_list/display_list_image.h" | ||
#include "flutter/fml/macros.h" | ||
#include "impeller/renderer/texture.h" | ||
|
||
namespace impeller { | ||
|
||
class DlImageImpeller final : public flutter::DlImage { | ||
public: | ||
static sk_sp<DlImageImpeller> Make(std::shared_ptr<Texture> texture); | ||
|
||
// |DlImage| | ||
~DlImageImpeller() override; | ||
|
||
// |DlImage| | ||
sk_sp<SkImage> skia_image() const override; | ||
|
||
// |DlImage| | ||
std::shared_ptr<impeller::Texture> impeller_texture() const override; | ||
|
||
// |DlImage| | ||
bool isTextureBacked() const override; | ||
|
||
// |DlImage| | ||
SkISize dimensions() const override; | ||
|
||
// |DlImage| | ||
size_t GetApproximateByteSize() const override; | ||
|
||
private: | ||
std::shared_ptr<Texture> texture_; | ||
|
||
explicit DlImageImpeller(std::shared_ptr<Texture> texture); | ||
|
||
FML_DISALLOW_COPY_AND_ASSIGN(DlImageImpeller); | ||
}; | ||
|
||
} // namespace impeller |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.