Skip to content

Commit cfe70e0

Browse files
authored
Revert "Run Flutter on iOS and Android with color correct Skia (flutter#3743)" (flutter#3775)
This reverts commit ffe8181.
1 parent 834fb96 commit cfe70e0

18 files changed

+94
-189
lines changed

flow/compositor_context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class CompositorContext {
2121
public:
2222
class ScopedFrame {
2323
public:
24-
SkCanvas* canvas() { return canvas_; }
24+
SkCanvas& canvas() { return *canvas_; }
2525

2626
CompositorContext& context() const { return context_; }
2727

flow/layers/layer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ class Layer {
3535
struct PrerollContext {
3636
RasterCache* raster_cache;
3737
GrContext* gr_context;
38-
sk_sp<SkColorSpace> dst_color_space;
3938
SkRect child_paint_bounds;
4039
};
4140

flow/layers/layer_tree.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,11 @@ void LayerTree::Raster(CompositorContext::ScopedFrame& frame,
2727
void LayerTree::Preroll(CompositorContext::ScopedFrame& frame,
2828
bool ignore_raster_cache) {
2929
TRACE_EVENT0("flutter", "LayerTree::Preroll");
30-
SkColorSpace* color_space =
31-
frame.canvas() ? frame.canvas()->imageInfo().colorSpace() : nullptr;
3230
frame.context().raster_cache().SetCheckboardCacheImages(
3331
checkerboard_raster_cache_images_);
3432
Layer::PrerollContext context = {
3533
ignore_raster_cache ? nullptr : &frame.context().raster_cache(),
36-
frame.gr_context(), sk_ref_sp(color_space),
37-
SkRect::MakeEmpty(),
34+
frame.gr_context(), SkRect::MakeEmpty(),
3835
};
3936
root_layer_->Preroll(&context, SkMatrix::I());
4037
}
@@ -54,7 +51,7 @@ void LayerTree::UpdateScene(SceneUpdateContext& context,
5451
#endif
5552

5653
void LayerTree::Paint(CompositorContext::ScopedFrame& frame) {
57-
Layer::PaintContext context = {*frame.canvas(), frame.context().frame_time(),
54+
Layer::PaintContext context = {frame.canvas(), frame.context().frame_time(),
5855
frame.context().engine_time(),
5956
frame.context().memory_usage(),
6057
checkerboard_offscreen_layers_};

flow/layers/picture_layer.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ PictureLayer::~PictureLayer() {
2323
void PictureLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
2424
if (auto cache = context->raster_cache) {
2525
raster_cache_result_ = cache->GetPrerolledImage(
26-
context->gr_context, picture_.get(), matrix, context->dst_color_space,
27-
is_complex_, will_change_);
26+
context->gr_context, picture_.get(), matrix, is_complex_, will_change_);
2827
}
2928

3029
SkRect bounds = picture_->cullRect().makeOffset(offset_.x(), offset_.y());

flow/raster_cache.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ static bool IsPictureWorthRasterizing(SkPicture* picture,
7171
RasterCacheResult RasterizePicture(SkPicture* picture,
7272
GrContext* context,
7373
const MatrixDecomposition& matrix,
74-
sk_sp<SkColorSpace> dst_color_space,
7574
bool checkerboard) {
7675
TRACE_EVENT0("flutter", "RasterCachePopulate");
7776

@@ -82,7 +81,7 @@ RasterCacheResult RasterizePicture(SkPicture* picture,
8281
std::ceil(logical_rect.width() * std::abs(scale.x())), // physical width
8382
std::ceil(logical_rect.height() *
8483
std::abs(scale.y())), // physical height
85-
std::move(dst_color_space) // colorspace
84+
nullptr // colorspace
8685
);
8786

8887
sk_sp<SkSurface> surface =
@@ -131,7 +130,6 @@ RasterCacheResult RasterCache::GetPrerolledImage(
131130
GrContext* context,
132131
SkPicture* picture,
133132
const SkMatrix& transformation_matrix,
134-
sk_sp<SkColorSpace> dst_color_space,
135133
bool is_complex,
136134
bool will_change) {
137135
if (!IsPictureWorthRasterizing(picture, will_change, is_complex)) {
@@ -161,8 +159,7 @@ RasterCacheResult RasterCache::GetPrerolledImage(
161159

162160
if (!entry.image.is_valid()) {
163161
entry.image =
164-
RasterizePicture(picture, context, matrix, std::move(dst_color_space),
165-
checkerboard_images_);
162+
RasterizePicture(picture, context, matrix, checkerboard_images_);
166163
}
167164

168165
// We are not considering unrasterizable images. So if we don't have an image

flow/raster_cache.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,8 @@ class RasterCache {
5353
RasterCacheResult GetPrerolledImage(GrContext* context,
5454
SkPicture* picture,
5555
const SkMatrix& transformation_matrix,
56-
sk_sp<SkColorSpace> dst_color_space,
5756
bool is_complex,
5857
bool will_change);
59-
6058
void SweepAfterFrame();
6159

6260
void Clear();

flow/raster_cache_unittests.cc

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,14 @@ TEST(RasterCache, ThresholdIsRespected) {
3232

3333
sk_sp<SkImage> image;
3434

35-
sk_sp<SkColorSpace> srgb = SkColorSpace::MakeSRGB();
3635
ASSERT_FALSE(
37-
cache.GetPrerolledImage(NULL, picture.get(), matrix, srgb, true, false)); // 1
36+
cache.GetPrerolledImage(NULL, picture.get(), matrix, true, false)); // 1
3837
cache.SweepAfterFrame();
3938
ASSERT_FALSE(
40-
cache.GetPrerolledImage(NULL, picture.get(), matrix, srgb, true, false)); // 2
39+
cache.GetPrerolledImage(NULL, picture.get(), matrix, true, false)); // 2
4140
cache.SweepAfterFrame();
4241
ASSERT_TRUE(
43-
cache.GetPrerolledImage(NULL, picture.get(), matrix, srgb, true, false)); // 3
42+
cache.GetPrerolledImage(NULL, picture.get(), matrix, true, false)); // 3
4443
cache.SweepAfterFrame();
4544
}
4645

@@ -54,15 +53,14 @@ TEST(RasterCache, ThresholdIsRespectedWhenZero) {
5453

5554
sk_sp<SkImage> image;
5655

57-
sk_sp<SkColorSpace> srgb = SkColorSpace::MakeSRGB();
5856
ASSERT_FALSE(
59-
cache.GetPrerolledImage(NULL, picture.get(), matrix, srgb, true, false)); // 1
57+
cache.GetPrerolledImage(NULL, picture.get(), matrix, true, false)); // 1
6058
cache.SweepAfterFrame();
6159
ASSERT_FALSE(
62-
cache.GetPrerolledImage(NULL, picture.get(), matrix, srgb, true, false)); // 2
60+
cache.GetPrerolledImage(NULL, picture.get(), matrix, true, false)); // 2
6361
cache.SweepAfterFrame();
6462
ASSERT_FALSE(
65-
cache.GetPrerolledImage(NULL, picture.get(), matrix, srgb, true, false)); // 3
63+
cache.GetPrerolledImage(NULL, picture.get(), matrix, true, false)); // 3
6664
cache.SweepAfterFrame();
6765
}
6866

@@ -76,20 +74,19 @@ TEST(RasterCache, SweepsRemoveUnusedFrames) {
7674

7775
sk_sp<SkImage> image;
7876

79-
sk_sp<SkColorSpace> srgb = SkColorSpace::MakeSRGB();
8077
ASSERT_FALSE(
81-
cache.GetPrerolledImage(NULL, picture.get(), matrix, srgb, true, false)); // 1
78+
cache.GetPrerolledImage(NULL, picture.get(), matrix, true, false)); // 1
8279
cache.SweepAfterFrame();
8380
ASSERT_FALSE(
84-
cache.GetPrerolledImage(NULL, picture.get(), matrix, srgb, true, false)); // 2
81+
cache.GetPrerolledImage(NULL, picture.get(), matrix, true, false)); // 2
8582
cache.SweepAfterFrame();
8683
ASSERT_TRUE(
87-
cache.GetPrerolledImage(NULL, picture.get(), matrix, srgb, true, false)); // 3
84+
cache.GetPrerolledImage(NULL, picture.get(), matrix, true, false)); // 3
8885
cache.SweepAfterFrame();
8986
ASSERT_TRUE(
90-
cache.GetPrerolledImage(NULL, picture.get(), matrix, srgb, true, false)); // 4
87+
cache.GetPrerolledImage(NULL, picture.get(), matrix, true, false)); // 4
9188
cache.SweepAfterFrame();
9289
cache.SweepAfterFrame(); // Extra frame without a preroll image access.
9390
ASSERT_FALSE(
94-
cache.GetPrerolledImage(NULL, picture.get(), matrix, srgb, true, false)); // 5
91+
cache.GetPrerolledImage(NULL, picture.get(), matrix, true, false)); // 5
9592
}

lib/ui/painting/image_decoding.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ sk_sp<SkImage> DecodeImage(sk_sp<SkData> buffer) {
3232

3333
GrContext* context = ResourceContext::Get();
3434
if (context) {
35-
// This acts as a flag to indicate that we want a color space aware decode.
36-
sk_sp<SkColorSpace> dstColorSpace = SkColorSpace::MakeSRGB();
35+
// TODO: Supply actual destination color space once available
3736
return SkImage::MakeCrossContextFromEncoded(context, std::move(buffer),
38-
false, dstColorSpace.get());
37+
false, nullptr);
3938
} else {
4039
return SkImage::MakeFromEncoded(std::move(buffer));
4140
}

shell/gpu/gpu_surface_gl.cc

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include "lib/ftl/arraysize.h"
99
#include "lib/ftl/logging.h"
1010
#include "third_party/skia/include/core/SkSurface.h"
11-
#include "third_party/skia/include/gpu/GrContextOptions.h"
1211
#include "third_party/skia/include/gpu/gl/GrGLInterface.h"
1312

1413
namespace shell {
@@ -45,12 +44,9 @@ bool GPUSurfaceGL::Setup() {
4544
auto backend_context =
4645
reinterpret_cast<GrBackendContext>(GrGLCreateNativeInterface());
4746

48-
GrContextOptions options;
49-
options.fRequireDecodeDisableForSRGB = false;
50-
5147
context_ =
52-
sk_sp<GrContext>(GrContext::Create(kOpenGL_GrBackend, backend_context,
53-
options));
48+
sk_sp<GrContext>(GrContext::Create(kOpenGL_GrBackend, backend_context));
49+
5450
if (context_ == nullptr) {
5551
FTL_LOG(INFO) << "Failed to setup Skia Gr context.";
5652
return false;
@@ -108,16 +104,15 @@ bool GPUSurfaceGL::PresentSurface(SkCanvas* canvas) {
108104
}
109105

110106
bool GPUSurfaceGL::SelectPixelConfig(GrPixelConfig* config) {
111-
if (delegate_->ColorSpace() && delegate_->ColorSpace()->gammaCloseToSRGB()) {
112-
FTL_DCHECK(context_->caps()->isConfigRenderable(kSRGBA_8888_GrPixelConfig,
113-
false));
114-
*config = kSRGBA_8888_GrPixelConfig;
115-
return true;
116-
}
107+
static const GrPixelConfig kConfigOptions[] = {
108+
kSkia8888_GrPixelConfig, kRGBA_4444_GrPixelConfig,
109+
};
117110

118-
if (context_->caps()->isConfigRenderable(kRGBA_8888_GrPixelConfig, false)) {
119-
*config = kRGBA_8888_GrPixelConfig;
120-
return true;
111+
for (size_t i = 0; i < arraysize(kConfigOptions); i++) {
112+
if (context_->caps()->isConfigRenderable(kConfigOptions[i], false)) {
113+
*config = kConfigOptions[i];
114+
return true;
115+
}
121116
}
122117

123118
return false;
@@ -129,6 +124,7 @@ sk_sp<SkSurface> GPUSurfaceGL::CreateSurface(const SkISize& size) {
129124
}
130125

131126
GrBackendRenderTargetDesc desc;
127+
132128
if (!SelectPixelConfig(&desc.fConfig)) {
133129
return nullptr;
134130
}
@@ -139,8 +135,7 @@ sk_sp<SkSurface> GPUSurfaceGL::CreateSurface(const SkISize& size) {
139135
desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
140136
desc.fRenderTargetHandle = delegate_->GLContextFBO();
141137

142-
return SkSurface::MakeFromBackendRenderTarget(context_.get(), desc,
143-
delegate_->ColorSpace(), nullptr);
138+
return SkSurface::MakeFromBackendRenderTarget(context_.get(), desc, nullptr);
144139
}
145140

146141
sk_sp<SkSurface> GPUSurfaceGL::AcquireSurface(const SkISize& size) {

shell/gpu/gpu_surface_gl.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ class GPUSurfaceGLDelegate {
2222
virtual bool GLContextPresent() = 0;
2323

2424
virtual intptr_t GLContextFBO() const = 0;
25-
26-
// TODO: Update Mac desktop and make this pure virtual.
27-
virtual sk_sp<SkColorSpace> ColorSpace() const { return nullptr; }
2825
};
2926

3027
class GPUSurfaceGL : public Surface {

0 commit comments

Comments
 (0)