summaryrefslogtreecommitdiffstats
path: root/o3d
diff options
context:
space:
mode:
authortschmelcher@chromium.org <tschmelcher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-02 21:21:05 +0000
committertschmelcher@chromium.org <tschmelcher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-02 21:21:05 +0000
commit108396b5f4588576a90db9282a8a3ee3a122a753 (patch)
tree3add5b4e50f6e19538550ab57189a4f324226371 /o3d
parent54edf8ac7428502b12a62a15f6a9e7e055b2c8fe (diff)
downloadchromium_src-108396b5f4588576a90db9282a8a3ee3a122a753.zip
chromium_src-108396b5f4588576a90db9282a8a3ee3a122a753.tar.gz
chromium_src-108396b5f4588576a90db9282a8a3ee3a122a753.tar.bz2
O2D: Add an API to the Layer class to enable painting the entire screen area. JavaScript will use this to paint a custom background colour using a Pattern created by Pattern::CreateRgbPattern(). (In principle JavaScript could already do this by setting (x, y) = (0, 0) and (width, height) = resolution of the display area, but this is simpler.) Also delete the code implementing the hard-coded black background.
TEST=loaded O2D and verified that a background can be created as described above BUG=none Review URL: http://codereview.chromium.org/6349032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73511 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d')
-rw-r--r--o3d/core/cross/cairo/layer.cc1
-rw-r--r--o3d/core/cross/cairo/layer.h12
-rw-r--r--o3d/core/cross/cairo/renderer_cairo.cc43
-rw-r--r--o3d/core/cross/cairo/renderer_cairo.h7
-rw-r--r--o3d/plugin/idl/layer.idl6
5 files changed, 36 insertions, 33 deletions
diff --git a/o3d/core/cross/cairo/layer.cc b/o3d/core/cross/cairo/layer.cc
index 943308f..58c77e0 100644
--- a/o3d/core/cross/cairo/layer.cc
+++ b/o3d/core/cross/cairo/layer.cc
@@ -51,6 +51,7 @@ Layer::~Layer() {
Layer::Layer(ServiceLocator* service_locator)
: ObjectBase(service_locator),
visible_(true),
+ everywhere_(false),
alpha_(0.0),
x_(0),
y_(0),
diff --git a/o3d/core/cross/cairo/layer.h b/o3d/core/cross/cairo/layer.h
index df2832b..1e790e0 100644
--- a/o3d/core/cross/cairo/layer.h
+++ b/o3d/core/cross/cairo/layer.h
@@ -77,6 +77,14 @@ class Layer : public ObjectBase {
visible_ = visible;
}
+ bool everywhere() const {
+ return everywhere_;
+ }
+
+ void set_everywhere(bool everywhere) {
+ everywhere_ = everywhere;
+ }
+
double alpha() const {
return alpha_;
}
@@ -177,6 +185,10 @@ class Layer : public ObjectBase {
// Whether this layer should be visible or not.
bool visible_;
+ // Paint everywhere rather than just within the region defined by the x, y,
+ // width, and height.
+ bool everywhere_;
+
// The transparency for the BLEND_WITH_TRANSPARENCY operator or the fading for
// the COPY_WITH_FADING operator.
double alpha_;
diff --git a/o3d/core/cross/cairo/renderer_cairo.cc b/o3d/core/cross/cairo/renderer_cairo.cc
index 2846d5d..68ebde9 100644
--- a/o3d/core/cross/cairo/renderer_cairo.cc
+++ b/o3d/core/cross/cairo/renderer_cairo.cc
@@ -92,9 +92,6 @@ void RendererCairo::Paint() {
// TODO(tschmelcher): Only sort when changes are made.
layer_list_.sort(LayerZValueLessThan);
- // Paint the background.
- PaintBackground(current_drawing);
-
// Core process of painting.
for (LayerList::iterator i = layer_list_.begin();
i != layer_list_.end(); i++) {
@@ -106,13 +103,15 @@ void RendererCairo::Paint() {
// Save the current drawing state.
cairo_save(current_drawing);
- // Clip the region outside the current Layer.
- cairo_rectangle(current_drawing,
- cur->x(),
- cur->y(),
- cur->width(),
- cur->height());
- cairo_clip(current_drawing);
+ if (!cur->everywhere()) {
+ // Clip the region outside the current Layer.
+ cairo_rectangle(current_drawing,
+ cur->x(),
+ cur->y(),
+ cur->width(),
+ cur->height());
+ cairo_clip(current_drawing);
+ }
// Clip the regions within other Layers that will obscure this one.
LayerList::iterator start_mask_it = i;
@@ -174,28 +173,20 @@ void RendererCairo::Paint() {
cairo_destroy(current_drawing);
}
-void RendererCairo::PaintBackground(cairo_t* cr) {
- cairo_save(cr);
- ClipArea(cr, layer_list_.begin());
-
- cairo_rectangle(cr, 0, 0, display_width(), display_height());
- cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
- cairo_fill(cr);
- cairo_restore(cr);
-}
-
void RendererCairo::ClipArea(cairo_t* cr, LayerList::iterator it) {
for (LayerList::iterator i = it; i != layer_list_.end(); i++) {
// Preparing and updating the Layer.
Layer* cur = *i;
if (!cur->ShouldClip()) continue;
- cairo_rectangle(cr, 0, 0, display_width(), display_height());
- cairo_rectangle(cr,
- cur->x(),
- cur->y(),
- cur->width(),
- cur->height());
+ if (!cur->everywhere()) {
+ cairo_rectangle(cr, 0, 0, display_width(), display_height());
+ cairo_rectangle(cr,
+ cur->x(),
+ cur->y(),
+ cur->width(),
+ cur->height());
+ }
cairo_clip(cr);
}
}
diff --git a/o3d/core/cross/cairo/renderer_cairo.h b/o3d/core/cross/cairo/renderer_cairo.h
index ced0d5e..d3c8e94 100644
--- a/o3d/core/cross/cairo/renderer_cairo.h
+++ b/o3d/core/cross/cairo/renderer_cairo.h
@@ -221,10 +221,6 @@ class RendererCairo : public Renderer {
// Clip the area of the current layer that will collide with other images.
void ClipArea(cairo_t* cr, LayerList::iterator it);
- // Paint the background with black color.
- // TODO(fransiskusx): Support changing the background color.
- void PaintBackground(cairo_t* cr);
-
// Linux Client Display
Display* display_;
// Linux Client Window
@@ -233,9 +229,6 @@ class RendererCairo : public Renderer {
// Main surface to render cairo
cairo_surface_t* main_surface_;
- // Draw the background
- cairo_t* bg_drawing_;
-
// Array of Layer
LayerList layer_list_;
};
diff --git a/o3d/plugin/idl/layer.idl b/o3d/plugin/idl/layer.idl
index ef28380..1b9a8f7 100644
--- a/o3d/plugin/idl/layer.idl
+++ b/o3d/plugin/idl/layer.idl
@@ -71,6 +71,12 @@ namespace o2d {
[getter, setter] bool visible;
%[
+ Paint everywhere rather than just within the region defined by the x, y,
+ width, and height.
+ %]
+ [getter, setter] bool everywhere;
+
+ %[
The transparency for the BLEND_WITH_TRANSPARENCY operator or the fading for
the COPY_WITH_FADING operator.
%]