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

Unified Diff: ui/gfx/compositor/layer.cc

Issue 9289036: aura: Add Layer::LAYER_SOLID_COLOR to compositor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: minor changes Created 8 years, 11 months 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
« no previous file with comments | « ui/gfx/compositor/layer.h ('k') | ui/gfx/compositor/layer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/compositor/layer.cc
diff --git a/ui/gfx/compositor/layer.cc b/ui/gfx/compositor/layer.cc
index 4b7529e3c6f094b146f24d3cc74ffb22c4f3cdf8..4b6fcfe0e4ae2e328cd91deb34b5163197b500b5 100644
--- a/ui/gfx/compositor/layer.cc
+++ b/ui/gfx/compositor/layer.cc
@@ -15,6 +15,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFloatPoint.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFloatRect.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSolidColorLayer.h"
#include "ui/base/animation/animation.h"
#include "ui/gfx/canvas_skia.h"
#include "ui/gfx/compositor/compositor_switches.h"
@@ -30,7 +31,7 @@ namespace {
const float EPSILON = 1e-3f;
-bool IsApproximateMultilpleOf(float value, float base) {
+bool IsApproximateMultipleOf(float value, float base) {
float remainder = fmod(fabs(value), base);
return remainder < EPSILON || base - remainder < EPSILON;
}
@@ -44,7 +45,7 @@ const ui::Layer* GetRoot(const ui::Layer* layer) {
namespace ui {
Layer::Layer()
- : type_(LAYER_HAS_TEXTURE),
+ : type_(LAYER_TEXTURED),
compositor_(NULL),
parent_(NULL),
visible_(true),
@@ -223,7 +224,7 @@ bool Layer::IsDrawn() const {
}
bool Layer::ShouldDraw() const {
- return type_ == LAYER_HAS_TEXTURE && GetCombinedOpacity() > 0.0f &&
+ return type_ != LAYER_NOT_DRAWN && GetCombinedOpacity() > 0.0f &&
!hole_rect_.Contains(gfx::Rect(gfx::Point(0, 0), bounds_.size()));
}
@@ -244,6 +245,9 @@ void Layer::ConvertPointToLayer(const Layer* source,
}
void Layer::SetFillsBoundsOpaquely(bool fills_bounds_opaquely) {
+ if (type_ == LAYER_SOLID_COLOR)
+ return;
piman 2012/01/26 02:16:07 Mmh, I feel like we should setOpaque somewhere. I'
Daniel Erat 2012/01/26 18:10:26 Thanks, makes sense. I've added a call to setOpaq
+
if (fills_bounds_opaquely_ == fills_bounds_opaquely)
return;
@@ -257,6 +261,7 @@ void Layer::SetFillsBoundsOpaquely(bool fills_bounds_opaquely) {
}
void Layer::SetExternalTexture(ui::Texture* texture) {
+ DCHECK_EQ(type_, LAYER_TEXTURED);
layer_updated_externally_ = !!texture;
texture_ = texture;
#if defined(USE_WEBKIT_COMPOSITOR)
@@ -300,7 +305,7 @@ void Layer::SetCanvas(const SkCanvas& canvas, const gfx::Point& origin) {
#if defined(USE_WEBKIT_COMPOSITOR)
NOTREACHED();
#else
- DCHECK_EQ(type_, LAYER_HAS_TEXTURE);
+ DCHECK_EQ(type_, LAYER_TEXTURED);
if (!texture_.get())
texture_ = GetCompositor()->CreateTexture();
@@ -310,8 +315,20 @@ void Layer::SetCanvas(const SkCanvas& canvas, const gfx::Point& origin) {
#endif
}
+void Layer::SetColor(SkColor color) {
+ DCHECK_EQ(type_, LAYER_SOLID_COLOR);
+#if defined(USE_WEBKIT_COMPOSITOR)
+ // WebColor is equivalent to SkColor, per WebColor.h.
+ web_layer_.to<WebKit::WebSolidColorLayer>().setBackgroundColor(
+ static_cast<WebKit::WebColor>(color));
+#endif
+}
+
void Layer::SchedulePaint(const gfx::Rect& invalid_rect) {
#if defined(USE_WEBKIT_COMPOSITOR)
+ if (type_ == LAYER_SOLID_COLOR)
+ return;
+
WebKit::WebFloatRect web_rect(
invalid_rect.x(),
invalid_rect.y(),
@@ -506,7 +523,7 @@ void Layer::GetLayerProperties(const ui::Transform& parent_transform,
static_cast<float>(bounds().y()));
current_transform.ConcatTransform(parent_transform);
- if (fills_bounds_opaquely_ && type_ == LAYER_HAS_TEXTURE) {
+ if (fills_bounds_opaquely_ && type_ != LAYER_NOT_DRAWN) {
LayerProperties properties;
properties.layer = this;
properties.transform_relative_to_root = current_transform;
@@ -551,7 +568,7 @@ void Layer::RecomputeHole() {
float degrees;
gfx::Point p;
if (!InterpolatedTransform::FactorTRS(candidate_hole_transform, &p,
- &degrees, NULL) || !IsApproximateMultilpleOf(degrees, 90.0f))
+ &degrees, NULL) || !IsApproximateMultipleOf(degrees, 90.0f))
continue;
candidate_hole_transform.TransformRect(&candidate_hole);
@@ -567,7 +584,7 @@ void Layer::RecomputeHole() {
layer->DropTexture();
#if defined(USE_WEBKIT_COMPOSITOR)
- RecomputeDrawsContentAndUVRect();
+ RecomputeDrawsContentAndUVRect();
#endif
}
@@ -731,7 +748,10 @@ float Layer::GetOpacityForAnimation() const {
#if defined(USE_WEBKIT_COMPOSITOR)
void Layer::CreateWebLayer() {
- web_layer_ = WebKit::WebContentLayer::create(this);
+ if (type_ == LAYER_SOLID_COLOR)
+ web_layer_ = WebKit::WebSolidColorLayer::create();
+ else
+ web_layer_ = WebKit::WebContentLayer::create(this);
web_layer_.setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f));
web_layer_.setOpaque(true);
web_layer_is_accelerated_ = false;
@@ -750,10 +770,12 @@ void Layer::RecomputeTransform() {
void Layer::RecomputeDrawsContentAndUVRect() {
DCHECK(!web_layer_.isNull());
- bool should_draw = type_ == LAYER_HAS_TEXTURE &&
+ bool should_draw = type_ != LAYER_NOT_DRAWN &&
!hole_rect_.Contains(gfx::Rect(gfx::Point(0, 0), bounds_.size()));
+
if (!web_layer_is_accelerated_) {
- web_layer_.to<WebKit::WebContentLayer>().setDrawsContent(should_draw);
+ if (type_ != LAYER_SOLID_COLOR)
+ web_layer_.to<WebKit::WebContentLayer>().setDrawsContent(should_draw);
web_layer_.setBounds(bounds_.size());
} else {
DCHECK(texture_);
« no previous file with comments | « ui/gfx/compositor/layer.h ('k') | ui/gfx/compositor/layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698