summaryrefslogtreecommitdiffstats
path: root/skia
diff options
context:
space:
mode:
authordavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-23 20:00:51 +0000
committerdavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-23 20:00:51 +0000
commit0ce348504238ae1aeb7e2555ea21301b0a428214 (patch)
tree78233e6177f0866f626b71fe59350bb1cfef6935 /skia
parent376a47639b68b58ab469716890573d360d2e358a (diff)
downloadchromium_src-0ce348504238ae1aeb7e2555ea21301b0a428214.zip
chromium_src-0ce348504238ae1aeb7e2555ea21301b0a428214.tar.gz
chromium_src-0ce348504238ae1aeb7e2555ea21301b0a428214.tar.bz2
Fixed some chrome aura build problems
- Removed default_plugin from aura build - Added new canvas_paint_x and renamed canvas_paint_linux to canvas_paint_gtk BUG=97131 TEST=none Review URL: http://codereview.chromium.org/8015012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102555 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia')
-rw-r--r--skia/ext/canvas_paint.h4
-rw-r--r--skia/ext/canvas_paint_gtk.h (renamed from skia/ext/canvas_paint_linux.h)0
-rw-r--r--skia/ext/canvas_paint_x.h111
3 files changed, 114 insertions, 1 deletions
diff --git a/skia/ext/canvas_paint.h b/skia/ext/canvas_paint.h
index 87118bd..051463f 100644
--- a/skia/ext/canvas_paint.h
+++ b/skia/ext/canvas_paint.h
@@ -16,8 +16,10 @@
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__sun)
#if defined(USE_WAYLAND)
#include "skia/ext/canvas_paint_wayland.h"
+#elif defined(TOOLKIT_USES_GTK)
+#include "skia/ext/canvas_paint_gtk.h"
#else
-#include "skia/ext/canvas_paint_linux.h"
+#include "skia/ext/canvas_paint_x.h"
#endif
#endif
diff --git a/skia/ext/canvas_paint_linux.h b/skia/ext/canvas_paint_gtk.h
index fca12ca..fca12ca 100644
--- a/skia/ext/canvas_paint_linux.h
+++ b/skia/ext/canvas_paint_gtk.h
diff --git a/skia/ext/canvas_paint_x.h b/skia/ext/canvas_paint_x.h
new file mode 100644
index 0000000..9868327
--- /dev/null
+++ b/skia/ext/canvas_paint_x.h
@@ -0,0 +1,111 @@
+// Copyright (c) 2011 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 SKIA_EXT_CANVAS_PAINT_WAYLAND_H_
+#define SKIA_EXT_CANVAS_PAINT_WAYLAND_H_
+#pragma once
+
+#include "base/logging.h"
+#include "skia/ext/platform_canvas.h"
+
+#include <cairo/cairo.h>
+
+namespace skia {
+
+// A class designed to translate skia painting into a region in a Wayland window
+// surface. On construction, it will set up a context for painting into, and on
+// destruction, it will commit it to the Wayland window surface.
+template <class T>
+class CanvasPaintT : public T {
+ public:
+ // This constructor assumes the result is opaque.
+ CanvasPaintT(cairo_surface_t* cairo_window_surface,
+ cairo_rectangle_t* region)
+ : context_(NULL),
+ cairo_window_surface_(cairo_window_surface),
+ region_(region),
+ composite_alpha_(false) {
+ init(true);
+ }
+
+ CanvasPaintT(cairo_surface_t* cairo_window_surface,
+ cairo_rectangle_t* region,
+ bool opaque)
+ : context_(NULL),
+ cairo_window_surface_(cairo_window_surface),
+ region_(region),
+ composite_alpha_(false) {
+ init(opaque);
+ }
+
+ virtual ~CanvasPaintT() {
+ if (!is_empty()) {
+ T::restoreToCount(1);
+
+ // Blit the dirty rect to the window.
+ CHECK(cairo_window_surface_);
+ cairo_t* cr = cairo_create(cairo_window_surface_);
+ CHECK(cr);
+
+ if (composite_alpha_)
+ cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
+
+ cairo_surface_t* source_surface = cairo_get_target(context_);
+ CHECK(source_surface);
+ // Flush cairo's cache of the surface.
+ cairo_surface_mark_dirty(source_surface);
+ cairo_set_source_surface(cr, source_surface, region_->x, region_->y);
+ cairo_rectangle(cr,
+ region_->x,
+ region_->y,
+ region_->width,
+ region_->height);
+ cairo_fill(cr);
+ cairo_destroy(cr);
+ }
+ }
+
+ // Sets whether the bitmap is composited in such a way that the alpha channel
+ // is honored. This is only useful if you've enabled an RGBA colormap on the
+ // widget. The default is false.
+ void set_composite_alpha(bool composite_alpha) {
+ composite_alpha_ = composite_alpha;
+ }
+
+ // Returns true if the invalid region is empty. The caller should call this
+ // function to determine if anything needs painting.
+ bool is_empty() const {
+ return region_->width == 0 && region_->height == 0;
+ }
+
+ private:
+ void init(bool opaque) {
+ if (!T::initialize(region_->width, region_->height, opaque, NULL)) {
+ // Cause a deliberate crash;
+ CHECK(false);
+ }
+
+ // Need to translate so that the dirty region appears at the origin of the
+ // surface.
+ T::translate(-SkIntToScalar(region_->x), -SkIntToScalar(region_->y));
+
+ context_ = BeginPlatformPaint(this);
+ }
+
+ cairo_t* context_;
+ cairo_surface_t* cairo_window_surface_;
+ cairo_rectangle_t* region_;
+ // See description above setter.
+ bool composite_alpha_;
+
+ // Disallow copy and assign.
+ CanvasPaintT(const CanvasPaintT&);
+ CanvasPaintT& operator=(const CanvasPaintT&);
+};
+
+typedef CanvasPaintT<PlatformCanvas> PlatformCanvasPaint;
+
+} // namespace skia
+
+#endif // SKIA_EXT_CANVAS_PAINT_WAYLAND_H_