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

Side by Side Diff: webkit/port/platform/graphics/skia/public/PlatformCanvasMac.cpp

Issue 11357: Move the platform files form port to skia for Mac only. Hopefully this won't ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6
7 #include "PlatformCanvasMac.h"
8
9 #include "base/gfx/bitmap_platform_device_mac.h"
10 #include "base/logging.h"
11
12 namespace gfx {
13
14 PlatformCanvasMac::PlatformCanvasMac() : SkCanvas() {
15 }
16
17 PlatformCanvasMac::PlatformCanvasMac(int width, int height, bool is_opaque)
18 : SkCanvas() {
19 initialize(width, height, is_opaque);
20 }
21
22 PlatformCanvasMac::PlatformCanvasMac(int width,
23 int height,
24 bool is_opaque,
25 CGContextRef context)
26 : SkCanvas() {
27 initialize(width, height, is_opaque);
28 }
29
30 PlatformCanvasMac::~PlatformCanvasMac() {
31 }
32
33 bool PlatformCanvasMac::initialize(int width,
34 int height,
35 bool is_opaque) {
36 SkDevice* device = createPlatformDevice(width, height, is_opaque, NULL);
37 if (!device)
38 return false;
39
40 setDevice(device);
41 device->unref(); // was created with refcount 1, and setDevice also refs
42 return true;
43 }
44
45 CGContextRef PlatformCanvasMac::beginPlatformPaint() {
46 return getTopPlatformDevice().GetBitmapContext();
47 }
48
49 void PlatformCanvasMac::endPlatformPaint() {
50 // flushing will be done in onAccessBitmap
51 }
52
53 PlatformDeviceMac& PlatformCanvasMac::getTopPlatformDevice() const {
54 // All of our devices should be our special PlatformDeviceMac.
55 SkCanvas::LayerIter iter(const_cast<PlatformCanvasMac*>(this), false);
56 return *static_cast<PlatformDeviceMac*>(iter.device());
57 }
58
59 SkDevice* PlatformCanvasMac::createDevice(SkBitmap::Config config,
60 int width,
61 int height,
62 bool is_opaque, bool isForLayer) {
63 DCHECK(config == SkBitmap::kARGB_8888_Config);
64 return createPlatformDevice(width, height, is_opaque, NULL);
65 }
66
67 SkDevice* PlatformCanvasMac::createPlatformDevice(int width,
68 int height,
69 bool is_opaque,
70 CGContextRef context) {
71 SkDevice* device = BitmapPlatformDeviceMac::Create(context, width, height,
72 is_opaque);
73 return device;
74 }
75
76 SkDevice* PlatformCanvasMac::setBitmapDevice(const SkBitmap&) {
77 NOTREACHED();
78 return NULL;
79 }
80
81 } // namespace gfx
82
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698