Skip to content

Commit 723ca3b

Browse files
chinmaygardednfield
authored andcommitted
Add more validation logs instead of FML logs.
1 parent 2b78480 commit 723ca3b

File tree

14 files changed

+36
-27
lines changed

14 files changed

+36
-27
lines changed

impeller/aiks/aiks_unittests.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ TEST_F(AiksTest, CanRenderStrokes) {
8989
TEST_F(AiksTest, CanRenderCurvedStrokes) {
9090
Canvas canvas;
9191
Paint paint;
92-
paint.color = Color::Blue();
92+
paint.color = Color::Red();
9393
paint.stroke_width = 25.0;
9494
paint.style = Paint::Style::kStroke;
9595
canvas.DrawPath(PathBuilder{}.AddCircle({500, 500}, 250).CreatePath(), paint);
96-
// ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
96+
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
9797
}
9898

9999
TEST_F(AiksTest, CanRenderClips) {
@@ -103,7 +103,7 @@ TEST_F(AiksTest, CanRenderClips) {
103103
canvas.ClipPath(
104104
PathBuilder{}.AddRect(Rect::MakeXYWH(0, 0, 500, 500)).CreatePath());
105105
canvas.DrawPath(PathBuilder{}.AddCircle({500, 500}, 250).CreatePath(), paint);
106-
// ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
106+
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
107107
}
108108

109109
TEST_F(AiksTest, CanRenderGroupOpacity) {
@@ -138,7 +138,7 @@ TEST_F(AiksTest, CanPerformFullScreenMSAA) {
138138

139139
canvas.DrawCircle({250, 250}, 125, red);
140140

141-
// ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
141+
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
142142
}
143143

144144
} // namespace testing

impeller/base/allocation.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <algorithm>
88

99
#include "flutter/fml/logging.h"
10+
#include "impeller/base/validation.h"
1011

1112
namespace impeller {
1213

@@ -69,7 +70,7 @@ bool Allocation::Reserve(size_t reserved) {
6970
// If new length is zero, a minimum non-zero sized allocation is returned.
7071
// So this check will not trip and this routine will indicate success as
7172
// expected.
72-
FML_LOG(ERROR) << "Allocation failed. Out of host memory.";
73+
VALIDATION_LOG << "Allocation failed. Out of host memory.";
7374
return false;
7475
}
7576

impeller/compiler/compiler_unittests.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "flutter/impeller/compiler/compiler.h"
66
#include "flutter/testing/testing.h"
77
#include "gtest/gtest.h"
8+
#include "impeller/base/validation.h"
89

910
namespace impeller {
1011
namespace compiler {
@@ -25,7 +26,7 @@ class CompilerTest : public ::testing::Test {
2526
bool CanCompileFixture(const char* fixture_name) const {
2627
auto fixture = flutter::testing::OpenFixtureAsMapping(fixture_name);
2728
if (!fixture->GetMapping()) {
28-
FML_LOG(ERROR) << "Could not find shader in fixtures: " << fixture_name;
29+
VALIDATION_LOG << "Could not find shader in fixtures: " << fixture_name;
2930
return false;
3031
}
3132
Compiler::SourceOptions compiler_options(fixture_name);
@@ -34,7 +35,7 @@ class CompilerTest : public ::testing::Test {
3435
Reflector::Options reflector_options;
3536
Compiler compiler(*fixture.get(), compiler_options, reflector_options);
3637
if (!compiler.IsValid()) {
37-
FML_LOG(ERROR) << "Compilation failed: " << compiler.GetErrorMessages();
38+
VALIDATION_LOG << "Compilation failed: " << compiler.GetErrorMessages();
3839
return false;
3940
}
4041
return true;

impeller/compiler/reflector.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "flutter/impeller/geometry/matrix.h"
1717
#include "flutter/impeller/geometry/scalar.h"
1818
#include "impeller/base/strings.h"
19+
#include "impeller/base/validation.h"
1920

2021
namespace impeller {
2122
namespace compiler {
@@ -150,7 +151,7 @@ std::optional<nlohmann::json> Reflector::GenerateTemplateArguments() const {
150151

151152
const auto& entrypoints = compiler_->get_entry_points_and_stages();
152153
if (entrypoints.size() != 1) {
153-
FML_LOG(ERROR) << "Incorrect number of entrypoints in the shader. Found "
154+
VALIDATION_LOG << "Incorrect number of entrypoints in the shader. Found "
154155
<< entrypoints.size() << " but expected 1.";
155156
return std::nullopt;
156157
}

impeller/entity/content_renderer.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ class ContentRenderer {
3838
struct Options {
3939
SampleCount sample_count = SampleCount::kCount1;
4040

41-
Options() {}
42-
4341
struct Hash {
4442
constexpr std::size_t operator()(const Options& o) const {
4543
return fml::HashCombine(o.sample_count);

impeller/image/compressed_image.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
#include <stb_image.h>
88

9+
#include "impeller/base/validation.h"
10+
911
namespace impeller {
1012

1113
CompressedImage::CompressedImage(
@@ -32,7 +34,7 @@ DecompressedImage CompressedImage::Decode() const {
3234
STBI_default);
3335

3436
if (decoded == nullptr) {
35-
FML_LOG(ERROR) << "Could not decode image from host memory.";
37+
VALIDATION_LOG << "Could not decode image from host memory.";
3638
return {};
3739
}
3840

@@ -68,7 +70,7 @@ DecompressedImage CompressedImage::Decode() const {
6870
}
6971

7072
if (components == DecompressedImage::Format::kInvalid) {
71-
FML_LOG(ERROR) << "Could not detect image components when decoding.";
73+
VALIDATION_LOG << "Could not detect image components when decoding.";
7274
return {};
7375
}
7476

impeller/playground/playground.mm

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "flutter/fml/paths.h"
88
#include "flutter/testing/testing.h"
9+
#include "impeller/base/validation.h"
910
#include "impeller/image/compressed_image.h"
1011
#include "impeller/playground/playground.h"
1112
#include "impeller/renderer/allocator.h"
@@ -140,7 +141,7 @@ static void PlaygroundKeyCallback(GLFWwindow* window,
140141
auto current_drawable = [layer nextDrawable];
141142

142143
if (!current_drawable) {
143-
FML_LOG(ERROR) << "Could not acquire current drawable.";
144+
VALIDATION_LOG << "Could not acquire current drawable.";
144145
return false;
145146
}
146147

@@ -207,7 +208,7 @@ static void PlaygroundKeyCallback(GLFWwindow* window,
207208
};
208209

209210
if (!renderer_.Render(surface, wrapped_callback)) {
210-
FML_LOG(ERROR) << "Could not render into the surface.";
211+
VALIDATION_LOG << "Could not render into the surface.";
211212
return false;
212213
}
213214

@@ -228,7 +229,7 @@ CompressedImage compressed_image(
228229
// simplicity.
229230
auto image = compressed_image.Decode().ConvertToRGBA();
230231
if (!image.IsValid()) {
231-
FML_LOG(ERROR) << "Could not find fixture named " << fixture_name;
232+
VALIDATION_LOG << "Could not find fixture named " << fixture_name;
232233
return nullptr;
233234
}
234235

@@ -241,15 +242,15 @@ CompressedImage compressed_image(
241242
renderer_.GetContext()->GetPermanentsAllocator()->CreateTexture(
242243
StorageMode::kHostVisible, texture_descriptor);
243244
if (!texture) {
244-
FML_LOG(ERROR) << "Could not allocate texture for fixture " << fixture_name;
245+
VALIDATION_LOG << "Could not allocate texture for fixture " << fixture_name;
245246
return nullptr;
246247
}
247248
texture->SetLabel(fixture_name);
248249

249250
auto uploaded = texture->SetContents(image.GetAllocation()->GetMapping(),
250251
image.GetAllocation()->GetSize());
251252
if (!uploaded) {
252-
FML_LOG(ERROR) << "Could not upload texture to device memory for fixture "
253+
VALIDATION_LOG << "Could not upload texture to device memory for fixture "
253254
<< fixture_name;
254255
return nullptr;
255256
}

impeller/renderer/backend/metal/allocator_mtl.mm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "flutter/fml/build_config.h"
88
#include "flutter/fml/logging.h"
9+
#include "impeller/base/validation.h"
910
#include "impeller/renderer/backend/metal/device_buffer_mtl.h"
1011
#include "impeller/renderer/backend/metal/formats_mtl.h"
1112
#include "impeller/renderer/backend/metal/texture_mtl.h"
@@ -113,7 +114,7 @@ static MTLStorageMode ToMTLStorageMode(StorageMode mode) {
113114
auto mtl_texture_desc = ToMTLTextureDescriptor(desc);
114115

115116
if (!mtl_texture_desc) {
116-
FML_DLOG(ERROR) << "Texture descriptor was invalid.";
117+
VALIDATION_LOG << "Texture descriptor was invalid.";
117118
return nullptr;
118119
}
119120

impeller/renderer/backend/metal/context_mtl.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
NSMutableArray<id<MTLLibrary>>* found_libraries = [NSMutableArray array];
2121
for (const auto& library_path : libraries_paths) {
2222
if (!fml::IsFile(library_path)) {
23-
FML_LOG(ERROR) << "Shader library does not exist at path '"
23+
VALIDATION_LOG << "Shader library does not exist at path '"
2424
<< library_path << "'";
2525
continue;
2626
}
@@ -61,7 +61,7 @@
6161
auto library = std::shared_ptr<ShaderLibraryMTL>(new ShaderLibraryMTL(
6262
ShaderLibrariesFromFiles(device_, libraries_paths)));
6363
if (!library->IsValid()) {
64-
FML_DLOG(ERROR) << "Could not create valid Metal shader library.";
64+
VALIDATION_LOG << "Could not create valid Metal shader library.";
6565
return;
6666
}
6767
shader_library_ = std::move(library);

impeller/renderer/backend/metal/device_buffer_mtl.mm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "impeller/renderer/backend/metal/device_buffer_mtl.h"
66

77
#include "flutter/fml/logging.h"
8+
#include "impeller/base/validation.h"
89
#include "impeller/renderer/backend/metal/formats_mtl.h"
910
#include "impeller/renderer/backend/metal/texture_mtl.h"
1011

@@ -29,7 +30,7 @@
2930

3031
// Avoid overruns.
3132
if (offset + desc.GetSizeOfBaseMipLevel() > size_) {
32-
FML_DLOG(ERROR) << "Avoiding buffer overrun when creating texture.";
33+
VALIDATION_LOG << "Avoiding buffer overrun when creating texture.";
3334
return nullptr;
3435
}
3536

impeller/renderer/backend/metal/texture_mtl.mm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include "impeller/renderer/backend/metal/texture_mtl.h"
66

7+
#include "impeller/base/validation.h"
8+
79
namespace impeller {
810

911
TextureMTL::TextureMTL(TextureDescriptor p_desc, id<MTLTexture> texture)
@@ -15,8 +17,7 @@
1517
}
1618

1719
if (desc.size != GetSize()) {
18-
FML_DLOG(ERROR)
19-
<< "The texture and its descriptor disagree about its size.";
20+
VALIDATION_LOG << "The texture and its descriptor disagree about its size.";
2021
return;
2122
}
2223

impeller/renderer/backend/metal/vertex_descriptor_mtl.mm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "impeller/renderer/backend/metal/vertex_descriptor_mtl.h"
66

77
#include "flutter/fml/logging.h"
8+
#include "impeller/base/validation.h"
89

910
namespace impeller {
1011

@@ -176,7 +177,7 @@ static MTLVertexFormat ReadStageInputFormat(const ShaderStageIOSlot& input) {
176177
const auto& input = inputs[i];
177178
auto vertex_format = ReadStageInputFormat(input);
178179
if (vertex_format == MTLVertexFormatInvalid) {
179-
FML_LOG(ERROR) << "Format for input " << input.name << " not supported.";
180+
VALIDATION_LOG << "Format for input " << input.name << " not supported.";
180181
return false;
181182
}
182183

impeller/renderer/pipeline.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ class PipelineT {
7474
using Builder = PipelineBuilder<VertexShader, FragmentShader>;
7575

7676
explicit PipelineT(const Context& context)
77-
: pipeline_future_(CreatePipelineFuture(
77+
: PipelineT(CreatePipelineFuture(
7878
context,
7979
Builder::MakeDefaultPipelineDescriptor(context))) {}
8080

8181
explicit PipelineT(const Context& context,
8282
std::optional<PipelineDescriptor> desc)
83-
: pipeline_future_(CreatePipelineFuture(context, desc)) {}
83+
: PipelineT(CreatePipelineFuture(context, desc)) {}
8484

8585
explicit PipelineT(PipelineFuture future)
8686
: pipeline_future_(std::move(future)) {}

impeller/renderer/renderer.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "impeller/renderer/renderer.h"
66

77
#include "flutter/fml/logging.h"
8+
#include "impeller/base/validation.h"
89
#include "impeller/renderer/command_buffer.h"
910
#include "impeller/renderer/surface.h"
1011

@@ -69,7 +70,7 @@ bool Renderer::Render(const Surface& surface,
6970
[sema = frames_in_flight_sema_](CommandBuffer::Status result) {
7071
sema->Signal();
7172
if (result != CommandBuffer::Status::kCompleted) {
72-
FML_LOG(ERROR) << "Could not commit command buffer.";
73+
VALIDATION_LOG << "Could not commit command buffer.";
7374
}
7475
});
7576
}

0 commit comments

Comments
 (0)