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

Side by Side Diff: skia/ext/bitmap_platform_device_win.cc

Issue 7633040: CL removing inheritance of SkDevice from PlatformDevice. Flavours of PlatformDevice classes now ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <windows.h> 5 #include <windows.h>
6 #include <psapi.h> 6 #include <psapi.h>
7 7
8 #include "skia/ext/bitmap_platform_device_win.h" 8 #include "skia/ext/bitmap_platform_device_win.h"
9 9
10 #include "skia/ext/bitmap_platform_device_data.h" 10 #include "skia/ext/bitmap_platform_device_data.h"
11 #include "skia/ext/platform_device.h"
11 #include "third_party/skia/include/core/SkMatrix.h" 12 #include "third_party/skia/include/core/SkMatrix.h"
12 #include "third_party/skia/include/core/SkRefCnt.h" 13 #include "third_party/skia/include/core/SkRefCnt.h"
13 #include "third_party/skia/include/core/SkRegion.h" 14 #include "third_party/skia/include/core/SkRegion.h"
14 #include "third_party/skia/include/core/SkUtils.h" 15 #include "third_party/skia/include/core/SkUtils.h"
15 16
16 namespace skia { 17 namespace skia {
17 18
18 BitmapPlatformDevice::BitmapPlatformDeviceData::BitmapPlatformDeviceData( 19 BitmapPlatformDevice::BitmapPlatformDeviceData::BitmapPlatformDeviceData(
19 HBITMAP hbitmap) 20 HBITMAP hbitmap)
20 : bitmap_context_(hbitmap), 21 : bitmap_context_(hbitmap),
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 return new BitmapPlatformDevice(new BitmapPlatformDeviceData(hbitmap), 148 return new BitmapPlatformDevice(new BitmapPlatformDeviceData(hbitmap),
148 bitmap); 149 bitmap);
149 } 150 }
150 151
151 // static 152 // static
152 BitmapPlatformDevice* BitmapPlatformDevice::create(int width, 153 BitmapPlatformDevice* BitmapPlatformDevice::create(int width,
153 int height, 154 int height,
154 bool is_opaque, 155 bool is_opaque,
155 HANDLE shared_section) { 156 HANDLE shared_section) {
156 HDC screen_dc = GetDC(NULL); 157 HDC screen_dc = GetDC(NULL);
157 BitmapPlatformDevice* device = BitmapPlatformDevice::create( 158 BitmapPlatformDevice* device = BitmapPlatformDevice::create(screen_dc, width, height,
158 screen_dc, width, height, is_opaque, shared_section); 159 is_opaque, shared_section);
159 ReleaseDC(NULL, screen_dc); 160 ReleaseDC(NULL, screen_dc);
160 return device; 161 return device;
161 } 162 }
162 163
163 // The device will own the HBITMAP, which corresponds to also owning the pixel 164 // The device will own the HBITMAP, which corresponds to also owning the pixel
164 // data. Therefore, we do not transfer ownership to the SkDevice's bitmap. 165 // data. Therefore, we do not transfer ownership to the SkDevice's bitmap.
165 BitmapPlatformDevice::BitmapPlatformDevice( 166 BitmapPlatformDevice::BitmapPlatformDevice(
166 BitmapPlatformDeviceData* data, 167 BitmapPlatformDeviceData* data,
167 const SkBitmap& bitmap) 168 const SkBitmap& bitmap)
168 : PlatformDevice(bitmap), 169 : SkDevice(bitmap),
169 data_(data) { 170 data_(data) {
170 // The data object is already ref'ed for us by create(). 171 // The data object is already ref'ed for us by create().
171 SkDEBUGCODE(begin_paint_count_ = 0); 172 SkDEBUGCODE(begin_paint_count_ = 0);
173 SetPlatformDevice(this, this);
172 } 174 }
173 175
174 BitmapPlatformDevice::~BitmapPlatformDevice() { 176 BitmapPlatformDevice::~BitmapPlatformDevice() {
175 SkASSERT(begin_paint_count_ == 0); 177 SkASSERT(begin_paint_count_ == 0);
176 data_->unref(); 178 data_->unref();
177 } 179 }
178 180
179 HDC BitmapPlatformDevice::BeginPlatformPaint() { 181 HDC BitmapPlatformDevice::BeginPlatformPaint() {
180 SkDEBUGCODE(begin_paint_count_++); 182 SkDEBUGCODE(begin_paint_count_++);
181 return data_->GetBitmapDC(); 183 return data_->GetBitmapDC();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 } 257 }
256 258
257 SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice( 259 SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice(
258 SkBitmap::Config config, int width, int height, bool isOpaque, 260 SkBitmap::Config config, int width, int height, bool isOpaque,
259 Usage /*usage*/) { 261 Usage /*usage*/) {
260 SkASSERT(config == SkBitmap::kARGB_8888_Config); 262 SkASSERT(config == SkBitmap::kARGB_8888_Config);
261 return BitmapPlatformDevice::create(width, height, isOpaque, NULL); 263 return BitmapPlatformDevice::create(width, height, isOpaque, NULL);
262 } 264 }
263 265
264 } // namespace skia 266 } // namespace skia
265
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698