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

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

Issue 6949012: Assert on BeginPlatformPaint/EndPlatformPaint mismatch. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 7 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
« no previous file with comments | « skia/ext/bitmap_platform_device_win.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 170 }
171 171
172 // The device will own the HBITMAP, which corresponds to also owning the pixel 172 // The device will own the HBITMAP, which corresponds to also owning the pixel
173 // data. Therefore, we do not transfer ownership to the SkDevice's bitmap. 173 // data. Therefore, we do not transfer ownership to the SkDevice's bitmap.
174 BitmapPlatformDevice::BitmapPlatformDevice( 174 BitmapPlatformDevice::BitmapPlatformDevice(
175 BitmapPlatformDeviceData* data, 175 BitmapPlatformDeviceData* data,
176 const SkBitmap& bitmap) 176 const SkBitmap& bitmap)
177 : PlatformDevice(bitmap), 177 : PlatformDevice(bitmap),
178 data_(data) { 178 data_(data) {
179 // The data object is already ref'ed for us by create(). 179 // The data object is already ref'ed for us by create().
180 SkDEBUGCODE(begin_paint_count_ = 0);
180 } 181 }
181 182
182 // The copy constructor just adds another reference to the underlying data. 183 // The copy constructor just adds another reference to the underlying data.
183 // We use a const cast since the default Skia definitions don't define the 184 // We use a const cast since the default Skia definitions don't define the
184 // proper constedness that we expect (accessBitmap should really be const). 185 // proper constedness that we expect (accessBitmap should really be const).
185 BitmapPlatformDevice::BitmapPlatformDevice( 186 BitmapPlatformDevice::BitmapPlatformDevice(
186 const BitmapPlatformDevice& other) 187 const BitmapPlatformDevice& other)
187 : PlatformDevice( 188 : PlatformDevice(
188 const_cast<BitmapPlatformDevice&>(other).accessBitmap(true)), 189 const_cast<BitmapPlatformDevice&>(other).accessBitmap(true)),
189 data_(other.data_) { 190 data_(other.data_) {
190 data_->ref(); 191 data_->ref();
192 SkDEBUGCODE(begin_paint_count_ = 0);
191 } 193 }
192 194
193 BitmapPlatformDevice::~BitmapPlatformDevice() { 195 BitmapPlatformDevice::~BitmapPlatformDevice() {
196 SkASSERT(begin_paint_count_ == 0);
194 data_->unref(); 197 data_->unref();
195 } 198 }
196 199
197 BitmapPlatformDevice& BitmapPlatformDevice::operator=( 200 BitmapPlatformDevice& BitmapPlatformDevice::operator=(
198 const BitmapPlatformDevice& other) { 201 const BitmapPlatformDevice& other) {
199 data_ = other.data_; 202 data_ = other.data_;
200 data_->ref(); 203 data_->ref();
201 return *this; 204 return *this;
202 } 205 }
203 206
204 HDC BitmapPlatformDevice::BeginPlatformPaint() { 207 HDC BitmapPlatformDevice::BeginPlatformPaint() {
208 SkDEBUGCODE(begin_paint_count_++);
205 return data_->GetBitmapDC(); 209 return data_->GetBitmapDC();
206 } 210 }
207 211
212 void BitmapPlatformDevice::EndPlatformPaint() {
213 SkASSERT(begin_paint_count_--);
214 PlatformDevice::EndPlatformPaint();
215 }
216
208 void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform, 217 void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform,
209 const SkRegion& region, 218 const SkRegion& region,
210 const SkClipStack&) { 219 const SkClipStack&) {
211 data_->SetMatrixClip(transform, region); 220 data_->SetMatrixClip(transform, region);
212 } 221 }
213 222
214 void BitmapPlatformDevice::drawToHDC(HDC dc, int x, int y, 223 void BitmapPlatformDevice::drawToHDC(HDC dc, int x, int y,
215 const RECT* src_rect) { 224 const RECT* src_rect) {
216 bool created_dc = !data_->IsBitmapDCCreated(); 225 bool created_dc = !data_->IsBitmapDCCreated();
217 HDC source_dc = BeginPlatformPaint(); 226 HDC source_dc = BeginPlatformPaint();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 if (data_->IsBitmapDCCreated()) 289 if (data_->IsBitmapDCCreated())
281 GdiFlush(); 290 GdiFlush();
282 } 291 }
283 292
284 SkDeviceFactory* BitmapPlatformDevice::onNewDeviceFactory() { 293 SkDeviceFactory* BitmapPlatformDevice::onNewDeviceFactory() {
285 return SkNEW(BitmapPlatformDeviceFactory); 294 return SkNEW(BitmapPlatformDeviceFactory);
286 } 295 }
287 296
288 } // namespace skia 297 } // namespace skia
289 298
OLDNEW
« no previous file with comments | « skia/ext/bitmap_platform_device_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698