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

Side by Side Diff: src/core/SkBitmapDevice.cpp

Issue 1156073003: remove unneeded device:lockpixels (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « include/core/SkDevice.h ('k') | src/utils/SkDeferredCanvas.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmapDevice.h" 8 #include "SkBitmapDevice.h"
9 #include "SkConfig8888.h" 9 #include "SkConfig8888.h"
10 #include "SkDeviceProperties.h" 10 #include "SkDeviceProperties.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 SkASSERT(bm.height() == fBitmap.height()); 113 SkASSERT(bm.height() == fBitmap.height());
114 fBitmap = bm; // intent is to use bm's pixelRef (and rowbytes/config) 114 fBitmap = bm; // intent is to use bm's pixelRef (and rowbytes/config)
115 fBitmap.lockPixels(); 115 fBitmap.lockPixels();
116 } 116 }
117 117
118 SkBaseDevice* SkBitmapDevice::onCreateDevice(const CreateInfo& cinfo, const SkPa int*) { 118 SkBaseDevice* SkBitmapDevice::onCreateDevice(const CreateInfo& cinfo, const SkPa int*) {
119 SkDeviceProperties leaky(cinfo.fPixelGeometry); 119 SkDeviceProperties leaky(cinfo.fPixelGeometry);
120 return SkBitmapDevice::Create(cinfo.fInfo, &leaky); 120 return SkBitmapDevice::Create(cinfo.fInfo, &leaky);
121 } 121 }
122 122
123 void SkBitmapDevice::lockPixels() {
124 if (fBitmap.lockPixelsAreWritable()) {
125 fBitmap.lockPixels();
126 }
127 }
128
129 void SkBitmapDevice::unlockPixels() {
130 if (fBitmap.lockPixelsAreWritable()) {
131 fBitmap.unlockPixels();
132 }
133 }
134
135 const SkBitmap& SkBitmapDevice::onAccessBitmap() { 123 const SkBitmap& SkBitmapDevice::onAccessBitmap() {
136 return fBitmap; 124 return fBitmap;
137 } 125 }
138 126
139 void* SkBitmapDevice::onAccessPixels(SkImageInfo* info, size_t* rowBytes) { 127 void* SkBitmapDevice::onAccessPixels(SkImageInfo* info, size_t* rowBytes) {
140 if (fBitmap.getPixels()) { 128 if (fBitmap.getPixels()) {
141 *info = fBitmap.info(); 129 *info = fBitmap.info();
142 *rowBytes = fBitmap.rowBytes(); 130 *rowBytes = fBitmap.rowBytes();
143 return fBitmap.getPixels(); 131 return fBitmap.getPixels();
144 } 132 }
(...skipping 20 matching lines...) Expand all
165 return true; 153 return true;
166 } 154 }
167 return false; 155 return false;
168 } 156 }
169 157
170 bool SkBitmapDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, s ize_t dstRowBytes, 158 bool SkBitmapDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, s ize_t dstRowBytes,
171 int x, int y) { 159 int x, int y) {
172 return fBitmap.readPixels(dstInfo, dstPixels, dstRowBytes, x, y); 160 return fBitmap.readPixels(dstInfo, dstPixels, dstRowBytes, x, y);
173 } 161 }
174 162
163 void SkBitmapDevice::onAttachToCanvas(SkCanvas* canvas) {
164 INHERITED::onAttachToCanvas(canvas);
165 if (fBitmap.lockPixelsAreWritable()) {
166 fBitmap.lockPixels();
167 }
168 }
169
170 void SkBitmapDevice::onDetachFromCanvas() {
171 INHERITED::onDetachFromCanvas();
172 if (fBitmap.lockPixelsAreWritable()) {
173 fBitmap.unlockPixels();
174 }
175 }
176
175 /////////////////////////////////////////////////////////////////////////////// 177 ///////////////////////////////////////////////////////////////////////////////
176 178
177 void SkBitmapDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { 179 void SkBitmapDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) {
178 draw.drawPaint(paint); 180 draw.drawPaint(paint);
179 } 181 }
180 182
181 void SkBitmapDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, si ze_t count, 183 void SkBitmapDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, si ze_t count,
182 const SkPoint pts[], const SkPaint& paint) { 184 const SkPoint pts[], const SkPaint& paint) {
183 CHECK_FOR_ANNOTATION(paint); 185 CHECK_FOR_ANNOTATION(paint);
184 draw.drawPoints(mode, count, pts, paint); 186 draw.drawPoints(mode, count, pts, paint);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 paint.getRasterizer() || 383 paint.getRasterizer() ||
382 paint.getPathEffect() || 384 paint.getPathEffect() ||
383 paint.isFakeBoldText() || 385 paint.isFakeBoldText() ||
384 paint.getStyle() != SkPaint::kFill_Style || 386 paint.getStyle() != SkPaint::kFill_Style ||
385 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) 387 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode))
386 { 388 {
387 return true; 389 return true;
388 } 390 }
389 return false; 391 return false;
390 } 392 }
OLDNEW
« no previous file with comments | « include/core/SkDevice.h ('k') | src/utils/SkDeferredCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698