mirror of
https://github.com/encounter/engine.git
synced 2026-03-30 11:09:55 -07:00
Remove dependencies on ui, third_party/mesa and mojo/convertors. Provide simple alternatives. (#2783)
This commit is contained in:
@@ -52,7 +52,6 @@ Thumbs.db
|
||||
/third_party/llvm/
|
||||
/third_party/llvm-build/
|
||||
/third_party/junit/src/
|
||||
/third_party/mesa/src/
|
||||
/third_party/mockito/src/
|
||||
/third_party/pdfium/
|
||||
/third_party/pywebsocket/src/
|
||||
|
||||
@@ -85,9 +85,6 @@ deps = {
|
||||
'src/third_party/libjpeg_turbo':
|
||||
Var('chromium_git') + '/chromium/deps/libjpeg_turbo.git' + '@' + '7260e4d8b8e1e40b17f03fafdf1cd83296900f76',
|
||||
|
||||
'src/third_party/mesa/src':
|
||||
Var('chromium_git') + '/chromium/deps/mesa.git' + '@' + '071d25db04c23821a12a8b260ab9d96a097402f0',
|
||||
|
||||
'src/third_party/gcm':
|
||||
'https://github.com/flutter/flutter_gcm.git@master',
|
||||
}
|
||||
|
||||
@@ -224,6 +224,12 @@ config("compiler") {
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_clang) {
|
||||
color_diagnostics_flag = [ "-fdiagnostics-color=always" ]
|
||||
cflags_cc += color_diagnostics_flag
|
||||
cflags_objcc += color_diagnostics_flag
|
||||
}
|
||||
|
||||
if (is_clang && is_debug) {
|
||||
# Allow comparing the address of references and 'this' against 0
|
||||
# in debug builds. Technically, these can never be null in
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
# 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.
|
||||
|
||||
# GYP version: mojo/mojo_converters.gypi:mojo_geometry_lib
|
||||
component("geometry") {
|
||||
output_name = "mojo_geometry_lib"
|
||||
|
||||
public_deps = [
|
||||
"//ui/gfx",
|
||||
]
|
||||
deps = [
|
||||
"//mojo/public/c/system",
|
||||
"//mojo/services/geometry/interfaces",
|
||||
"//skia",
|
||||
"//ui/gfx/geometry",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"geometry_type_converters.cc",
|
||||
"geometry_type_converters.h",
|
||||
]
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
// 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 "mojo/converters/geometry/geometry_type_converters.h"
|
||||
|
||||
namespace mojo {
|
||||
|
||||
// static
|
||||
PointPtr TypeConverter<PointPtr, gfx::Point>::Convert(const gfx::Point& input) {
|
||||
PointPtr point(Point::New());
|
||||
point->x = input.x();
|
||||
point->y = input.y();
|
||||
return point;
|
||||
}
|
||||
|
||||
// static
|
||||
gfx::Point TypeConverter<gfx::Point, PointPtr>::Convert(const PointPtr& input) {
|
||||
if (input.is_null())
|
||||
return gfx::Point();
|
||||
return gfx::Point(input->x, input->y);
|
||||
}
|
||||
|
||||
// static
|
||||
PointFPtr TypeConverter<PointFPtr, gfx::PointF>::Convert(
|
||||
const gfx::PointF& input) {
|
||||
PointFPtr point(PointF::New());
|
||||
point->x = input.x();
|
||||
point->y = input.y();
|
||||
return point;
|
||||
}
|
||||
|
||||
// static
|
||||
gfx::PointF TypeConverter<gfx::PointF, PointFPtr>::Convert(
|
||||
const PointFPtr& input) {
|
||||
if (input.is_null())
|
||||
return gfx::PointF();
|
||||
return gfx::PointF(input->x, input->y);
|
||||
}
|
||||
|
||||
// static
|
||||
SizePtr TypeConverter<SizePtr, gfx::Size>::Convert(const gfx::Size& input) {
|
||||
SizePtr size(Size::New());
|
||||
size->width = input.width();
|
||||
size->height = input.height();
|
||||
return size;
|
||||
}
|
||||
|
||||
// static
|
||||
gfx::Size TypeConverter<gfx::Size, SizePtr>::Convert(const SizePtr& input) {
|
||||
if (input.is_null())
|
||||
return gfx::Size();
|
||||
return gfx::Size(input->width, input->height);
|
||||
}
|
||||
|
||||
// static
|
||||
RectPtr TypeConverter<RectPtr, gfx::Rect>::Convert(const gfx::Rect& input) {
|
||||
RectPtr rect(Rect::New());
|
||||
rect->x = input.x();
|
||||
rect->y = input.y();
|
||||
rect->width = input.width();
|
||||
rect->height = input.height();
|
||||
return rect;
|
||||
}
|
||||
|
||||
// static
|
||||
gfx::Rect TypeConverter<gfx::Rect, RectPtr>::Convert(const RectPtr& input) {
|
||||
if (input.is_null())
|
||||
return gfx::Rect();
|
||||
return gfx::Rect(input->x, input->y, input->width, input->height);
|
||||
}
|
||||
|
||||
// static
|
||||
RectFPtr TypeConverter<RectFPtr, gfx::RectF>::Convert(const gfx::RectF& input) {
|
||||
RectFPtr rect(RectF::New());
|
||||
rect->x = input.x();
|
||||
rect->y = input.y();
|
||||
rect->width = input.width();
|
||||
rect->height = input.height();
|
||||
return rect;
|
||||
}
|
||||
|
||||
// static
|
||||
gfx::RectF TypeConverter<gfx::RectF, RectFPtr>::Convert(const RectFPtr& input) {
|
||||
if (input.is_null())
|
||||
return gfx::RectF();
|
||||
return gfx::RectF(input->x, input->y, input->width, input->height);
|
||||
}
|
||||
|
||||
// static
|
||||
TransformPtr TypeConverter<TransformPtr, gfx::Transform>::Convert(
|
||||
const gfx::Transform& input) {
|
||||
std::vector<float> storage(16);
|
||||
input.matrix().asRowMajorf(&storage[0]);
|
||||
mojo::Array<float> matrix;
|
||||
matrix.Swap(&storage);
|
||||
TransformPtr transform(Transform::New());
|
||||
transform->matrix = matrix.Pass();
|
||||
return transform;
|
||||
}
|
||||
|
||||
// static
|
||||
gfx::Transform TypeConverter<gfx::Transform, TransformPtr>::Convert(
|
||||
const TransformPtr& input) {
|
||||
if (input.is_null())
|
||||
return gfx::Transform();
|
||||
gfx::Transform transform(gfx::Transform::kSkipInitialization);
|
||||
transform.matrix().setRowMajorf(&input->matrix.storage()[0]);
|
||||
return transform;
|
||||
}
|
||||
|
||||
// static
|
||||
Size TypeConverter<Size, gfx::Size>::Convert(const gfx::Size& input) {
|
||||
Size size;
|
||||
size.width = input.width();
|
||||
size.height = input.height();
|
||||
return size;
|
||||
}
|
||||
|
||||
// static
|
||||
gfx::Size TypeConverter<gfx::Size, Size>::Convert(const Size& input) {
|
||||
return gfx::Size(input.width, input.height);
|
||||
}
|
||||
|
||||
// static
|
||||
Rect TypeConverter<Rect, gfx::Rect>::Convert(const gfx::Rect& input) {
|
||||
Rect rect;
|
||||
rect.x = input.x();
|
||||
rect.y = input.y();
|
||||
rect.width = input.width();
|
||||
rect.height = input.height();
|
||||
return rect;
|
||||
}
|
||||
|
||||
// static
|
||||
gfx::Rect TypeConverter<gfx::Rect, Rect>::Convert(const Rect& input) {
|
||||
return gfx::Rect(input.x, input.y, input.width, input.height);
|
||||
}
|
||||
|
||||
} // namespace mojo
|
||||
@@ -1,115 +0,0 @@
|
||||
// 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.
|
||||
|
||||
#ifndef MOJO_CONVERTERS_GEOMETRY_GEOMETRY_TYPE_CONVERTERS_H_
|
||||
#define MOJO_CONVERTERS_GEOMETRY_GEOMETRY_TYPE_CONVERTERS_H_
|
||||
|
||||
#include "mojo/services/geometry/interfaces/geometry.mojom.h"
|
||||
#include "ui/gfx/geometry/point.h"
|
||||
#include "ui/gfx/geometry/point_f.h"
|
||||
#include "ui/gfx/geometry/rect.h"
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
#include "ui/gfx/transform.h"
|
||||
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct TypeConverter<PointPtr, gfx::Point> {
|
||||
static PointPtr Convert(const gfx::Point& input);
|
||||
};
|
||||
template <>
|
||||
struct TypeConverter<gfx::Point, PointPtr> {
|
||||
static gfx::Point Convert(const PointPtr& input);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct TypeConverter<PointFPtr, gfx::PointF> {
|
||||
static PointFPtr Convert(const gfx::PointF& input);
|
||||
};
|
||||
template <>
|
||||
struct TypeConverter<gfx::PointF, PointFPtr> {
|
||||
static gfx::PointF Convert(const PointFPtr& input);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct TypeConverter<SizePtr, gfx::Size> {
|
||||
static SizePtr Convert(const gfx::Size& input);
|
||||
};
|
||||
template <>
|
||||
struct TypeConverter<gfx::Size, SizePtr> {
|
||||
static gfx::Size Convert(const SizePtr& input);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct TypeConverter<RectPtr, gfx::Rect> {
|
||||
static RectPtr Convert(const gfx::Rect& input);
|
||||
};
|
||||
template <>
|
||||
struct TypeConverter<gfx::Rect, RectPtr> {
|
||||
static gfx::Rect Convert(const RectPtr& input);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct TypeConverter<RectFPtr, gfx::RectF> {
|
||||
static RectFPtr Convert(const gfx::RectF& input);
|
||||
};
|
||||
template <>
|
||||
struct TypeConverter<gfx::RectF, RectFPtr> {
|
||||
static gfx::RectF Convert(const RectFPtr& input);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct TypeConverter<TransformPtr, gfx::Transform> {
|
||||
static TransformPtr Convert(const gfx::Transform& input);
|
||||
};
|
||||
template <>
|
||||
struct TypeConverter<gfx::Transform, TransformPtr> {
|
||||
static gfx::Transform Convert(const TransformPtr& input);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct TypeConverter<Size, gfx::Size> {
|
||||
static Size Convert(const gfx::Size& input);
|
||||
};
|
||||
template <>
|
||||
struct TypeConverter<gfx::Size, Size> {
|
||||
static gfx::Size Convert(const Size& input);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct TypeConverter<Rect, gfx::Rect> {
|
||||
static Rect Convert(const gfx::Rect& input);
|
||||
};
|
||||
template <>
|
||||
struct TypeConverter<gfx::Rect, Rect> {
|
||||
static gfx::Rect Convert(const Rect& input);
|
||||
};
|
||||
|
||||
} // namespace mojo
|
||||
|
||||
inline bool operator==(const mojo::Size& lhs, const mojo::Size& rhs) {
|
||||
return lhs.width == rhs.width && lhs.height == rhs.height;
|
||||
}
|
||||
|
||||
inline bool operator==(const gfx::Size& lhs, const mojo::Size& rhs) {
|
||||
return lhs.width() == rhs.width && lhs.height() == rhs.height;
|
||||
}
|
||||
|
||||
inline bool operator==(const mojo::Size& lhs, const gfx::Size& rhs) {
|
||||
return rhs == lhs;
|
||||
}
|
||||
|
||||
inline bool operator!=(const mojo::Size& lhs, const mojo::Size& rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
inline bool operator!=(const gfx::Size& lhs, const mojo::Size& rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
inline bool operator!=(const mojo::Size& lhs, const gfx::Size& rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
#endif // MOJO_CONVERTERS_GEOMETRY_GEOMETRY_TYPE_CONVERTERS_H_
|
||||
@@ -1,28 +0,0 @@
|
||||
# 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.
|
||||
|
||||
component("surfaces") {
|
||||
output_name = "mojo_surfaces_lib"
|
||||
|
||||
sources = [
|
||||
"surfaces_type_converters.cc",
|
||||
"surfaces_type_converters.h",
|
||||
]
|
||||
|
||||
public_deps = [
|
||||
"//mojo/converters/geometry",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//base",
|
||||
"//cc",
|
||||
"//cc/surfaces",
|
||||
"//cc/surfaces:surface_id",
|
||||
"//gpu",
|
||||
"//mojo/environment:chromium",
|
||||
"//mojo/public/c/system",
|
||||
"//mojo/services/surfaces/interfaces",
|
||||
"//mojo/services/surfaces/interfaces:surface_id",
|
||||
]
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,147 +0,0 @@
|
||||
// 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.
|
||||
|
||||
#ifndef MOJO_CONVERTERS_SURFACES_SURFACES_TYPE_CONVERTERS_H_
|
||||
#define MOJO_CONVERTERS_SURFACES_SURFACES_TYPE_CONVERTERS_H_
|
||||
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "cc/resources/returned_resource.h"
|
||||
#include "cc/resources/transferable_resource.h"
|
||||
#include "cc/surfaces/surface_id.h"
|
||||
#include "gpu/command_buffer/common/mailbox.h"
|
||||
#include "gpu/command_buffer/common/mailbox_holder.h"
|
||||
#include "mojo/services/surfaces/interfaces/quads.mojom.h"
|
||||
#include "mojo/services/surfaces/interfaces/surface_id.mojom.h"
|
||||
#include "mojo/services/surfaces/interfaces/surfaces.mojom.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
|
||||
namespace cc {
|
||||
class CompositorFrame;
|
||||
class DrawQuad;
|
||||
class RenderPass;
|
||||
class RenderPassId;
|
||||
class SharedQuadState;
|
||||
} // namespace cc
|
||||
|
||||
namespace mojo {
|
||||
|
||||
// Types from surface_id.mojom
|
||||
template <>
|
||||
struct TypeConverter<SurfaceIdPtr, cc::SurfaceId> {
|
||||
static SurfaceIdPtr Convert(const cc::SurfaceId& input);
|
||||
};
|
||||
template <>
|
||||
struct TypeConverter<cc::SurfaceId, SurfaceIdPtr> {
|
||||
static cc::SurfaceId Convert(const SurfaceIdPtr& input);
|
||||
};
|
||||
|
||||
// Types from quads.mojom
|
||||
template <>
|
||||
struct TypeConverter<ColorPtr, SkColor> {
|
||||
static ColorPtr Convert(const SkColor& input);
|
||||
};
|
||||
template <>
|
||||
struct TypeConverter<SkColor, ColorPtr> {
|
||||
static SkColor Convert(const ColorPtr& input);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct TypeConverter<RenderPassIdPtr, cc::RenderPassId> {
|
||||
static RenderPassIdPtr Convert(const cc::RenderPassId& input);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct TypeConverter<cc::RenderPassId, RenderPassIdPtr> {
|
||||
static cc::RenderPassId Convert(const RenderPassIdPtr& input);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct TypeConverter<QuadPtr, cc::DrawQuad> {
|
||||
static QuadPtr Convert(const cc::DrawQuad& input);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct TypeConverter<SharedQuadStatePtr, cc::SharedQuadState> {
|
||||
static SharedQuadStatePtr Convert(const cc::SharedQuadState& input);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct TypeConverter<PassPtr, cc::RenderPass> {
|
||||
static PassPtr Convert(const cc::RenderPass& input);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct TypeConverter<scoped_ptr<cc::RenderPass>, PassPtr> {
|
||||
static scoped_ptr<cc::RenderPass> Convert(const PassPtr& input);
|
||||
};
|
||||
|
||||
// Types from surfaces.mojom
|
||||
template <>
|
||||
struct TypeConverter<MailboxPtr, gpu::Mailbox> {
|
||||
static MailboxPtr Convert(const gpu::Mailbox& input);
|
||||
};
|
||||
template <>
|
||||
struct TypeConverter<gpu::Mailbox, MailboxPtr> {
|
||||
static gpu::Mailbox Convert(const MailboxPtr& input);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct TypeConverter<MailboxHolderPtr, gpu::MailboxHolder> {
|
||||
static MailboxHolderPtr Convert(const gpu::MailboxHolder& input);
|
||||
};
|
||||
template <>
|
||||
struct TypeConverter<gpu::MailboxHolder, MailboxHolderPtr> {
|
||||
static gpu::MailboxHolder Convert(const MailboxHolderPtr& input);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct TypeConverter<TransferableResourcePtr, cc::TransferableResource> {
|
||||
static TransferableResourcePtr Convert(const cc::TransferableResource& input);
|
||||
};
|
||||
template <>
|
||||
struct TypeConverter<cc::TransferableResource, TransferableResourcePtr> {
|
||||
static cc::TransferableResource Convert(const TransferableResourcePtr& input);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct TypeConverter<Array<TransferableResourcePtr>,
|
||||
cc::TransferableResourceArray> {
|
||||
static Array<TransferableResourcePtr> Convert(
|
||||
const cc::TransferableResourceArray& input);
|
||||
};
|
||||
template <>
|
||||
struct TypeConverter<cc::TransferableResourceArray,
|
||||
Array<TransferableResourcePtr>> {
|
||||
static cc::TransferableResourceArray Convert(
|
||||
const Array<TransferableResourcePtr>& input);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct TypeConverter<ReturnedResourcePtr, cc::ReturnedResource> {
|
||||
static ReturnedResourcePtr Convert(const cc::ReturnedResource& input);
|
||||
};
|
||||
template <>
|
||||
struct TypeConverter<cc::ReturnedResource, ReturnedResourcePtr> {
|
||||
static cc::ReturnedResource Convert(const ReturnedResourcePtr& input);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct TypeConverter<Array<ReturnedResourcePtr>, cc::ReturnedResourceArray> {
|
||||
static Array<ReturnedResourcePtr> Convert(
|
||||
const cc::ReturnedResourceArray& input);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct TypeConverter<FramePtr, cc::CompositorFrame> {
|
||||
static FramePtr Convert(const cc::CompositorFrame& input);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct TypeConverter<scoped_ptr<cc::CompositorFrame>, FramePtr> {
|
||||
static scoped_ptr<cc::CompositorFrame> Convert(const FramePtr& input);
|
||||
};
|
||||
|
||||
} // namespace mojo
|
||||
|
||||
#endif // MOJO_CONVERTERS_SURFACES_SURFACES_TYPE_CONVERTERS_H_
|
||||
@@ -1,30 +0,0 @@
|
||||
# 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.
|
||||
|
||||
import("//testing/test.gni")
|
||||
|
||||
test("mojo_surfaces_lib_unittests") {
|
||||
deps = [
|
||||
"//base",
|
||||
"//base/test:test_support",
|
||||
"//cc",
|
||||
"//cc/surfaces",
|
||||
"//gpu",
|
||||
"//mojo/converters/geometry",
|
||||
"//mojo/converters/surfaces",
|
||||
"//mojo/edk/test:run_all_unittests",
|
||||
"//mojo/environment:chromium",
|
||||
"//mojo/services/geometry/interfaces",
|
||||
"//mojo/services/surfaces/interfaces",
|
||||
"//skia",
|
||||
"//testing/gtest",
|
||||
"//ui/gfx",
|
||||
"//ui/gfx/geometry",
|
||||
"//ui/gfx:test_support",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"surface_unittest.cc",
|
||||
]
|
||||
}
|
||||
@@ -1,464 +0,0 @@
|
||||
// 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 "cc/quads/render_pass.h"
|
||||
#include "cc/quads/solid_color_draw_quad.h"
|
||||
#include "cc/quads/surface_draw_quad.h"
|
||||
#include "cc/quads/texture_draw_quad.h"
|
||||
#include "gpu/command_buffer/common/mailbox.h"
|
||||
#include "gpu/command_buffer/common/mailbox_holder.h"
|
||||
#include "mojo/converters/geometry/geometry_type_converters.h"
|
||||
#include "mojo/converters/surfaces/surfaces_type_converters.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
#include "third_party/skia/include/core/SkXfermode.h"
|
||||
|
||||
namespace mojo {
|
||||
namespace {
|
||||
|
||||
TEST(SurfaceLibTest, SurfaceIdConverterNullId) {
|
||||
cc::SurfaceId null_id;
|
||||
cc::SurfaceId round_trip = SurfaceId::From(null_id).To<cc::SurfaceId>();
|
||||
EXPECT_TRUE(round_trip.is_null());
|
||||
}
|
||||
|
||||
TEST(SurfaceLibTest, SurfaceIdConverterValidId) {
|
||||
cc::SurfaceId valid_id(7);
|
||||
cc::SurfaceId round_trip = SurfaceId::From(valid_id).To<cc::SurfaceId>();
|
||||
EXPECT_FALSE(round_trip.is_null());
|
||||
EXPECT_EQ(valid_id, round_trip);
|
||||
}
|
||||
|
||||
TEST(SurfaceLibTest, Color) {
|
||||
SkColor arbitrary_color = SK_ColorMAGENTA;
|
||||
SkColor round_trip = Color::From(arbitrary_color).To<SkColor>();
|
||||
EXPECT_EQ(arbitrary_color, round_trip);
|
||||
}
|
||||
|
||||
class SurfaceLibQuadTest : public testing::Test {
|
||||
public:
|
||||
SurfaceLibQuadTest()
|
||||
: rect(5, 7, 13, 19),
|
||||
opaque_rect(rect),
|
||||
visible_rect(9, 11, 5, 7),
|
||||
needs_blending(false) {
|
||||
pass = cc::RenderPass::Create();
|
||||
sqs = pass->CreateAndAppendSharedQuadState();
|
||||
}
|
||||
|
||||
protected:
|
||||
gfx::Rect rect;
|
||||
gfx::Rect opaque_rect;
|
||||
gfx::Rect visible_rect;
|
||||
bool needs_blending;
|
||||
scoped_ptr<cc::RenderPass> pass;
|
||||
cc::SharedQuadState* sqs;
|
||||
};
|
||||
|
||||
TEST_F(SurfaceLibQuadTest, ColorQuad) {
|
||||
cc::SolidColorDrawQuad* color_quad =
|
||||
pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>();
|
||||
SkColor arbitrary_color = SK_ColorGREEN;
|
||||
bool force_anti_aliasing_off = true;
|
||||
color_quad->SetAll(sqs,
|
||||
rect,
|
||||
opaque_rect,
|
||||
visible_rect,
|
||||
needs_blending,
|
||||
arbitrary_color,
|
||||
force_anti_aliasing_off);
|
||||
|
||||
QuadPtr mojo_quad = Quad::From<cc::DrawQuad>(*color_quad);
|
||||
ASSERT_FALSE(mojo_quad.is_null());
|
||||
EXPECT_EQ(Material::SOLID_COLOR, mojo_quad->material);
|
||||
EXPECT_EQ(Rect::From(rect), mojo_quad->rect);
|
||||
EXPECT_EQ(Rect::From(opaque_rect), mojo_quad->opaque_rect);
|
||||
EXPECT_EQ(Rect::From(visible_rect), mojo_quad->visible_rect);
|
||||
EXPECT_EQ(needs_blending, mojo_quad->needs_blending);
|
||||
ASSERT_TRUE(mojo_quad->solid_color_quad_state);
|
||||
SolidColorQuadStatePtr& mojo_color_state = mojo_quad->solid_color_quad_state;
|
||||
EXPECT_EQ(Color::From(arbitrary_color), mojo_color_state->color);
|
||||
EXPECT_EQ(force_anti_aliasing_off, mojo_color_state->force_anti_aliasing_off);
|
||||
}
|
||||
|
||||
TEST_F(SurfaceLibQuadTest, SurfaceQuad) {
|
||||
cc::SurfaceDrawQuad* surface_quad =
|
||||
pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>();
|
||||
cc::SurfaceId arbitrary_id(5);
|
||||
surface_quad->SetAll(
|
||||
sqs, rect, opaque_rect, visible_rect, needs_blending, arbitrary_id);
|
||||
|
||||
QuadPtr mojo_quad = Quad::From<cc::DrawQuad>(*surface_quad);
|
||||
ASSERT_FALSE(mojo_quad.is_null());
|
||||
EXPECT_EQ(Material::SURFACE_CONTENT, mojo_quad->material);
|
||||
ASSERT_TRUE(mojo_quad->surface_quad_state);
|
||||
SurfaceQuadStatePtr& mojo_surface_state = mojo_quad->surface_quad_state;
|
||||
EXPECT_EQ(SurfaceId::From(arbitrary_id),
|
||||
mojo_surface_state->surface);
|
||||
}
|
||||
|
||||
TEST_F(SurfaceLibQuadTest, TextureQuad) {
|
||||
cc::TextureDrawQuad* texture_quad =
|
||||
pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>();
|
||||
unsigned resource_id = 9;
|
||||
bool premultiplied_alpha = true;
|
||||
gfx::PointF uv_top_left(1.7f, 2.1f);
|
||||
gfx::PointF uv_bottom_right(-7.f, 16.3f);
|
||||
SkColor background_color = SK_ColorYELLOW;
|
||||
float vertex_opacity[4] = {0.1f, 0.5f, 0.4f, 0.8f};
|
||||
bool flipped = false;
|
||||
bool nearest_neighbor = false;
|
||||
texture_quad->SetAll(sqs,
|
||||
rect,
|
||||
opaque_rect,
|
||||
visible_rect,
|
||||
needs_blending,
|
||||
resource_id,
|
||||
premultiplied_alpha,
|
||||
uv_top_left,
|
||||
uv_bottom_right,
|
||||
background_color,
|
||||
vertex_opacity,
|
||||
flipped,
|
||||
nearest_neighbor);
|
||||
|
||||
QuadPtr mojo_quad = Quad::From<cc::DrawQuad>(*texture_quad);
|
||||
ASSERT_FALSE(mojo_quad.is_null());
|
||||
EXPECT_EQ(Material::TEXTURE_CONTENT, mojo_quad->material);
|
||||
ASSERT_TRUE(mojo_quad->texture_quad_state);
|
||||
TextureQuadStatePtr& mojo_texture_state = mojo_quad->texture_quad_state;
|
||||
EXPECT_EQ(resource_id, mojo_texture_state->resource_id);
|
||||
EXPECT_EQ(premultiplied_alpha, mojo_texture_state->premultiplied_alpha);
|
||||
EXPECT_EQ(PointF::From(uv_top_left), mojo_texture_state->uv_top_left);
|
||||
EXPECT_EQ(PointF::From(uv_bottom_right), mojo_texture_state->uv_bottom_right);
|
||||
EXPECT_EQ(Color::From(background_color),
|
||||
mojo_texture_state->background_color);
|
||||
for (size_t i = 0; i < 4; ++i) {
|
||||
EXPECT_EQ(vertex_opacity[i], mojo_texture_state->vertex_opacity[i]) << i;
|
||||
}
|
||||
EXPECT_EQ(flipped, mojo_texture_state->flipped);
|
||||
}
|
||||
|
||||
TEST_F(SurfaceLibQuadTest, TextureQuadEmptyVertexOpacity) {
|
||||
QuadPtr mojo_texture_quad = Quad::New();
|
||||
mojo_texture_quad->material = Material::TEXTURE_CONTENT;
|
||||
TextureQuadStatePtr mojo_texture_state = TextureQuadState::New();
|
||||
mojo_texture_state->background_color = Color::New();
|
||||
mojo_texture_quad->texture_quad_state = mojo_texture_state.Pass();
|
||||
PassPtr mojo_pass = Pass::New();
|
||||
mojo_pass->quads.push_back(mojo_texture_quad.Pass());
|
||||
SharedQuadStatePtr mojo_sqs = SharedQuadState::New();
|
||||
mojo_pass->shared_quad_states.push_back(mojo_sqs.Pass());
|
||||
|
||||
scoped_ptr<cc::RenderPass> pass = mojo_pass.To<scoped_ptr<cc::RenderPass> >();
|
||||
|
||||
EXPECT_FALSE(pass);
|
||||
}
|
||||
|
||||
TEST_F(SurfaceLibQuadTest, TextureQuadEmptyBackgroundColor) {
|
||||
QuadPtr mojo_texture_quad = Quad::New();
|
||||
mojo_texture_quad->material = Material::TEXTURE_CONTENT;
|
||||
TextureQuadStatePtr mojo_texture_state = TextureQuadState::New();
|
||||
mojo_texture_state->vertex_opacity = mojo::Array<float>::New(4);
|
||||
mojo_texture_quad->texture_quad_state = mojo_texture_state.Pass();
|
||||
PassPtr mojo_pass = Pass::New();
|
||||
mojo_pass->quads.push_back(mojo_texture_quad.Pass());
|
||||
SharedQuadStatePtr mojo_sqs = SharedQuadState::New();
|
||||
mojo_pass->shared_quad_states.push_back(mojo_sqs.Pass());
|
||||
|
||||
scoped_ptr<cc::RenderPass> pass = mojo_pass.To<scoped_ptr<cc::RenderPass> >();
|
||||
EXPECT_FALSE(pass);
|
||||
}
|
||||
|
||||
TEST(SurfaceLibTest, SharedQuadState) {
|
||||
gfx::Transform content_to_target_transform;
|
||||
content_to_target_transform.Scale3d(0.3f, 0.7f, 0.9f);
|
||||
gfx::Size content_bounds(57, 39);
|
||||
gfx::Rect visible_content_rect(3, 7, 28, 42);
|
||||
gfx::Rect clip_rect(9, 12, 21, 31);
|
||||
bool is_clipped = true;
|
||||
float opacity = 0.65f;
|
||||
int sorting_context_id = 13;
|
||||
::SkXfermode::Mode blend_mode = ::SkXfermode::kSrcOver_Mode;
|
||||
scoped_ptr<cc::RenderPass> pass = cc::RenderPass::Create();
|
||||
cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
|
||||
sqs->SetAll(content_to_target_transform,
|
||||
content_bounds,
|
||||
visible_content_rect,
|
||||
clip_rect,
|
||||
is_clipped,
|
||||
opacity,
|
||||
blend_mode,
|
||||
sorting_context_id);
|
||||
|
||||
SharedQuadStatePtr mojo_sqs = SharedQuadState::From(*sqs);
|
||||
ASSERT_FALSE(mojo_sqs.is_null());
|
||||
EXPECT_EQ(Transform::From(content_to_target_transform),
|
||||
mojo_sqs->content_to_target_transform);
|
||||
EXPECT_EQ(Size::From(content_bounds), mojo_sqs->content_bounds);
|
||||
EXPECT_EQ(Rect::From(visible_content_rect), mojo_sqs->visible_content_rect);
|
||||
EXPECT_EQ(Rect::From(clip_rect), mojo_sqs->clip_rect);
|
||||
EXPECT_EQ(is_clipped, mojo_sqs->is_clipped);
|
||||
EXPECT_EQ(opacity, mojo_sqs->opacity);
|
||||
EXPECT_EQ(sorting_context_id, mojo_sqs->sorting_context_id);
|
||||
}
|
||||
|
||||
TEST(SurfaceLibTest, RenderPass) {
|
||||
scoped_ptr<cc::RenderPass> pass = cc::RenderPass::Create();
|
||||
cc::RenderPassId pass_id(1, 6);
|
||||
gfx::Rect output_rect(4, 9, 13, 71);
|
||||
gfx::Rect damage_rect(9, 17, 41, 45);
|
||||
gfx::Transform transform_to_root_target;
|
||||
transform_to_root_target.SkewY(43.0);
|
||||
bool has_transparent_background = false;
|
||||
pass->SetAll(pass_id,
|
||||
output_rect,
|
||||
damage_rect,
|
||||
transform_to_root_target,
|
||||
has_transparent_background);
|
||||
|
||||
gfx::Transform content_to_target_transform;
|
||||
content_to_target_transform.Scale3d(0.3f, 0.7f, 0.9f);
|
||||
gfx::Size content_bounds(57, 39);
|
||||
gfx::Rect visible_content_rect(3, 7, 28, 42);
|
||||
gfx::Rect clip_rect(9, 12, 21, 31);
|
||||
bool is_clipped = true;
|
||||
float opacity = 0.65f;
|
||||
int sorting_context_id = 13;
|
||||
::SkXfermode::Mode blend_mode = ::SkXfermode::kSrcOver_Mode;
|
||||
cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
|
||||
sqs->SetAll(content_to_target_transform,
|
||||
content_bounds,
|
||||
visible_content_rect,
|
||||
clip_rect,
|
||||
is_clipped,
|
||||
opacity,
|
||||
blend_mode,
|
||||
sorting_context_id);
|
||||
|
||||
gfx::Rect rect(5, 7, 13, 19);
|
||||
gfx::Rect opaque_rect(rect);
|
||||
gfx::Rect visible_rect(9, 11, 5, 7);
|
||||
bool needs_blending = false;
|
||||
|
||||
cc::SolidColorDrawQuad* color_quad =
|
||||
pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>();
|
||||
SkColor arbitrary_color = SK_ColorGREEN;
|
||||
bool force_anti_aliasing_off = true;
|
||||
color_quad->SetAll(pass->shared_quad_state_list.back(),
|
||||
rect,
|
||||
opaque_rect,
|
||||
visible_rect,
|
||||
needs_blending,
|
||||
arbitrary_color,
|
||||
force_anti_aliasing_off);
|
||||
|
||||
cc::SurfaceDrawQuad* surface_quad =
|
||||
pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>();
|
||||
cc::SurfaceId arbitrary_id(5);
|
||||
surface_quad->SetAll(
|
||||
sqs, rect, opaque_rect, visible_rect, needs_blending, arbitrary_id);
|
||||
|
||||
cc::TextureDrawQuad* texture_quad =
|
||||
pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>();
|
||||
unsigned resource_id = 9;
|
||||
bool premultiplied_alpha = true;
|
||||
gfx::PointF uv_top_left(1.7f, 2.1f);
|
||||
gfx::PointF uv_bottom_right(-7.f, 16.3f);
|
||||
SkColor background_color = SK_ColorYELLOW;
|
||||
float vertex_opacity[4] = {0.1f, 0.5f, 0.4f, 0.8f};
|
||||
bool flipped = false;
|
||||
bool nearest_neighbor = false;
|
||||
texture_quad->SetAll(sqs,
|
||||
rect,
|
||||
opaque_rect,
|
||||
visible_rect,
|
||||
needs_blending,
|
||||
resource_id,
|
||||
premultiplied_alpha,
|
||||
uv_top_left,
|
||||
uv_bottom_right,
|
||||
background_color,
|
||||
vertex_opacity,
|
||||
flipped,
|
||||
nearest_neighbor);
|
||||
|
||||
PassPtr mojo_pass = Pass::From(*pass);
|
||||
ASSERT_FALSE(mojo_pass.is_null());
|
||||
EXPECT_EQ(6, mojo_pass->id);
|
||||
EXPECT_EQ(Rect::From(output_rect), mojo_pass->output_rect);
|
||||
EXPECT_EQ(Rect::From(damage_rect), mojo_pass->damage_rect);
|
||||
EXPECT_EQ(Transform::From(transform_to_root_target),
|
||||
mojo_pass->transform_to_root_target);
|
||||
EXPECT_EQ(has_transparent_background, mojo_pass->has_transparent_background);
|
||||
ASSERT_EQ(1u, mojo_pass->shared_quad_states.size());
|
||||
ASSERT_EQ(3u, mojo_pass->quads.size());
|
||||
EXPECT_EQ(0u, mojo_pass->quads[0]->shared_quad_state_index);
|
||||
|
||||
scoped_ptr<cc::RenderPass> round_trip_pass =
|
||||
mojo_pass.To<scoped_ptr<cc::RenderPass> >();
|
||||
EXPECT_EQ(pass_id, round_trip_pass->id);
|
||||
EXPECT_EQ(output_rect, round_trip_pass->output_rect);
|
||||
EXPECT_EQ(damage_rect, round_trip_pass->damage_rect);
|
||||
EXPECT_EQ(transform_to_root_target,
|
||||
round_trip_pass->transform_to_root_target);
|
||||
EXPECT_EQ(has_transparent_background,
|
||||
round_trip_pass->has_transparent_background);
|
||||
ASSERT_EQ(1u, round_trip_pass->shared_quad_state_list.size());
|
||||
ASSERT_EQ(3u, round_trip_pass->quad_list.size());
|
||||
EXPECT_EQ(round_trip_pass->shared_quad_state_list.front(),
|
||||
round_trip_pass->quad_list.front()->shared_quad_state);
|
||||
|
||||
cc::SharedQuadState* round_trip_sqs =
|
||||
round_trip_pass->shared_quad_state_list.front();
|
||||
EXPECT_EQ(content_to_target_transform,
|
||||
round_trip_sqs->content_to_target_transform);
|
||||
EXPECT_EQ(content_bounds, round_trip_sqs->content_bounds);
|
||||
EXPECT_EQ(visible_content_rect, round_trip_sqs->visible_content_rect);
|
||||
EXPECT_EQ(clip_rect, round_trip_sqs->clip_rect);
|
||||
EXPECT_EQ(is_clipped, round_trip_sqs->is_clipped);
|
||||
EXPECT_EQ(opacity, round_trip_sqs->opacity);
|
||||
EXPECT_EQ(sorting_context_id, round_trip_sqs->sorting_context_id);
|
||||
|
||||
cc::DrawQuad* round_trip_quad = round_trip_pass->quad_list.front();
|
||||
// First is solid color quad.
|
||||
ASSERT_EQ(cc::DrawQuad::SOLID_COLOR, round_trip_quad->material);
|
||||
EXPECT_EQ(rect, round_trip_quad->rect);
|
||||
EXPECT_EQ(opaque_rect, round_trip_quad->opaque_rect);
|
||||
EXPECT_EQ(visible_rect, round_trip_quad->visible_rect);
|
||||
EXPECT_EQ(needs_blending, round_trip_quad->needs_blending);
|
||||
const cc::SolidColorDrawQuad* round_trip_color_quad =
|
||||
cc::SolidColorDrawQuad::MaterialCast(round_trip_quad);
|
||||
EXPECT_EQ(arbitrary_color, round_trip_color_quad->color);
|
||||
EXPECT_EQ(force_anti_aliasing_off,
|
||||
round_trip_color_quad->force_anti_aliasing_off);
|
||||
|
||||
round_trip_quad = round_trip_pass->quad_list.ElementAt(1);
|
||||
// Second is surface quad.
|
||||
ASSERT_EQ(cc::DrawQuad::SURFACE_CONTENT, round_trip_quad->material);
|
||||
const cc::SurfaceDrawQuad* round_trip_surface_quad =
|
||||
cc::SurfaceDrawQuad::MaterialCast(round_trip_quad);
|
||||
EXPECT_EQ(arbitrary_id, round_trip_surface_quad->surface_id);
|
||||
|
||||
round_trip_quad = round_trip_pass->quad_list.ElementAt(2);
|
||||
// Third is texture quad.
|
||||
ASSERT_EQ(cc::DrawQuad::TEXTURE_CONTENT, round_trip_quad->material);
|
||||
const cc::TextureDrawQuad* round_trip_texture_quad =
|
||||
cc::TextureDrawQuad::MaterialCast(round_trip_quad);
|
||||
EXPECT_EQ(resource_id, round_trip_texture_quad->resource_id);
|
||||
EXPECT_EQ(premultiplied_alpha, round_trip_texture_quad->premultiplied_alpha);
|
||||
EXPECT_EQ(uv_top_left, round_trip_texture_quad->uv_top_left);
|
||||
EXPECT_EQ(uv_bottom_right, round_trip_texture_quad->uv_bottom_right);
|
||||
EXPECT_EQ(background_color, round_trip_texture_quad->background_color);
|
||||
for (size_t i = 0; i < 4; ++i) {
|
||||
EXPECT_EQ(vertex_opacity[i], round_trip_texture_quad->vertex_opacity[i])
|
||||
<< i;
|
||||
}
|
||||
EXPECT_EQ(flipped, round_trip_texture_quad->flipped);
|
||||
}
|
||||
|
||||
TEST(SurfaceLibTest, Mailbox) {
|
||||
gpu::Mailbox mailbox;
|
||||
mailbox.Generate();
|
||||
|
||||
MailboxPtr mojo_mailbox = Mailbox::From(mailbox);
|
||||
EXPECT_EQ(0, memcmp(mailbox.name, &mojo_mailbox->name.storage()[0], 64));
|
||||
|
||||
gpu::Mailbox round_trip_mailbox = mojo_mailbox.To<gpu::Mailbox>();
|
||||
EXPECT_EQ(mailbox, round_trip_mailbox);
|
||||
}
|
||||
|
||||
TEST(SurfaceLibTest, MailboxEmptyName) {
|
||||
MailboxPtr mojo_mailbox = Mailbox::New();
|
||||
|
||||
gpu::Mailbox converted_mailbox = mojo_mailbox.To<gpu::Mailbox>();
|
||||
EXPECT_TRUE(converted_mailbox.IsZero());
|
||||
}
|
||||
|
||||
TEST(SurfaceLibTest, MailboxHolder) {
|
||||
gpu::Mailbox mailbox;
|
||||
mailbox.Generate();
|
||||
uint32_t texture_target = GL_TEXTURE_2D;
|
||||
uint32_t sync_point = 7u;
|
||||
gpu::MailboxHolder holder(mailbox, texture_target, sync_point);
|
||||
|
||||
MailboxHolderPtr mojo_holder = MailboxHolder::From(holder);
|
||||
EXPECT_EQ(texture_target, mojo_holder->texture_target);
|
||||
EXPECT_EQ(sync_point, mojo_holder->sync_point);
|
||||
|
||||
gpu::MailboxHolder round_trip_holder = mojo_holder.To<gpu::MailboxHolder>();
|
||||
EXPECT_EQ(mailbox, round_trip_holder.mailbox);
|
||||
EXPECT_EQ(texture_target, round_trip_holder.texture_target);
|
||||
EXPECT_EQ(sync_point, round_trip_holder.sync_point);
|
||||
}
|
||||
|
||||
TEST(SurfaceLibTest, TransferableResource) {
|
||||
uint32_t id = 7u;
|
||||
cc::ResourceFormat format = cc::BGRA_8888;
|
||||
uint32_t filter = 123u;
|
||||
gfx::Size size(17, 18);
|
||||
gpu::MailboxHolder mailbox_holder;
|
||||
bool is_repeated = false;
|
||||
;
|
||||
bool is_software = false;
|
||||
cc::TransferableResource resource;
|
||||
resource.id = id;
|
||||
resource.format = format;
|
||||
resource.filter = filter;
|
||||
resource.size = size;
|
||||
resource.mailbox_holder = mailbox_holder;
|
||||
resource.is_repeated = is_repeated;
|
||||
resource.is_software = is_software;
|
||||
|
||||
TransferableResourcePtr mojo_resource = TransferableResource::From(resource);
|
||||
EXPECT_EQ(id, mojo_resource->id);
|
||||
EXPECT_EQ(static_cast<ResourceFormat>(format),
|
||||
mojo_resource->format);
|
||||
EXPECT_EQ(filter, mojo_resource->filter);
|
||||
EXPECT_EQ(Size::From(size), mojo_resource->size);
|
||||
EXPECT_EQ(is_repeated, mojo_resource->is_repeated);
|
||||
EXPECT_EQ(is_software, mojo_resource->is_software);
|
||||
|
||||
cc::TransferableResource round_trip_resource =
|
||||
mojo_resource.To<cc::TransferableResource>();
|
||||
EXPECT_EQ(id, round_trip_resource.id);
|
||||
EXPECT_EQ(format, round_trip_resource.format);
|
||||
EXPECT_EQ(filter, round_trip_resource.filter);
|
||||
EXPECT_EQ(size, round_trip_resource.size);
|
||||
EXPECT_EQ(mailbox_holder.mailbox, round_trip_resource.mailbox_holder.mailbox);
|
||||
EXPECT_EQ(mailbox_holder.texture_target,
|
||||
round_trip_resource.mailbox_holder.texture_target);
|
||||
EXPECT_EQ(mailbox_holder.sync_point,
|
||||
round_trip_resource.mailbox_holder.sync_point);
|
||||
EXPECT_EQ(is_repeated, round_trip_resource.is_repeated);
|
||||
EXPECT_EQ(is_software, round_trip_resource.is_software);
|
||||
}
|
||||
|
||||
TEST(SurfaceLibTest, ReturnedResource) {
|
||||
uint32_t id = 5u;
|
||||
uint32_t sync_point = 24u;
|
||||
int count = 2;
|
||||
bool lost = false;
|
||||
cc::ReturnedResource resource;
|
||||
resource.id = id;
|
||||
resource.sync_point = sync_point;
|
||||
resource.count = count;
|
||||
resource.lost = lost;
|
||||
|
||||
ReturnedResourcePtr mojo_resource = ReturnedResource::From(resource);
|
||||
EXPECT_EQ(id, mojo_resource->id);
|
||||
EXPECT_EQ(sync_point, mojo_resource->sync_point);
|
||||
EXPECT_EQ(count, mojo_resource->count);
|
||||
EXPECT_EQ(lost, mojo_resource->lost);
|
||||
|
||||
cc::ReturnedResource round_trip_resource =
|
||||
mojo_resource.To<cc::ReturnedResource>();
|
||||
EXPECT_EQ(id, round_trip_resource.id);
|
||||
EXPECT_EQ(sync_point, round_trip_resource.sync_point);
|
||||
EXPECT_EQ(count, round_trip_resource.count);
|
||||
EXPECT_EQ(lost, round_trip_resource.lost);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace mojo
|
||||
@@ -32,10 +32,6 @@ group("sky") {
|
||||
deps += [ "//sky/services/activity" ]
|
||||
}
|
||||
|
||||
if (!is_android) {
|
||||
deps += [ "//third_party/mesa:osmesa" ]
|
||||
}
|
||||
|
||||
# TODO(mpcomplete): This is temporary until we move GCM and Firebase
|
||||
# out of the engine repo.
|
||||
if (enable_firebase) {
|
||||
|
||||
+9
-15
@@ -16,6 +16,7 @@ dart_embedder_resources("generate_sky_embedder_diagnostic_server_resources_cc")
|
||||
|
||||
source_set("common") {
|
||||
sources = [
|
||||
"$target_gen_dir/sky_embedder_diagnostic_server_resources.cc",
|
||||
"diagnostic/diagnostic_server.cc",
|
||||
"diagnostic/diagnostic_server.h",
|
||||
"gpu/picture_serializer.cc",
|
||||
@@ -42,7 +43,6 @@ source_set("common") {
|
||||
"ui/platform_impl.h",
|
||||
"ui_delegate.cc",
|
||||
"ui_delegate.h",
|
||||
"$target_gen_dir/sky_embedder_diagnostic_server_resources.cc",
|
||||
]
|
||||
|
||||
public_deps = [
|
||||
@@ -75,22 +75,18 @@ source_set("common") {
|
||||
"//sky/services/rasterizer:interfaces",
|
||||
"//sky/services/semantics:interfaces",
|
||||
"//sky/shell/dart",
|
||||
"//ui/gfx",
|
||||
]
|
||||
}
|
||||
|
||||
source_set("gpu_direct") {
|
||||
sources = [
|
||||
"gpu/direct/surface_notifications_direct.cc",
|
||||
"gpu/direct/surface_notifications_direct.h",
|
||||
"gpu/direct/rasterizer_direct.cc",
|
||||
"gpu/direct/rasterizer_direct.h",
|
||||
"gpu/direct/ganesh_canvas.cc",
|
||||
"gpu/direct/ganesh_canvas.h",
|
||||
"gpu/direct/rasterizer_direct.cc",
|
||||
"gpu/direct/rasterizer_direct.h",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//ui/gl",
|
||||
":common",
|
||||
]
|
||||
}
|
||||
@@ -157,12 +153,12 @@ if (is_android) {
|
||||
"//mojo/android:libsystem_java",
|
||||
"//mojo/edk/base_edk",
|
||||
"//mojo/edk/system",
|
||||
"//ui/gl",
|
||||
]
|
||||
|
||||
ldflags = [
|
||||
"-lGLESv2",
|
||||
"-landroid",
|
||||
"-lEGL",
|
||||
"-lGLESv2",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -257,6 +253,8 @@ if (is_android) {
|
||||
"platform/ios/framework/Source/accessibility_bridge.mm",
|
||||
"platform/ios/framework/Source/application_messages_impl.h",
|
||||
"platform/ios/framework/Source/application_messages_impl.mm",
|
||||
"platform/ios/framework/Source/flutter_touch_mapper.h",
|
||||
"platform/ios/framework/Source/flutter_touch_mapper.mm",
|
||||
"platform/ios/framework/Source/FlutterAppDelegate.mm",
|
||||
"platform/ios/framework/Source/FlutterDartProject.mm",
|
||||
"platform/ios/framework/Source/FlutterDartProject_Internal.h",
|
||||
@@ -267,8 +265,8 @@ if (is_android) {
|
||||
"platform/ios/framework/Source/FlutterView.h",
|
||||
"platform/ios/framework/Source/FlutterView.mm",
|
||||
"platform/ios/framework/Source/FlutterViewController.mm",
|
||||
"platform/ios/framework/Source/flutter_touch_mapper.h",
|
||||
"platform/ios/framework/Source/flutter_touch_mapper.mm",
|
||||
"platform/ios/platform_view_ios.h",
|
||||
"platform/ios/platform_view_ios.mm",
|
||||
]
|
||||
|
||||
set_sources_assignment_filter([])
|
||||
@@ -277,8 +275,6 @@ if (is_android) {
|
||||
"platform/mac/platform_mac.mm",
|
||||
"platform/mac/platform_service_provider.cc",
|
||||
"platform/mac/platform_service_provider.h",
|
||||
"platform/mac/platform_view_mac.h",
|
||||
"platform/mac/platform_view_mac.mm",
|
||||
"platform/mac/view_service_provider.cc",
|
||||
"platform/mac/view_service_provider.h",
|
||||
]
|
||||
@@ -295,7 +291,6 @@ if (is_android) {
|
||||
"//sky/services/ns_net",
|
||||
"//sky/services/semantics",
|
||||
"//sky/services/vsync",
|
||||
"//ui/gl",
|
||||
":common",
|
||||
":gpu_direct",
|
||||
]
|
||||
@@ -455,7 +450,6 @@ if (is_android) {
|
||||
"//mojo/edk/base_edk",
|
||||
"//mojo/edk/system",
|
||||
"//sky/services/ns_net",
|
||||
"//ui/gl",
|
||||
":common",
|
||||
":gpu_direct",
|
||||
":testing",
|
||||
|
||||
@@ -27,18 +27,14 @@ GaneshCanvas::GaneshCanvas() {
|
||||
GaneshCanvas::~GaneshCanvas() {
|
||||
}
|
||||
|
||||
void GaneshCanvas::SetGrGLInterface(const GrGLInterface* interface) {
|
||||
void GaneshCanvas::SetupGrGLInterface() {
|
||||
sk_surface_ = nullptr;
|
||||
if (interface) {
|
||||
gr_context_ = skia::AdoptRef(GrContext::Create(kOpenGL_GrBackend,
|
||||
reinterpret_cast<GrBackendContext>(interface)));
|
||||
DCHECK(gr_context_);
|
||||
gr_context_->setResourceCacheLimits(kMaxGaneshResourceCacheCount,
|
||||
kMaxGaneshResourceCacheBytes);
|
||||
} else if (gr_context_) {
|
||||
gr_context_->abandonContext();
|
||||
gr_context_.clear();
|
||||
}
|
||||
gr_context_ = skia::AdoptRef(GrContext::Create(
|
||||
kOpenGL_GrBackend,
|
||||
reinterpret_cast<GrBackendContext>(GrGLCreateNativeInterface())));
|
||||
DCHECK(gr_context_);
|
||||
gr_context_->setResourceCacheLimits(kMaxGaneshResourceCacheCount,
|
||||
kMaxGaneshResourceCacheBytes);
|
||||
}
|
||||
|
||||
bool GaneshCanvas::SelectPixelConfig(GrPixelConfig* config) {
|
||||
|
||||
@@ -21,7 +21,8 @@ class GaneshCanvas {
|
||||
GaneshCanvas();
|
||||
~GaneshCanvas();
|
||||
|
||||
void SetGrGLInterface(const GrGLInterface* interface);
|
||||
void SetupGrGLInterface();
|
||||
|
||||
SkCanvas* GetCanvas(int32_t fbo, const SkISize& size);
|
||||
|
||||
bool IsValid();
|
||||
|
||||
@@ -9,42 +9,32 @@
|
||||
#include "sky/engine/wtf/PassRefPtr.h"
|
||||
#include "sky/engine/wtf/RefPtr.h"
|
||||
#include "sky/shell/gpu/picture_serializer.h"
|
||||
#include "sky/shell/platform_view.h"
|
||||
#include "sky/shell/shell.h"
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
#include "third_party/skia/include/core/SkPicture.h"
|
||||
#include "ui/gl/gl_bindings.h"
|
||||
#include "ui/gl/gl_bindings_skia_in_process.h"
|
||||
#include "ui/gl/gl_context.h"
|
||||
#include "ui/gl/gl_share_group.h"
|
||||
#include "ui/gl/gl_surface.h"
|
||||
|
||||
namespace sky {
|
||||
namespace shell {
|
||||
|
||||
static const double kOneFrameDuration = 1e3 / 60.0;
|
||||
|
||||
std::unique_ptr<Rasterizer> Rasterizer::Create() {
|
||||
return std::unique_ptr<Rasterizer>(new RasterizerDirect());
|
||||
}
|
||||
|
||||
RasterizerDirect::RasterizerDirect()
|
||||
: share_group_(new gfx::GLShareGroup()), binding_(this),
|
||||
weak_factory_(this) {
|
||||
}
|
||||
RasterizerDirect::RasterizerDirect() : binding_(this), weak_factory_(this) {}
|
||||
|
||||
RasterizerDirect::~RasterizerDirect() {
|
||||
weak_factory_.InvalidateWeakPtrs();
|
||||
Shell::Shared().PurgeRasterizers();
|
||||
}
|
||||
|
||||
base::WeakPtr<RasterizerDirect> RasterizerDirect::GetWeakPtr() {
|
||||
// Implementation of declaration in sky/shell/rasterizer.h.
|
||||
std::unique_ptr<Rasterizer> Rasterizer::Create() {
|
||||
return std::unique_ptr<Rasterizer>(new RasterizerDirect());
|
||||
}
|
||||
|
||||
// sky::shell::Rasterizer override.
|
||||
base::WeakPtr<Rasterizer> RasterizerDirect::GetWeakRasterizerPtr() {
|
||||
return weak_factory_.GetWeakPtr();
|
||||
}
|
||||
|
||||
base::WeakPtr<Rasterizer> RasterizerDirect::GetWeakRasterizerPtr() {
|
||||
return GetWeakPtr();
|
||||
}
|
||||
|
||||
// sky::shell::Rasterizer override.
|
||||
void RasterizerDirect::ConnectToRasterizer(
|
||||
mojo::InterfaceRequest<rasterizer::Rasterizer> request) {
|
||||
binding_.Bind(request.Pass());
|
||||
@@ -52,23 +42,37 @@ void RasterizerDirect::ConnectToRasterizer(
|
||||
Shell::Shared().AddRasterizer(GetWeakRasterizerPtr());
|
||||
}
|
||||
|
||||
void RasterizerDirect::OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget,
|
||||
base::WaitableEvent* did_draw) {
|
||||
gfx::SurfaceConfiguration config;
|
||||
config.stencil_bits = 8;
|
||||
surface_ = gfx::GLSurface::CreateViewGLSurface(widget, config);
|
||||
CHECK(surface_) << "GLSurface required.";
|
||||
// Eagerly create the GL context. For a while after the accelerated widget
|
||||
// is first available (after startup), the process is busy setting up dart
|
||||
// isolates. During this time, we are free to create the context. Thus
|
||||
// avoiding a delay when the first frame is painted.
|
||||
EnsureGLContext();
|
||||
CHECK(context_->MakeCurrent(surface_.get()));
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
surface_->SwapBuffers();
|
||||
if (did_draw)
|
||||
did_draw->Signal();
|
||||
// sky::shell::Rasterizer override.
|
||||
void RasterizerDirect::Setup(PlatformView* platform_view,
|
||||
base::Closure continuation,
|
||||
base::WaitableEvent* setup_completion_event) {
|
||||
CHECK(platform_view) << "Must be able to acquire the view.";
|
||||
|
||||
// The context needs to be made current before the GrGL interface can be
|
||||
// setup.
|
||||
bool success = platform_view->ContextMakeCurrent();
|
||||
|
||||
CHECK(success) << "Could not make the context current for initial GL setup";
|
||||
|
||||
ganesh_canvas_.SetupGrGLInterface();
|
||||
|
||||
platform_view_ = platform_view;
|
||||
|
||||
continuation.Run();
|
||||
|
||||
setup_completion_event->Signal();
|
||||
}
|
||||
|
||||
// sky::shell::Rasterizer override.
|
||||
void RasterizerDirect::Teardown(
|
||||
base::WaitableEvent* teardown_completion_event) {
|
||||
platform_view_ = nullptr;
|
||||
teardown_completion_event->Signal();
|
||||
}
|
||||
|
||||
// sky::shell::Rasterizer override.
|
||||
flow::LayerTree* RasterizerDirect::GetLastLayerTree() {
|
||||
return last_layer_tree_.get();
|
||||
}
|
||||
|
||||
void RasterizerDirect::Draw(uint64_t layer_tree_ptr,
|
||||
@@ -78,16 +82,13 @@ void RasterizerDirect::Draw(uint64_t layer_tree_ptr,
|
||||
std::unique_ptr<flow::LayerTree> layer_tree(
|
||||
reinterpret_cast<flow::LayerTree*>(layer_tree_ptr));
|
||||
|
||||
if (!surface_ || !layer_tree->root_layer()) {
|
||||
if (platform_view_ == nullptr || !platform_view_->ContextMakeCurrent() ||
|
||||
!layer_tree->root_layer()) {
|
||||
callback.Run();
|
||||
return;
|
||||
}
|
||||
|
||||
gfx::Size size(layer_tree->frame_size().width(),
|
||||
layer_tree->frame_size().height());
|
||||
|
||||
if (surface_->GetSize() != size)
|
||||
surface_->Resize(size);
|
||||
SkISize size = layer_tree->frame_size();
|
||||
|
||||
// There is no way for the compositor to know how long the layer tree
|
||||
// construction took. Fortunately, the layer tree does. Grab that time
|
||||
@@ -95,19 +96,19 @@ void RasterizerDirect::Draw(uint64_t layer_tree_ptr,
|
||||
compositor_context_.engine_time().SetLapTime(layer_tree->construction_time());
|
||||
|
||||
{
|
||||
EnsureGLContext();
|
||||
CHECK(context_->MakeCurrent(surface_.get()));
|
||||
SkCanvas* canvas = ganesh_canvas_.GetCanvas(
|
||||
surface_->GetBackingFrameBufferObject(), layer_tree->frame_size());
|
||||
platform_view_->DefaultFramebuffer(), layer_tree->frame_size());
|
||||
flow::CompositorContext::ScopedFrame frame =
|
||||
compositor_context_.AcquireFrame(ganesh_canvas_.gr_context(), *canvas);
|
||||
canvas->clear(SK_ColorBLACK);
|
||||
layer_tree->Raster(frame);
|
||||
canvas->flush();
|
||||
surface_->SwapBuffers();
|
||||
|
||||
platform_view_->SwapBuffers();
|
||||
}
|
||||
|
||||
// Trace to a file if necessary
|
||||
static const double kOneFrameDuration = 1e3 / 60.0;
|
||||
bool frameExceededThreshold = false;
|
||||
uint32_t thresholdInterval = layer_tree->rasterizer_tracing_threshold();
|
||||
if (thresholdInterval != 0 &&
|
||||
@@ -141,32 +142,5 @@ void RasterizerDirect::Draw(uint64_t layer_tree_ptr,
|
||||
last_layer_tree_ = std::move(layer_tree);
|
||||
}
|
||||
|
||||
void RasterizerDirect::OnOutputSurfaceDestroyed() {
|
||||
if (context_) {
|
||||
CHECK(context_->MakeCurrent(surface_.get()));
|
||||
compositor_context_.OnGrContextDestroyed();
|
||||
ganesh_canvas_.SetGrGLInterface(nullptr);
|
||||
context_ = nullptr;
|
||||
}
|
||||
CHECK(!ganesh_canvas_.IsValid());
|
||||
CHECK(!context_);
|
||||
surface_ = nullptr;
|
||||
}
|
||||
|
||||
void RasterizerDirect::EnsureGLContext() {
|
||||
if (context_)
|
||||
return;
|
||||
context_ = gfx::GLContext::CreateGLContext(share_group_.get(), surface_.get(),
|
||||
gfx::PreferIntegratedGpu);
|
||||
CHECK(context_) << "GLContext required.";
|
||||
CHECK(context_->MakeCurrent(surface_.get()));
|
||||
gr_gl_interface_ = skia::AdoptRef(gfx::CreateInProcessSkiaGLBinding());
|
||||
ganesh_canvas_.SetGrGLInterface(gr_gl_interface_.get());
|
||||
}
|
||||
|
||||
flow::LayerTree* RasterizerDirect::GetLastLayerTree() {
|
||||
return last_layer_tree_.get();
|
||||
}
|
||||
|
||||
} // namespace shell
|
||||
} // namespace sky
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SKY_SHELL_GPU_DIRECT_RASTERIZER_H_
|
||||
#define SKY_SHELL_GPU_DIRECT_RASTERIZER_H_
|
||||
#ifndef SKY_SHELL_GPU_DIRECT_RASTERIZER_DIRECT_H_
|
||||
#define SKY_SHELL_GPU_DIRECT_RASTERIZER_DIRECT_H_
|
||||
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/synchronization/waitable_event.h"
|
||||
@@ -11,61 +11,50 @@
|
||||
#include "skia/ext/refptr.h"
|
||||
#include "sky/shell/gpu/direct/ganesh_canvas.h"
|
||||
#include "sky/shell/rasterizer.h"
|
||||
#include "ui/gfx/native_widget_types.h"
|
||||
|
||||
namespace gfx {
|
||||
class GLContext;
|
||||
class GLShareGroup;
|
||||
class GLSurface;
|
||||
}
|
||||
|
||||
namespace sky {
|
||||
namespace shell {
|
||||
class GaneshContext;
|
||||
class GaneshSurface;
|
||||
|
||||
class RasterizerDirect : public Rasterizer {
|
||||
public:
|
||||
explicit RasterizerDirect();
|
||||
RasterizerDirect();
|
||||
|
||||
~RasterizerDirect() override;
|
||||
|
||||
base::WeakPtr<RasterizerDirect> GetWeakPtr();
|
||||
|
||||
base::WeakPtr<::sky::shell::Rasterizer> GetWeakRasterizerPtr() override;
|
||||
|
||||
// sky::shell::Rasterizer override.
|
||||
void ConnectToRasterizer(
|
||||
mojo::InterfaceRequest<rasterizer::Rasterizer> request) override;
|
||||
|
||||
void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget,
|
||||
base::WaitableEvent* did_draw);
|
||||
void OnOutputSurfaceDestroyed();
|
||||
// sky::shell::Rasterizer override.
|
||||
void Setup(PlatformView* platform_view,
|
||||
base::Closure continuation,
|
||||
base::WaitableEvent* setup_completion_event) override;
|
||||
|
||||
// sky::shell::Rasterizer override.
|
||||
void Teardown(base::WaitableEvent* teardown_completion_event) override;
|
||||
|
||||
// sky::shell::Rasterizer override.
|
||||
base::WeakPtr<sky::shell::Rasterizer> GetWeakRasterizerPtr() override;
|
||||
|
||||
// sky::shell::Rasterizer override.
|
||||
flow::LayerTree* GetLastLayerTree() override;
|
||||
|
||||
private:
|
||||
void Draw(uint64_t layer_tree_ptr, const DrawCallback& callback) override;
|
||||
|
||||
void EnsureGLContext();
|
||||
|
||||
scoped_refptr<gfx::GLShareGroup> share_group_;
|
||||
scoped_refptr<gfx::GLSurface> surface_;
|
||||
scoped_refptr<gfx::GLContext> context_;
|
||||
|
||||
skia::RefPtr<const GrGLInterface> gr_gl_interface_;
|
||||
GaneshCanvas ganesh_canvas_;
|
||||
|
||||
flow::CompositorContext compositor_context_;
|
||||
|
||||
mojo::Binding<rasterizer::Rasterizer> binding_;
|
||||
|
||||
std::unique_ptr<flow::LayerTree> last_layer_tree_;
|
||||
|
||||
PlatformView* platform_view_;
|
||||
base::WeakPtrFactory<RasterizerDirect> weak_factory_;
|
||||
|
||||
// sky::services::rasterizer::Rasterizer (from rasterizer.mojom) override.
|
||||
void Draw(uint64_t layer_tree_ptr, const DrawCallback& callback) override;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(RasterizerDirect);
|
||||
};
|
||||
|
||||
} // namespace shell
|
||||
} // namespace sky
|
||||
|
||||
#endif // SKY_SHELL_GPU_DIRECT_RASTERIZER_H_
|
||||
#endif // SKY_SHELL_GPU_DIRECT_RASTERIZER_DIRECT_H_
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
// Copyright 2015 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/shell/gpu/direct/surface_notifications_direct.h"
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/location.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "sky/shell/gpu/direct/rasterizer_direct.h"
|
||||
#include "sky/shell/shell.h"
|
||||
|
||||
namespace sky {
|
||||
namespace shell {
|
||||
|
||||
void SurfaceNotificationsDirect::NotifyCreated(
|
||||
const PlatformView::Config& config,
|
||||
gfx::AcceleratedWidget widget,
|
||||
base::WaitableEvent* did_draw) {
|
||||
RasterizerDirect* rasterizer = static_cast<RasterizerDirect*>(config.rasterizer);
|
||||
config.ui_task_runner->PostTask(
|
||||
FROM_HERE, base::Bind(&UIDelegate::OnOutputSurfaceCreated,
|
||||
config.ui_delegate,
|
||||
base::Bind(&RasterizerDirect::OnAcceleratedWidgetAvailable,
|
||||
rasterizer->GetWeakPtr(), widget, did_draw)));
|
||||
}
|
||||
|
||||
void SurfaceNotificationsDirect::NotifyDestroyed(
|
||||
const PlatformView::Config& config) {
|
||||
RasterizerDirect* rasterizer = static_cast<RasterizerDirect*>(config.rasterizer);
|
||||
config.ui_task_runner->PostTask(
|
||||
FROM_HERE, base::Bind(&UIDelegate::OnOutputSurfaceDestroyed,
|
||||
config.ui_delegate,
|
||||
base::Bind(&RasterizerDirect::OnOutputSurfaceDestroyed,
|
||||
rasterizer->GetWeakPtr())));
|
||||
}
|
||||
|
||||
} // namespace shell
|
||||
} // namespace sky
|
||||
@@ -1,25 +0,0 @@
|
||||
// Copyright 2015 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.
|
||||
|
||||
#ifndef SKY_SHELL_GPU_DIRECT_SURFACE_NOTIFICATIONS_DIRECT_H_
|
||||
#define SKY_SHELL_GPU_DIRECT_SURFACE_NOTIFICATIONS_DIRECT_H_
|
||||
|
||||
#include "base/synchronization/waitable_event.h"
|
||||
#include "sky/shell/platform_view.h"
|
||||
|
||||
namespace sky {
|
||||
namespace shell {
|
||||
|
||||
class SurfaceNotificationsDirect {
|
||||
public:
|
||||
static void NotifyCreated(const PlatformView::Config& config,
|
||||
gfx::AcceleratedWidget widget,
|
||||
base::WaitableEvent* did_draw);
|
||||
static void NotifyDestroyed(const PlatformView::Config& config);
|
||||
};
|
||||
|
||||
} // namespace shell
|
||||
} // namespace sky
|
||||
|
||||
#endif // SKY_SHELL_GPU_DIRECT_SURFACE_NOTIFICATIONS_DIRECT_H_
|
||||
@@ -18,7 +18,8 @@ namespace {
|
||||
|
||||
void DidEcho(void* context) {
|
||||
TRACE_EVENT_ASYNC_END0("flutter", "MGLEcho", context);
|
||||
Rasterizer::DrawCallback* callback = static_cast<Rasterizer::DrawCallback*>(context);
|
||||
Rasterizer::DrawCallback* callback =
|
||||
static_cast<Rasterizer::DrawCallback*>(context);
|
||||
callback->Run();
|
||||
delete callback;
|
||||
}
|
||||
@@ -32,24 +33,19 @@ std::unique_ptr<Rasterizer> Rasterizer::Create() {
|
||||
return std::unique_ptr<Rasterizer>(new RasterizerMojo());
|
||||
}
|
||||
|
||||
RasterizerMojo::RasterizerMojo() : binding_(this), weak_factory_(this) {
|
||||
}
|
||||
RasterizerMojo::RasterizerMojo() : binding_(this), weak_factory_(this) {}
|
||||
|
||||
RasterizerMojo::~RasterizerMojo() {
|
||||
weak_factory_.InvalidateWeakPtrs();
|
||||
Shell::Shared().PurgeRasterizers();
|
||||
}
|
||||
|
||||
base::WeakPtr<RasterizerMojo> RasterizerMojo::GetWeakPtr() {
|
||||
base::WeakPtr<Rasterizer> RasterizerMojo::GetWeakRasterizerPtr() {
|
||||
return weak_factory_.GetWeakPtr();
|
||||
}
|
||||
|
||||
base::WeakPtr<Rasterizer> RasterizerMojo::GetWeakRasterizerPtr() {
|
||||
return GetWeakPtr();
|
||||
}
|
||||
|
||||
void RasterizerMojo::ConnectToRasterizer (
|
||||
mojo::InterfaceRequest<rasterizer::Rasterizer> request ) {
|
||||
void RasterizerMojo::ConnectToRasterizer(
|
||||
mojo::InterfaceRequest<rasterizer::Rasterizer> request) {
|
||||
binding_.Bind(request.Pass());
|
||||
|
||||
Shell::Shared().AddRasterizer(GetWeakRasterizerPtr());
|
||||
@@ -61,6 +57,17 @@ void RasterizerMojo::Init(mojo::ApplicationConnectorPtr connector,
|
||||
scene_ = scene.Pass();
|
||||
}
|
||||
|
||||
void RasterizerMojo::Setup(PlatformView* platform_view,
|
||||
base::Closure rasterizer_continuation,
|
||||
base::WaitableEvent* setup_completion_event) {
|
||||
rasterizer_continuation.Run();
|
||||
setup_completion_event->Signal();
|
||||
}
|
||||
|
||||
void RasterizerMojo::Teardown(base::WaitableEvent* teardown_completion_event) {
|
||||
teardown_completion_event->Signal();
|
||||
}
|
||||
|
||||
void RasterizerMojo::Draw(uint64_t layer_tree_ptr,
|
||||
const DrawCallback& callback) {
|
||||
TRACE_EVENT0("flutter", "RasterizerMojo::Draw");
|
||||
@@ -69,7 +76,8 @@ void RasterizerMojo::Draw(uint64_t layer_tree_ptr,
|
||||
reinterpret_cast<flow::LayerTree*>(layer_tree_ptr));
|
||||
|
||||
if (!scene_ || !gl_state_ || gl_state_->gl_context->is_lost()) {
|
||||
TRACE_EVENT_INSTANT0("flutter", "RasterizerMojo::Draw error one", TRACE_EVENT_SCOPE_THREAD);
|
||||
TRACE_EVENT_INSTANT0("flutter", "RasterizerMojo::Draw error one",
|
||||
TRACE_EVENT_SCOPE_THREAD);
|
||||
callback.Run();
|
||||
return;
|
||||
}
|
||||
@@ -79,7 +87,8 @@ void RasterizerMojo::Draw(uint64_t layer_tree_ptr,
|
||||
size.height = layer_tree->frame_size().height();
|
||||
|
||||
if (size.width <= 0 || size.height <= 0.0) {
|
||||
TRACE_EVENT_INSTANT0("flutter", "RasterizerMojo::Draw empty frame size", TRACE_EVENT_SCOPE_THREAD);
|
||||
TRACE_EVENT_INSTANT0("flutter", "RasterizerMojo::Draw empty frame size",
|
||||
TRACE_EVENT_SCOPE_THREAD);
|
||||
callback.Run();
|
||||
return;
|
||||
}
|
||||
@@ -145,13 +154,11 @@ flow::LayerTree* RasterizerMojo::GetLastLayerTree() {
|
||||
}
|
||||
|
||||
RasterizerMojo::GLState::GLState(mojo::ApplicationConnector* connector)
|
||||
: gl_context(mojo::GLContext::CreateOffscreen(connector)),
|
||||
gl_texture_recycler(gl_context),
|
||||
ganesh_context(new mojo::skia::GaneshContext(gl_context)) {
|
||||
}
|
||||
: gl_context(mojo::GLContext::CreateOffscreen(connector)),
|
||||
gl_texture_recycler(gl_context),
|
||||
ganesh_context(new mojo::skia::GaneshContext(gl_context)) {}
|
||||
|
||||
RasterizerMojo::GLState::~GLState() {
|
||||
}
|
||||
RasterizerMojo::GLState::~GLState() {}
|
||||
|
||||
} // namespace shell
|
||||
} // namespace sky
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user