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

Side by Side Diff: base/gfx/platform_canvas_mac.cc

Issue 11244: Move PlatformCanvas and PlatformDevice from base/gfx to webkit/port. I left h... (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
« no previous file with comments | « base/gfx/platform_canvas_mac.h ('k') | base/gfx/platform_canvas_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/gfx/platform_canvas_mac.h"
6
7 #include "base/gfx/bitmap_platform_device_mac.h"
8 #include "base/logging.h"
9
10 namespace gfx {
11
12 PlatformCanvasMac::PlatformCanvasMac() : SkCanvas() {
13 }
14
15 PlatformCanvasMac::PlatformCanvasMac(int width, int height, bool is_opaque)
16 : SkCanvas() {
17 initialize(width, height, is_opaque);
18 }
19
20 PlatformCanvasMac::PlatformCanvasMac(int width,
21 int height,
22 bool is_opaque,
23 CGContextRef context)
24 : SkCanvas() {
25 initialize(width, height, is_opaque);
26 }
27
28 PlatformCanvasMac::~PlatformCanvasMac() {
29 }
30
31 bool PlatformCanvasMac::initialize(int width,
32 int height,
33 bool is_opaque) {
34 SkDevice* device = createPlatformDevice(width, height, is_opaque, NULL);
35 if (!device)
36 return false;
37
38 setDevice(device);
39 device->unref(); // was created with refcount 1, and setDevice also refs
40 return true;
41 }
42
43 CGContextRef PlatformCanvasMac::beginPlatformPaint() {
44 return getTopPlatformDevice().GetBitmapContext();
45 }
46
47 void PlatformCanvasMac::endPlatformPaint() {
48 // flushing will be done in onAccessBitmap
49 }
50
51 PlatformDeviceMac& PlatformCanvasMac::getTopPlatformDevice() const {
52 // All of our devices should be our special PlatformDeviceMac.
53 SkCanvas::LayerIter iter(const_cast<PlatformCanvasMac*>(this), false);
54 return *static_cast<PlatformDeviceMac*>(iter.device());
55 }
56
57 SkDevice* PlatformCanvasMac::createDevice(SkBitmap::Config config,
58 int width,
59 int height,
60 bool is_opaque, bool isForLayer) {
61 DCHECK(config == SkBitmap::kARGB_8888_Config);
62 return createPlatformDevice(width, height, is_opaque, NULL);
63 }
64
65 SkDevice* PlatformCanvasMac::createPlatformDevice(int width,
66 int height,
67 bool is_opaque,
68 CGContextRef context) {
69 SkDevice* device = BitmapPlatformDeviceMac::Create(context, width, height,
70 is_opaque);
71 return device;
72 }
73
74 SkDevice* PlatformCanvasMac::setBitmapDevice(const SkBitmap&) {
75 NOTREACHED();
76 return NULL;
77 }
78
79 } // namespace gfx
80
OLDNEW
« no previous file with comments | « base/gfx/platform_canvas_mac.h ('k') | base/gfx/platform_canvas_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698