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 1154293002: don't use accessBitmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | src/core/SkCanvas.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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 SkBaseDevice* SkBitmapDevice::onCreateDevice(const CreateInfo& cinfo, const SkPa int*) { 119 SkBaseDevice* SkBitmapDevice::onCreateDevice(const CreateInfo& cinfo, const SkPa int*) {
120 SkDeviceProperties leaky(cinfo.fPixelGeometry); 120 SkDeviceProperties leaky(cinfo.fPixelGeometry);
121 return SkBitmapDevice::Create(cinfo.fInfo, &leaky); 121 return SkBitmapDevice::Create(cinfo.fInfo, &leaky);
122 } 122 }
123 123
124 const SkBitmap& SkBitmapDevice::onAccessBitmap() { 124 const SkBitmap& SkBitmapDevice::onAccessBitmap() {
125 return fBitmap; 125 return fBitmap;
126 } 126 }
127 127
128 bool SkBitmapDevice::onAccessPixels(SkPixmap* pmap) { 128 bool SkBitmapDevice::onAccessPixels(SkPixmap* pmap) {
129 return fBitmap.lockPixelsAreWritable() && this->onPeekPixels(pmap);
130 }
131
132 bool SkBitmapDevice::onPeekPixels(SkPixmap* pmap) {
129 const SkImageInfo info = fBitmap.info(); 133 const SkImageInfo info = fBitmap.info();
130 if (fBitmap.getPixels() && (kUnknown_SkColorType != info.colorType())) { 134 if (fBitmap.getPixels() && (kUnknown_SkColorType != info.colorType())) {
131 SkColorTable* ctable = NULL; 135 SkColorTable* ctable = NULL;
132 pmap->reset(fBitmap.info(), fBitmap.getPixels(), fBitmap.rowBytes(), cta ble); 136 pmap->reset(fBitmap.info(), fBitmap.getPixels(), fBitmap.rowBytes(), cta ble);
133 return true; 137 return true;
134 } 138 }
135 return false; 139 return false;
136 } 140 }
137 141
138 bool SkBitmapDevice::onPeekPixels(SkPixmap* pmap) {
139 // peek and access are the exact same logic for us
140 return this->onAccessPixels(pmap);
141 }
142
143 bool SkBitmapDevice::onWritePixels(const SkImageInfo& srcInfo, const void* srcPi xels, 142 bool SkBitmapDevice::onWritePixels(const SkImageInfo& srcInfo, const void* srcPi xels,
144 size_t srcRowBytes, int x, int y) { 143 size_t srcRowBytes, int x, int y) {
145 // since we don't stop creating un-pixeled devices yet, check for no pixels here 144 // since we don't stop creating un-pixeled devices yet, check for no pixels here
146 if (NULL == fBitmap.getPixels()) { 145 if (NULL == fBitmap.getPixels()) {
147 return false; 146 return false;
148 } 147 }
149 148
150 const SkImageInfo dstInfo = fBitmap.info().makeWH(srcInfo.width(), srcInfo.h eight()); 149 const SkImageInfo dstInfo = fBitmap.info().makeWH(srcInfo.width(), srcInfo.h eight());
151 150
152 void* dstPixels = fBitmap.getAddr(x, y); 151 void* dstPixels = fBitmap.getAddr(x, y);
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 const SkPoint verts[], const SkPoint textures[ ], 344 const SkPoint verts[], const SkPoint textures[ ],
346 const SkColor colors[], SkXfermode* xmode, 345 const SkColor colors[], SkXfermode* xmode,
347 const uint16_t indices[], int indexCount, 346 const uint16_t indices[], int indexCount,
348 const SkPaint& paint) { 347 const SkPaint& paint) {
349 draw.drawVertices(vmode, vertexCount, verts, textures, colors, xmode, 348 draw.drawVertices(vmode, vertexCount, verts, textures, colors, xmode,
350 indices, indexCount, paint); 349 indices, indexCount, paint);
351 } 350 }
352 351
353 void SkBitmapDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, 352 void SkBitmapDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
354 int x, int y, const SkPaint& paint) { 353 int x, int y, const SkPaint& paint) {
355 const SkBitmap& src = device->accessBitmap(false); 354 draw.drawSprite(static_cast<SkBitmapDevice*>(device)->fBitmap, x, y, paint);
356 draw.drawSprite(src, x, y, paint);
357 } 355 }
358 356
359 SkSurface* SkBitmapDevice::newSurface(const SkImageInfo& info, const SkSurfacePr ops& props) { 357 SkSurface* SkBitmapDevice::newSurface(const SkImageInfo& info, const SkSurfacePr ops& props) {
360 return SkSurface::NewRaster(info, &props); 358 return SkSurface::NewRaster(info, &props);
361 } 359 }
362 360
363 SkImageFilter::Cache* SkBitmapDevice::getImageFilterCache() { 361 SkImageFilter::Cache* SkBitmapDevice::getImageFilterCache() {
364 SkImageFilter::Cache* cache = SkImageFilter::Cache::Get(); 362 SkImageFilter::Cache* cache = SkImageFilter::Cache::Get();
365 cache->ref(); 363 cache->ref();
366 return cache; 364 return cache;
367 } 365 }
368 366
369 /////////////////////////////////////////////////////////////////////////////// 367 ///////////////////////////////////////////////////////////////////////////////
370 368
371 bool SkBitmapDevice::onShouldDisableLCD(const SkPaint& paint) const { 369 bool SkBitmapDevice::onShouldDisableLCD(const SkPaint& paint) const {
372 if (kN32_SkColorType != fBitmap.colorType() || 370 if (kN32_SkColorType != fBitmap.colorType() ||
373 paint.getRasterizer() || 371 paint.getRasterizer() ||
374 paint.getPathEffect() || 372 paint.getPathEffect() ||
375 paint.isFakeBoldText() || 373 paint.isFakeBoldText() ||
376 paint.getStyle() != SkPaint::kFill_Style || 374 paint.getStyle() != SkPaint::kFill_Style ||
377 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) 375 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode))
378 { 376 {
379 return true; 377 return true;
380 } 378 }
381 return false; 379 return false;
382 } 380 }
OLDNEW
« no previous file with comments | « no previous file | src/core/SkCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698