summaryrefslogtreecommitdiffstats
path: root/skia/ext/platform_canvas_win.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-14 15:14:53 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-14 15:14:53 +0000
commitbd63dc9cdf640a6d1e833ce0b5ed7ed9090973b0 (patch)
tree149a64e70ca634bd43019d639d9ae29ca6d45a9a /skia/ext/platform_canvas_win.cc
parentb39627f8eef41a2d4e1f4516bf905d6ad895e56b (diff)
downloadchromium_src-bd63dc9cdf640a6d1e833ce0b5ed7ed9090973b0.zip
chromium_src-bd63dc9cdf640a6d1e833ce0b5ed7ed9090973b0.tar.gz
chromium_src-bd63dc9cdf640a6d1e833ce0b5ed7ed9090973b0.tar.bz2
Refactor the PlatformContext layer to have only one class.
Previously we had three classes of PlatformCanvas*, one for each platform. Then we had a typedef of PlatformContext to PlatformCanvas[Mac|Win|Linux] for the specific platform. This means that it was almost impossible to forward-declare PlatformCanvas and there were a bunch of unnecessary includes of platform_canvas.h in header files. This change makes there be only one platform_canvas.h header with ifdefs, which removes a decent amount of duplicated code. There is a platform-independent file, and one platform-dependent file of platform_canvas for each platform. I also renamed PlatformDevice[Mac|Win|Linux] to PlatformDevice, althouth in this case I kept the separate headers since there was much less overlap. I also broke out CanvasPaint into separate headers so this template doesn't need to be included all over the project (only a couple of files actually need it). Review URL: http://codereview.chromium.org/125109 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18363 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/ext/platform_canvas_win.cc')
-rw-r--r--skia/ext/platform_canvas_win.cc70
1 files changed, 21 insertions, 49 deletions
diff --git a/skia/ext/platform_canvas_win.cc b/skia/ext/platform_canvas_win.cc
index fe0f852..d81b4f9 100644
--- a/skia/ext/platform_canvas_win.cc
+++ b/skia/ext/platform_canvas_win.cc
@@ -5,9 +5,8 @@
#include <windows.h>
#include <psapi.h>
-#include "skia/ext/platform_canvas_win.h"
-
#include "skia/ext/bitmap_platform_device_win.h"
+#include "skia/ext/platform_canvas.h"
namespace skia {
@@ -54,20 +53,20 @@ __declspec(noinline) void CrashIfInvalidSection(HANDLE shared_section) {
CHECK(::GetHandleInformation(shared_section, &handle_info) == TRUE);
}
-PlatformCanvasWin::PlatformCanvasWin() : SkCanvas() {
+PlatformCanvas::PlatformCanvas() : SkCanvas() {
}
-PlatformCanvasWin::PlatformCanvasWin(int width, int height, bool is_opaque)
+PlatformCanvas::PlatformCanvas(int width, int height, bool is_opaque)
: SkCanvas() {
bool initialized = initialize(width, height, is_opaque, NULL);
if (!initialized)
CrashForBitmapAllocationFailure(width, height);
}
-PlatformCanvasWin::PlatformCanvasWin(int width,
- int height,
- bool is_opaque,
- HANDLE shared_section)
+PlatformCanvas::PlatformCanvas(int width,
+ int height,
+ bool is_opaque,
+ HANDLE shared_section)
: SkCanvas() {
bool initialized = initialize(width, height, is_opaque, shared_section);
if (!initialized) {
@@ -76,15 +75,15 @@ PlatformCanvasWin::PlatformCanvasWin(int width,
}
}
-PlatformCanvasWin::~PlatformCanvasWin() {
+PlatformCanvas::~PlatformCanvas() {
}
-bool PlatformCanvasWin::initialize(int width,
- int height,
- bool is_opaque,
- HANDLE shared_section) {
- SkDevice* device =
- createPlatformDevice(width, height, is_opaque, shared_section);
+bool PlatformCanvas::initialize(int width,
+ int height,
+ bool is_opaque,
+ HANDLE shared_section) {
+ SkDevice* device = BitmapPlatformDevice::create(width, height,
+ is_opaque, shared_section);
if (!device)
return false;
@@ -93,48 +92,21 @@ bool PlatformCanvasWin::initialize(int width,
return true;
}
-HDC PlatformCanvasWin::beginPlatformPaint() {
+HDC PlatformCanvas::beginPlatformPaint() {
return getTopPlatformDevice().getBitmapDC();
}
-void PlatformCanvasWin::endPlatformPaint() {
+void PlatformCanvas::endPlatformPaint() {
// we don't clear the DC here since it will be likely to be used again
// flushing will be done in onAccessBitmap
}
-PlatformDeviceWin& PlatformCanvasWin::getTopPlatformDevice() const {
- // All of our devices should be our special PlatformDevice.
- SkCanvas::LayerIter iter(const_cast<PlatformCanvasWin*>(this), false);
- return *static_cast<PlatformDeviceWin*>(iter.device());
-}
-
-SkDevice* PlatformCanvasWin::createDevice(SkBitmap::Config config,
- int width,
- int height,
- bool is_opaque, bool isForLayer) {
+SkDevice* PlatformCanvas::createDevice(SkBitmap::Config config,
+ int width,
+ int height,
+ bool is_opaque, bool isForLayer) {
SkASSERT(config == SkBitmap::kARGB_8888_Config);
- return createPlatformDevice(width, height, is_opaque, NULL);
-}
-
-SkDevice* PlatformCanvasWin::createPlatformDevice(int width,
- int height,
- bool is_opaque,
- HANDLE shared_section) {
- HDC screen_dc = GetDC(NULL);
- SkDevice* device = BitmapPlatformDeviceWin::create(screen_dc, width, height,
- is_opaque, shared_section);
- ReleaseDC(NULL, screen_dc);
- return device;
-}
-
-SkDevice* PlatformCanvasWin::setBitmapDevice(const SkBitmap&) {
- SkASSERT(false); // Should not be called.
- return NULL;
-}
-
-// static
-size_t PlatformCanvasWin::StrideForWidth(unsigned width) {
- return 4 * width;
+ return BitmapPlatformDevice::create(width, height, is_opaque, NULL);
}
} // namespace skia