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

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

Issue 1155443004: change internals over to SkPixmap and stop using accessBitmap (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
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"
11 #include "SkDraw.h" 11 #include "SkDraw.h"
12 #include "SkPixelRef.h"
12 #include "SkRasterClip.h" 13 #include "SkRasterClip.h"
13 #include "SkShader.h" 14 #include "SkShader.h"
14 #include "SkSurface.h" 15 #include "SkSurface.h"
15 16
16 #define CHECK_FOR_ANNOTATION(paint) \ 17 #define CHECK_FOR_ANNOTATION(paint) \
17 do { if (paint.getAnnotation()) { return; } } while (0) 18 do { if (paint.getAnnotation()) { return; } } while (0)
18 19
19 static bool valid_for_bitmap_device(const SkImageInfo& info, 20 static bool valid_for_bitmap_device(const SkImageInfo& info,
20 SkAlphaType* newAlphaType) { 21 SkAlphaType* newAlphaType) {
21 if (info.width() < 0 || info.height() < 0) { 22 if (info.width() < 0 || info.height() < 0) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 118
118 SkBaseDevice* SkBitmapDevice::onCreateDevice(const CreateInfo& cinfo, const SkPa int*) { 119 SkBaseDevice* SkBitmapDevice::onCreateDevice(const CreateInfo& cinfo, const SkPa int*) {
119 SkDeviceProperties leaky(cinfo.fPixelGeometry); 120 SkDeviceProperties leaky(cinfo.fPixelGeometry);
120 return SkBitmapDevice::Create(cinfo.fInfo, &leaky); 121 return SkBitmapDevice::Create(cinfo.fInfo, &leaky);
121 } 122 }
122 123
123 const SkBitmap& SkBitmapDevice::onAccessBitmap() { 124 const SkBitmap& SkBitmapDevice::onAccessBitmap() {
124 return fBitmap; 125 return fBitmap;
125 } 126 }
126 127
127 void* SkBitmapDevice::onAccessPixels(SkImageInfo* info, size_t* rowBytes) { 128 bool SkBitmapDevice::onAccessPixels(SkPixmap* pmap) {
128 if (fBitmap.getPixels()) { 129 const SkImageInfo info = fBitmap.info();
129 *info = fBitmap.info(); 130 if (fBitmap.getPixels() && (kUnknown_SkColorType != info.colorType())) {
130 *rowBytes = fBitmap.rowBytes(); 131 SkColorTable* ctable = NULL;
131 return fBitmap.getPixels(); 132 pmap->reset(fBitmap.info(), fBitmap.getPixels(), fBitmap.rowBytes(), cta ble);
133 return true;
132 } 134 }
133 return NULL; 135 return false;
134 } 136 }
135 137
136 #include "SkConfig8888.h" 138 bool SkBitmapDevice::onPeekPixels(SkPixmap* pmap) {
137 #include "SkPixelRef.h" 139 // peek and access are the exact same logic for us
140 return this->onAccessPixels(pmap);
141 }
138 142
139 bool SkBitmapDevice::onWritePixels(const SkImageInfo& srcInfo, const void* srcPi xels, 143 bool SkBitmapDevice::onWritePixels(const SkImageInfo& srcInfo, const void* srcPi xels,
140 size_t srcRowBytes, int x, int y) { 144 size_t srcRowBytes, int x, int y) {
141 // since we don't stop creating un-pixeled devices yet, check for no pixels here 145 // since we don't stop creating un-pixeled devices yet, check for no pixels here
142 if (NULL == fBitmap.getPixels()) { 146 if (NULL == fBitmap.getPixels()) {
143 return false; 147 return false;
144 } 148 }
145 149
146 const SkImageInfo dstInfo = fBitmap.info().makeWH(srcInfo.width(), srcInfo.h eight()); 150 const SkImageInfo dstInfo = fBitmap.info().makeWH(srcInfo.width(), srcInfo.h eight());
147 151
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 void SkBitmapDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, 353 void SkBitmapDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
350 int x, int y, const SkPaint& paint) { 354 int x, int y, const SkPaint& paint) {
351 const SkBitmap& src = device->accessBitmap(false); 355 const SkBitmap& src = device->accessBitmap(false);
352 draw.drawSprite(src, x, y, paint); 356 draw.drawSprite(src, x, y, paint);
353 } 357 }
354 358
355 SkSurface* SkBitmapDevice::newSurface(const SkImageInfo& info, const SkSurfacePr ops& props) { 359 SkSurface* SkBitmapDevice::newSurface(const SkImageInfo& info, const SkSurfacePr ops& props) {
356 return SkSurface::NewRaster(info, &props); 360 return SkSurface::NewRaster(info, &props);
357 } 361 }
358 362
359 const void* SkBitmapDevice::peekPixels(SkImageInfo* info, size_t* rowBytes) {
360 const SkImageInfo bmInfo = fBitmap.info();
361 if (fBitmap.getPixels() && (kUnknown_SkColorType != bmInfo.colorType())) {
362 if (info) {
363 *info = bmInfo;
364 }
365 if (rowBytes) {
366 *rowBytes = fBitmap.rowBytes();
367 }
368 return fBitmap.getPixels();
369 }
370 return NULL;
371 }
372
373 SkImageFilter::Cache* SkBitmapDevice::getImageFilterCache() { 363 SkImageFilter::Cache* SkBitmapDevice::getImageFilterCache() {
374 SkImageFilter::Cache* cache = SkImageFilter::Cache::Get(); 364 SkImageFilter::Cache* cache = SkImageFilter::Cache::Get();
375 cache->ref(); 365 cache->ref();
376 return cache; 366 return cache;
377 } 367 }
378 368
379 /////////////////////////////////////////////////////////////////////////////// 369 ///////////////////////////////////////////////////////////////////////////////
380 370
381 bool SkBitmapDevice::onShouldDisableLCD(const SkPaint& paint) const { 371 bool SkBitmapDevice::onShouldDisableLCD(const SkPaint& paint) const {
382 if (kN32_SkColorType != fBitmap.colorType() || 372 if (kN32_SkColorType != fBitmap.colorType() ||
383 paint.getRasterizer() || 373 paint.getRasterizer() ||
384 paint.getPathEffect() || 374 paint.getPathEffect() ||
385 paint.isFakeBoldText() || 375 paint.isFakeBoldText() ||
386 paint.getStyle() != SkPaint::kFill_Style || 376 paint.getStyle() != SkPaint::kFill_Style ||
387 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) 377 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode))
388 { 378 {
389 return true; 379 return true;
390 } 380 }
391 return false; 381 return false;
392 } 382 }
OLDNEW
« no previous file with comments | « include/core/SkPixmap.h ('k') | src/core/SkCanvas.cpp » ('j') | src/core/SkPixmap.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698