Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(493)

Unified Diff: sky/compositor/layer.cc

Issue 797063002: Make reftests work for sky. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sky/compositor/layer.cc
diff --git a/sky/compositor/layer.cc b/sky/compositor/layer.cc
index 8d2ec8bc811276c8cc19093c7707a95ef7718221..23801c77cc81e475afb5e48e8daf9d9fa9df35ca 100644
--- a/sky/compositor/layer.cc
+++ b/sky/compositor/layer.cc
@@ -7,11 +7,16 @@
#include "base/debug/trace_event.h"
#include "mojo/skia/ganesh_surface.h"
#include "sky/compositor/layer_host.h"
+#include "third_party/skia/include/core/SkBitmapDevice.h"
#include "third_party/skia/include/core/SkCanvas.h"
+#include "ui/gfx/codec/png_codec.h"
namespace sky {
-Layer::Layer(LayerClient* client) : client_(client), host_(nullptr) {
+Layer::Layer(LayerClient* client, bool is_testing)
+ : client_(client),
+ host_(nullptr),
+ is_testing_(is_testing) {
}
Layer::~Layer() {
@@ -25,6 +30,14 @@ void Layer::SetSize(const gfx::Size& size) {
size_ = size;
}
+std::string Layer::GetPixels() {
+ std::vector<unsigned char> png_data;
+ bool encoding_succeeded = gfx::PNGCodec::EncodeBGRASkBitmap(bitmap_, false, &png_data);
+ if (encoding_succeeded)
+ return std::string(reinterpret_cast<const char*>(&png_data[0]), png_data.size());
+ return std::string();
+}
+
void Layer::Display() {
TRACE_EVENT0("sky", "Layer::Display");
@@ -35,9 +48,21 @@ void Layer::Display() {
SkCanvas* canvas = surface.canvas();
- gfx::Rect rect(size_);
- client_->PaintContents(canvas, rect);
- canvas->flush();
+ if (is_testing_) {
+ bitmap_.reset();
+ bitmap_.allocN32Pixels(size_.width(), size_.height());
+ SkBitmapDevice device(bitmap_);
+ SkCanvas bitmapCanvas(&device);
+
+ gfx::Rect bitmapRect(size_);
+ bitmapCanvas.drawColor(SK_ColorRED);
ojan 2014/12/12 03:48:39 This lets us see if if we don't paint at all. Not
+ client_->PaintContents(&bitmapCanvas, bitmapRect);
+ bitmapCanvas.flush();
+ } else {
+ gfx::Rect rect(size_);
+ client_->PaintContents(canvas, rect);
+ canvas->flush();
+ }
texture_ = surface.TakeTexture();
}
« no previous file with comments | « sky/compositor/layer.h ('k') | sky/compositor/layer_host.h » ('j') | sky/tools/tester/tester.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698