mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This way we get some broad pixel test coverage. Do this by dumping the png from the flights app, uploading it to google storage and then having the reference file load the uploaded file. This isn't a good long-term solution. Long-term we should dump paint commands (or some other textual representation) and/or make more targetted reftests that don't need pngs. As such, the process for doing this is painful and manual. If we decide we want to have pixel tests properly, we'll want to do something more automated obviously. Also, turn on the discard_transparency bool when encoding the pngs. Otherwise, the png is lossy and none of this works. R=esprehn@chromium.org Review URL: https://codereview.chromium.org/836363003
40 lines
1.2 KiB
C++
40 lines
1.2 KiB
C++
// Copyright 2014 The Chromium 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 "sky/compositor/display_delegate_bitmap.h"
|
|
|
|
#include "sky/compositor/layer_client.h"
|
|
#include "third_party/skia/include/core/SkBitmapDevice.h"
|
|
#include "third_party/skia/include/core/SkCanvas.h"
|
|
#include "ui/gfx/codec/png_codec.h"
|
|
#include "ui/gfx/geometry/rect.h"
|
|
|
|
namespace sky {
|
|
|
|
DisplayDelegateBitmap::DisplayDelegateBitmap(LayerClient* client)
|
|
: client_(client) {}
|
|
|
|
DisplayDelegateBitmap::~DisplayDelegateBitmap() {}
|
|
|
|
DisplayDelegate* DisplayDelegateBitmap::create(LayerClient* client) {
|
|
return new DisplayDelegateBitmap(client);
|
|
}
|
|
|
|
void DisplayDelegateBitmap::GetPixelsForTesting(std::vector<unsigned char>* pixels) {
|
|
gfx::PNGCodec::EncodeBGRASkBitmap(bitmap_, true, pixels);
|
|
}
|
|
|
|
void DisplayDelegateBitmap::Paint(mojo::GaneshSurface& surface, const gfx::Rect& size) {
|
|
bitmap_.allocN32Pixels(size.width(), size.height());
|
|
SkBitmapDevice device(bitmap_);
|
|
SkCanvas canvas(&device);
|
|
// Draw red so we can see when we fail to paint.
|
|
canvas.drawColor(SK_ColorRED);
|
|
|
|
client_->PaintContents(&canvas, size);
|
|
canvas.flush();
|
|
}
|
|
|
|
} // namespace sky
|