summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
Diffstat (limited to 'base')
-rw-r--r--base/base.xcodeproj/project.pbxproj4
-rw-r--r--base/build/base_gfx.vcproj16
-rw-r--r--base/gfx/bitmap_platform_device_win.cc2
-rw-r--r--base/gfx/gdi_util.cc (renamed from base/gfx/bitmap_header.cc)18
-rw-r--r--base/gfx/gdi_util.h (renamed from base/gfx/bitmap_header.h)12
-rw-r--r--base/gfx/native_theme.cc2
-rw-r--r--base/gfx/vector_canvas_unittest.cc2
-rw-r--r--base/gfx/vector_device.cc2
-rw-r--r--base/tuple.h123
-rw-r--r--base/tuple_unittest.cc19
10 files changed, 176 insertions, 24 deletions
diff --git a/base/base.xcodeproj/project.pbxproj b/base/base.xcodeproj/project.pbxproj
index b00cd28..1b211b8 100644
--- a/base/base.xcodeproj/project.pbxproj
+++ b/base/base.xcodeproj/project.pbxproj
@@ -558,8 +558,6 @@
8254038E0D92D2CF0006B936 /* word_iterator.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = word_iterator.cc; sourceTree = "<group>"; };
8254038F0D92D2CF0006B936 /* word_iterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = word_iterator.h; sourceTree = "<group>"; };
825403B10D92D2E50006B936 /* libbase_gfx.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libbase_gfx.a; sourceTree = BUILT_PRODUCTS_DIR; };
- 825403C00D92D31D0006B936 /* bitmap_header.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = bitmap_header.cc; sourceTree = "<group>"; };
- 825403C10D92D31D0006B936 /* bitmap_header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bitmap_header.h; sourceTree = "<group>"; };
825403C40D92D31D0006B936 /* font_utils.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = font_utils.cc; sourceTree = "<group>"; };
825403C50D92D31D0006B936 /* font_utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = font_utils.h; sourceTree = "<group>"; };
825403C80D92D31D0006B936 /* native_theme.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = native_theme.cc; sourceTree = "<group>"; };
@@ -1058,8 +1056,6 @@
825403B40D92D2EC0006B936 /* gfx */ = {
isa = PBXGroup;
children = (
- 825403C00D92D31D0006B936 /* bitmap_header.cc */,
- 825403C10D92D31D0006B936 /* bitmap_header.h */,
AB6BC1ED0E54E836006436D5 /* bitmap_platform_device.h */,
829E2F940DBFD74B00819EBF /* bitmap_platform_device_mac.cc */,
829E2F950DBFD74B00819EBF /* bitmap_platform_device_mac.h */,
diff --git a/base/build/base_gfx.vcproj b/base/build/base_gfx.vcproj
index 329449b..79ce51d 100644
--- a/base/build/base_gfx.vcproj
+++ b/base/build/base_gfx.vcproj
@@ -122,14 +122,6 @@
</References>
<Files>
<File
- RelativePath="..\gfx\bitmap_header.cc"
- >
- </File>
- <File
- RelativePath="..\gfx\bitmap_header.h"
- >
- </File>
- <File
RelativePath="..\gfx\bitmap_platform_device_win.cc"
>
</File>
@@ -154,6 +146,14 @@
>
</File>
<File
+ RelativePath="..\gfx\gdi_util.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\gfx\gdi_util.h"
+ >
+ </File>
+ <File
RelativePath="..\gfx\image_operations.cc"
>
</File>
diff --git a/base/gfx/bitmap_platform_device_win.cc b/base/gfx/bitmap_platform_device_win.cc
index 1209db1..2031027 100644
--- a/base/gfx/bitmap_platform_device_win.cc
+++ b/base/gfx/bitmap_platform_device_win.cc
@@ -4,7 +4,7 @@
#include "base/gfx/bitmap_platform_device_win.h"
-#include "base/gfx/bitmap_header.h"
+#include "base/gfx/gdi_util.h"
#include "base/logging.h"
#include "base/process_util.h"
#include "SkMatrix.h"
diff --git a/base/gfx/bitmap_header.cc b/base/gfx/gdi_util.cc
index acaf0c0..48df853 100644
--- a/base/gfx/bitmap_header.cc
+++ b/base/gfx/gdi_util.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/gfx/bitmap_header.h"
+#include "base/gfx/gdi_util.h"
namespace gfx {
@@ -60,5 +60,21 @@ void CreateMonochromeBitmapHeader(int width,
hdr->biClrImportant = 0;
}
+void SubtractRectanglesFromRegion(HRGN hrgn,
+ const std::vector<gfx::Rect>& cutouts) {
+ if (cutouts.size()) {
+ HRGN cutout = ::CreateRectRgn(0, 0, 0, 0);
+ for (size_t i = 0; i < cutouts.size(); i++) {
+ ::SetRectRgn(cutout,
+ cutouts[i].x(),
+ cutouts[i].y(),
+ cutouts[i].right(),
+ cutouts[i].bottom());
+ ::CombineRgn(hrgn, hrgn, cutout, RGN_DIFF);
+ }
+ ::DeleteObject(cutout);
+ }
+}
+
} // namespace gfx
diff --git a/base/gfx/bitmap_header.h b/base/gfx/gdi_util.h
index 0c8066b..cc15e92 100644
--- a/base/gfx/bitmap_header.h
+++ b/base/gfx/gdi_util.h
@@ -2,10 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_GFX_BITMAP_HEADER_H__
-#define BASE_GFX_BITMAP_HEADER_H__
+#ifndef BASE_GFX_GDI_UTIL_H__
+#define BASE_GFX_GDI_UTIL_H__
+#include <vector>
#include <windows.h>
+#include "base/gfx/rect.h"
namespace gfx {
@@ -25,8 +27,10 @@ void CreateBitmapV4Header(int width, int height, BITMAPV4HEADER* hdr);
// Creates a monochrome bitmap header.
void CreateMonochromeBitmapHeader(int width, int height, BITMAPINFOHEADER* hdr);
+// Modify the given hrgn by subtracting the given rectangles.
+void SubtractRectanglesFromRegion(HRGN hrgn,
+ const std::vector<gfx::Rect>& cutouts);
} // namespace gfx
-#endif // BASE_GFX_BITMAP_HEADER_H__
-
+#endif // BASE_GFX_GDI_UTIL_H__
diff --git a/base/gfx/native_theme.cc b/base/gfx/native_theme.cc
index ea55502..b8aa30c 100644
--- a/base/gfx/native_theme.cc
+++ b/base/gfx/native_theme.cc
@@ -9,7 +9,7 @@
#include <vsstyle.h>
#include <vssym32.h>
-#include "base/gfx/bitmap_header.h"
+#include "base/gfx/gdi_util.h"
#include "base/gfx/platform_canvas_win.h"
#include "base/gfx/skia_utils.h"
#include "base/gfx/rect.h"
diff --git a/base/gfx/vector_canvas_unittest.cc b/base/gfx/vector_canvas_unittest.cc
index 65d3d5f..60a79ba 100644
--- a/base/gfx/vector_canvas_unittest.cc
+++ b/base/gfx/vector_canvas_unittest.cc
@@ -8,7 +8,7 @@
#include "base/command_line.h"
#include "base/file_util.h"
-#include "base/gfx/bitmap_header.h"
+#include "base/gfx/gdi_util.h"
#include "base/gfx/png_decoder.h"
#include "base/gfx/png_encoder.h"
#include "base/gfx/size.h"
diff --git a/base/gfx/vector_device.cc b/base/gfx/vector_device.cc
index 8778299..7230e2b 100644
--- a/base/gfx/vector_device.cc
+++ b/base/gfx/vector_device.cc
@@ -4,7 +4,7 @@
#include "base/gfx/vector_device.h"
-#include "base/gfx/bitmap_header.h"
+#include "base/gfx/gdi_util.h"
#include "base/gfx/skia_utils.h"
#include "base/logging.h"
#include "base/scoped_handle.h"
diff --git a/base/tuple.h b/base/tuple.h
index c54b579..a515830 100644
--- a/base/tuple.h
+++ b/base/tuple.h
@@ -3,8 +3,8 @@
// found in the LICENSE file.
// A Tuple is a generic templatized container, similar in concept to std::pair.
-// There are classes Tuple0 to Tuple5, cooresponding to the number of elements
-// it contains. The convenient MakeTuple() function takes 0 to 5 arguments,
+// There are classes Tuple0 to Tuple6, cooresponding to the number of elements
+// it contains. The convenient MakeTuple() function takes 0 to 6 arguments,
// and will construct and return the appropriate Tuple object. The functions
// DispatchToMethod and DispatchToFunction take a function pointer or instance
// and method pointer, and unpack a tuple into arguments to the call.
@@ -193,6 +193,46 @@ public:
E e;
};
+template <class A, class B, class C, class D, class E, class F>
+struct Tuple6 {
+public:
+ typedef A TypeA;
+ typedef B TypeB;
+ typedef C TypeC;
+ typedef D TypeD;
+ typedef E TypeE;
+ typedef F TypeF;
+ typedef Tuple6<typename TupleTraits<A>::ValueType,
+ typename TupleTraits<B>::ValueType,
+ typename TupleTraits<C>::ValueType,
+ typename TupleTraits<D>::ValueType,
+ typename TupleTraits<E>::ValueType,
+ typename TupleTraits<F>::ValueType> ValueTuple;
+ typedef Tuple6<typename TupleTraits<A>::RefType,
+ typename TupleTraits<B>::RefType,
+ typename TupleTraits<C>::RefType,
+ typename TupleTraits<D>::RefType,
+ typename TupleTraits<E>::RefType,
+ typename TupleTraits<F>::RefType> RefTuple;
+
+ Tuple6() {}
+ Tuple6(typename TupleTraits<A>::ParamType a,
+ typename TupleTraits<B>::ParamType b,
+ typename TupleTraits<C>::ParamType c,
+ typename TupleTraits<D>::ParamType d,
+ typename TupleTraits<E>::ParamType e,
+ typename TupleTraits<F>::ParamType f)
+ : a(a), b(b), c(c), d(d), e(e), f(f) {
+ }
+
+ A a;
+ B b;
+ C c;
+ D d;
+ E e;
+ F f;
+};
+
// Tuple creators -------------------------------------------------------------
//
// Helper functions for constructing tuples while inferring the template
@@ -229,6 +269,12 @@ inline Tuple5<A, B, C, D, E> MakeTuple(const A& a, const B& b, const C& c,
return Tuple5<A, B, C, D, E>(a, b, c, d, e);
}
+template <class A, class B, class C, class D, class E, class F>
+inline Tuple6<A, B, C, D, E, F> MakeTuple(const A& a, const B& b, const C& c,
+ const D& d, const E& e, const F& f) {
+ return Tuple6<A, B, C, D, E, F>(a, b, c, d, e, f);
+}
+
// The following set of helpers make what Boost refers to as "Tiers" - a tuple
// of references.
@@ -257,6 +303,12 @@ inline Tuple5<A&, B&, C&, D&, E&> MakeRefTuple(A& a, B& b, C& c, D& d, E& e) {
return Tuple5<A&, B&, C&, D&, E&>(a, b, c, d, e);
}
+template <class A, class B, class C, class D, class E, class F>
+inline Tuple6<A&, B&, C&, D&, E&, F&> MakeRefTuple(A& a, B& b, C& c, D& d, E& e,
+ F& f) {
+ return Tuple6<A&, B&, C&, D&, E&, F&>(a, b, c, d, e, f);
+}
+
// Dispatchers ----------------------------------------------------------------
//
// Helper functions that call the given method on an object, with the unpacked
@@ -306,6 +358,13 @@ inline void DispatchToMethod(ObjT* obj, Method method,
(obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e);
}
+template<class ObjT, class Method, class A, class B, class C, class D, class E,
+ class F>
+inline void DispatchToMethod(ObjT* obj, Method method,
+ const Tuple6<A, B, C, D, E, F>& arg) {
+ (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f);
+}
+
// Static Dispatchers with no out params.
template <class Function>
@@ -345,6 +404,12 @@ inline void DispatchToFunction(Function function,
(*function)(arg.a, arg.b, arg.c, arg.d, arg.e);
}
+template<class Function, class A, class B, class C, class D, class E, class F>
+inline void DispatchToFunction(Function function,
+ const Tuple6<A, B, C, D, E, F>& arg) {
+ (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f);
+}
+
// Dispatchers with 0 out param (as a Tuple0).
template <class ObjT, class Method>
@@ -385,6 +450,13 @@ inline void DispatchToMethod(ObjT* obj, Method method,
(obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e);
}
+template<class ObjT, class Method, class A, class B, class C, class D, class E,
+ class F>
+inline void DispatchToMethod(ObjT* obj, Method method,
+ const Tuple6<A, B, C, D, E, F>& arg, Tuple0*) {
+ (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f);
+}
+
// Dispatchers with 1 out param.
template<class ObjT, class Method,
@@ -444,6 +516,15 @@ inline void DispatchToMethod(ObjT* obj, Method method,
(obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a);
}
+template<class ObjT, class Method,
+ class InA, class InB, class InC, class InD, class InE, class InF,
+ class OutA>
+inline void DispatchToMethod(ObjT* obj, Method method,
+ const Tuple6<InA, InB, InC, InD, InE, InF>& in,
+ Tuple1<OutA>* out) {
+ (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a);
+}
+
// Dispatchers with 2 out params.
template<class ObjT, class Method,
@@ -503,6 +584,15 @@ inline void DispatchToMethod(ObjT* obj, Method method,
(obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b);
}
+template<class ObjT, class Method,
+ class InA, class InB, class InC, class InD, class InE, class InF,
+ class OutA, class OutB>
+inline void DispatchToMethod(ObjT* obj, Method method,
+ const Tuple6<InA, InB, InC, InD, InE, InF>& in,
+ Tuple2<OutA, OutB>* out) {
+ (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a, &out->b);
+}
+
// Dispatchers with 3 out params.
template<class ObjT, class Method,
@@ -562,6 +652,15 @@ inline void DispatchToMethod(ObjT* obj, Method method,
(obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b, &out->c);
}
+template<class ObjT, class Method,
+ class InA, class InB, class InC, class InD, class InE, class InF,
+ class OutA, class OutB, class OutC>
+inline void DispatchToMethod(ObjT* obj, Method method,
+ const Tuple6<InA, InB, InC, InD, InE, InF>& in,
+ Tuple3<OutA, OutB, OutC>* out) {
+ (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a, &out->b, &out->c);
+}
+
// Dispatchers with 4 out params.
template<class ObjT, class Method,
@@ -622,6 +721,16 @@ inline void DispatchToMethod(ObjT* obj, Method method,
&out->a, &out->b, &out->c, &out->d);
}
+template<class ObjT, class Method,
+ class InA, class InB, class InC, class InD, class InE, class InF,
+ class OutA, class OutB, class OutC, class OutD>
+inline void DispatchToMethod(ObjT* obj, Method method,
+ const Tuple6<InA, InB, InC, InD, InE, InF>& in,
+ Tuple4<OutA, OutB, OutC, OutD>* out) {
+ (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f,
+ &out->a, &out->b, &out->c, &out->d);
+}
+
// Dispatchers with 5 out params.
template<class ObjT, class Method,
@@ -683,5 +792,15 @@ inline void DispatchToMethod(ObjT* obj, Method method,
&out->a, &out->b, &out->c, &out->d, &out->e);
}
+template<class ObjT, class Method,
+ class InA, class InB, class InC, class InD, class InE, class InF,
+ class OutA, class OutB, class OutC, class OutD, class OutE>
+inline void DispatchToMethod(ObjT* obj, Method method,
+ const Tuple6<InA, InB, InC, InD, InE, InF>& in,
+ Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
+ (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f,
+ &out->a, &out->b, &out->c, &out->d, &out->e);
+}
+
#endif // BASE_TUPLE_H__
diff --git a/base/tuple_unittest.cc b/base/tuple_unittest.cc
index 36ea560..65a3757 100644
--- a/base/tuple_unittest.cc
+++ b/base/tuple_unittest.cc
@@ -18,6 +18,13 @@ struct Addy {
}
};
+struct Addz {
+ Addz() { }
+ void DoAdd(int a, int b, int c, int d, int e, int* res) {
+ *res = a + b + c + d + e;
+ }
+};
+
} // namespace
TEST(TupleTest, Basic) {
@@ -27,6 +34,7 @@ TEST(TupleTest, Basic) {
Tuple3<int, int, int> t3(1, 2, 3);
Tuple4<int, int, int, int*> t4(1, 2, 3, &t1.a);
Tuple5<int, int, int, int, int*> t5(1, 2, 3, 4, &t4.a);
+ Tuple6<int, int, int, int, int, int*> t6(1, 2, 3, 4, 5, &t4.a);
EXPECT_EQ(1, t1.a);
EXPECT_EQ(1, t2.a);
@@ -40,7 +48,11 @@ TEST(TupleTest, Basic) {
EXPECT_EQ(2, t5.b);
EXPECT_EQ(3, t5.c);
EXPECT_EQ(4, t5.d);
-
+ EXPECT_EQ(1, t6.a);
+ EXPECT_EQ(2, t6.b);
+ EXPECT_EQ(3, t6.c);
+ EXPECT_EQ(4, t6.d);
+ EXPECT_EQ(5, t6.e);
EXPECT_EQ(1, t1.a);
DispatchToFunction(&DoAdd, t4);
@@ -54,6 +66,11 @@ TEST(TupleTest, Basic) {
EXPECT_EQ(1, t4.a);
DispatchToMethod(&addy, &Addy::DoAdd, t5);
EXPECT_EQ(10, t4.a);
+
+ Addz addz;
+ EXPECT_EQ(10, t4.a);
+ DispatchToMethod(&addz, &Addz::DoAdd, t6);
+ EXPECT_EQ(15, t4.a);
}
namespace {