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

Unified Diff: core/cross/cairo/renderer_cairo.cc

Issue 6320002: O2D: Several (unrelated) improvements:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: Created 9 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 | « core/cross/cairo/renderer_cairo.h ('k') | plugin/idl/layer.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/cross/cairo/renderer_cairo.cc
===================================================================
--- core/cross/cairo/renderer_cairo.cc (revision 71191)
+++ core/cross/cairo/renderer_cairo.cc (working copy)
@@ -72,14 +72,28 @@
display_ = NULL;
}
+// Comparison predicate for STL sort.
+bool LayerZValueLessThan(const Layer* first, const Layer* second) {
+ return first->z() < second->z();
+}
+
void RendererCairo::Paint() {
+ // TODO(tschmelcher): Don't keep creating and destroying the drawing context.
cairo_t* current_drawing = cairo_create(main_surface_);
+ // Redirect drawing to an off-screen surface (holding only colour information,
+ // without an alpha channel).
+ cairo_push_group_with_content(current_drawing, CAIRO_CONTENT_COLOR);
+
+ // Sort layers by z value.
+ // TODO(tschmelcher): Only sort when changes are made.
+ layer_list_.sort(LayerZValueLessThan);
+
// Paint the background.
PaintBackground(current_drawing);
// Core process of painting.
- for (LayerRefList::iterator i = layer_list_.begin();
+ for (LayerList::iterator i = layer_list_.begin();
i != layer_list_.end(); i++) {
// Put the state with no mask to the stack.
cairo_save(current_drawing);
@@ -93,7 +107,7 @@
}
// Masking areas for other scene.
- LayerRefList::iterator start_mask_it = i;
+ LayerList::iterator start_mask_it = i;
start_mask_it++;
MaskArea(current_drawing, start_mask_it);
@@ -109,6 +123,14 @@
// Restore to the state with no mask.
cairo_restore(current_drawing);
}
+
+ // Finish off-screen drawing and make the off-screen surface the source for
+ // paints to the screen.
+ cairo_pop_group_to_source(current_drawing);
+
+ // Paint the off-screen surface to the screen.
+ cairo_paint(current_drawing);
+
cairo_destroy(current_drawing);
}
@@ -122,10 +144,10 @@
cairo_restore(cr);
}
-void RendererCairo::MaskArea(cairo_t* cr, LayerRefList::iterator it) {
+void RendererCairo::MaskArea(cairo_t* cr, LayerList::iterator it) {
cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
- for (LayerRefList::iterator i = it; i != layer_list_.end(); i++) {
+ for (LayerList::iterator i = it; i != layer_list_.end(); i++) {
// Preparing and updating the Layer.
Layer* cur_mask = *i;
@@ -140,9 +162,13 @@
}
void RendererCairo::AddLayer(Layer* image) {
- layer_list_.push_front(Layer::Ref(image));
+ layer_list_.push_front(image);
}
+void RendererCairo::RemoveLayer(Layer* image) {
+ layer_list_.remove(image);
+}
+
void RendererCairo::InitCommon() {
main_surface_ = cairo_xlib_surface_create(display_, window_,
XDefaultVisual(display_, 0),
@@ -214,12 +240,6 @@
}
// TODO(fransiskusx): DO need to implement before shipped.
-// Removes the Layer from the array.
-void RendererCairo::RemoveLayer(Layer* image) {
- NOTIMPLEMENTED();
-}
-
-// TODO(fransiskusx): DO need to implement before shipped.
// Get a single fullscreen display mode by id.
// Returns true on success, false on error.
bool RendererCairo::GetDisplayMode(int id, DisplayMode* mode) {
« no previous file with comments | « core/cross/cairo/renderer_cairo.h ('k') | plugin/idl/layer.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698