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

Side by Side Diff: cc/resources/resource_provider.h

Issue 754433003: Update from https://crrev.com/305340 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 | « cc/resources/picture_pile.cc ('k') | cc/resources/resource_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 #ifndef CC_RESOURCES_RESOURCE_PROVIDER_H_ 5 #ifndef CC_RESOURCES_RESOURCE_PROVIDER_H_
6 #define CC_RESOURCES_RESOURCE_PROVIDER_H_ 6 #define CC_RESOURCES_RESOURCE_PROVIDER_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 289
290 DISALLOW_COPY_AND_ASSIGN(ScopedReadLockSoftware); 290 DISALLOW_COPY_AND_ASSIGN(ScopedReadLockSoftware);
291 }; 291 };
292 292
293 class CC_EXPORT ScopedWriteLockSoftware { 293 class CC_EXPORT ScopedWriteLockSoftware {
294 public: 294 public:
295 ScopedWriteLockSoftware(ResourceProvider* resource_provider, 295 ScopedWriteLockSoftware(ResourceProvider* resource_provider,
296 ResourceProvider::ResourceId resource_id); 296 ResourceProvider::ResourceId resource_id);
297 ~ScopedWriteLockSoftware(); 297 ~ScopedWriteLockSoftware();
298 298
299 SkCanvas* sk_canvas() { return sk_canvas_.get(); } 299 SkBitmap& sk_bitmap() { return sk_bitmap_; }
300 bool valid() const { return !!sk_bitmap_.getPixels(); } 300 bool valid() const { return !!sk_bitmap_.getPixels(); }
301 301
302 private: 302 private:
303 ResourceProvider* resource_provider_; 303 ResourceProvider* resource_provider_;
304 ResourceProvider::Resource* resource_; 304 ResourceProvider::Resource* resource_;
305 SkBitmap sk_bitmap_; 305 SkBitmap sk_bitmap_;
306 scoped_ptr<SkCanvas> sk_canvas_;
307 base::ThreadChecker thread_checker_; 306 base::ThreadChecker thread_checker_;
308 307
309 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockSoftware); 308 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockSoftware);
310 }; 309 };
311 310
312 class CC_EXPORT ScopedWriteLockGpuMemoryBuffer { 311 class CC_EXPORT ScopedWriteLockGpuMemoryBuffer {
313 public: 312 public:
314 ScopedWriteLockGpuMemoryBuffer(ResourceProvider* resource_provider, 313 ScopedWriteLockGpuMemoryBuffer(ResourceProvider* resource_provider,
315 ResourceProvider::ResourceId resource_id); 314 ResourceProvider::ResourceId resource_id);
316 ~ScopedWriteLockGpuMemoryBuffer(); 315 ~ScopedWriteLockGpuMemoryBuffer();
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 scoped_ptr<IdAllocator> texture_id_allocator_; 591 scoped_ptr<IdAllocator> texture_id_allocator_;
593 scoped_ptr<IdAllocator> buffer_id_allocator_; 592 scoped_ptr<IdAllocator> buffer_id_allocator_;
594 593
595 bool use_sync_query_; 594 bool use_sync_query_;
596 // Fence used for CopyResource if CHROMIUM_sync_query is not supported. 595 // Fence used for CopyResource if CHROMIUM_sync_query is not supported.
597 scoped_refptr<SynchronousFence> synchronous_fence_; 596 scoped_refptr<SynchronousFence> synchronous_fence_;
598 597
599 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); 598 DISALLOW_COPY_AND_ASSIGN(ResourceProvider);
600 }; 599 };
601 600
602
603 // TODO(epenner): Move these format conversions to resource_format.h 601 // TODO(epenner): Move these format conversions to resource_format.h
604 // once that builds on mac (npapi.h currently #includes OpenGL.h). 602 // once that builds on mac (npapi.h currently #includes OpenGL.h).
605 inline unsigned BitsPerPixel(ResourceFormat format) { 603 inline unsigned BitsPerPixel(ResourceFormat format) {
606 DCHECK_LE(format, RESOURCE_FORMAT_MAX); 604 switch (format) {
607 static const unsigned format_bits_per_pixel[RESOURCE_FORMAT_MAX + 1] = { 605 case BGRA_8888:
608 32, // RGBA_8888 606 case RGBA_8888:
609 16, // RGBA_4444 607 return 32;
610 32, // BGRA_8888 608 case RGBA_4444:
611 8, // ALPHA_8 609 case RGB_565:
612 8, // LUMINANCE_8 610 return 16;
613 16, // RGB_565, 611 case ALPHA_8:
614 4 // ETC1 612 case LUMINANCE_8:
615 }; 613 return 8;
616 return format_bits_per_pixel[format]; 614 case ETC1:
615 return 4;
616 }
617 NOTREACHED();
618 return 0;
617 } 619 }
618 620
619 inline GLenum GLDataType(ResourceFormat format) { 621 inline GLenum GLDataType(ResourceFormat format) {
620 DCHECK_LE(format, RESOURCE_FORMAT_MAX); 622 DCHECK_LE(format, RESOURCE_FORMAT_MAX);
621 static const unsigned format_gl_data_type[RESOURCE_FORMAT_MAX + 1] = { 623 static const unsigned format_gl_data_type[RESOURCE_FORMAT_MAX + 1] = {
622 GL_UNSIGNED_BYTE, // RGBA_8888 624 GL_UNSIGNED_BYTE, // RGBA_8888
623 GL_UNSIGNED_SHORT_4_4_4_4, // RGBA_4444 625 GL_UNSIGNED_SHORT_4_4_4_4, // RGBA_4444
624 GL_UNSIGNED_BYTE, // BGRA_8888 626 GL_UNSIGNED_BYTE, // BGRA_8888
625 GL_UNSIGNED_BYTE, // ALPHA_8 627 GL_UNSIGNED_BYTE, // ALPHA_8
626 GL_UNSIGNED_BYTE, // LUMINANCE_8 628 GL_UNSIGNED_BYTE, // LUMINANCE_8
(...skipping 17 matching lines...) Expand all
644 return format_gl_data_format[format]; 646 return format_gl_data_format[format];
645 } 647 }
646 648
647 inline GLenum GLInternalFormat(ResourceFormat format) { 649 inline GLenum GLInternalFormat(ResourceFormat format) {
648 return GLDataFormat(format); 650 return GLDataFormat(format);
649 } 651 }
650 652
651 } // namespace cc 653 } // namespace cc
652 654
653 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ 655 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_
OLDNEW
« no previous file with comments | « cc/resources/picture_pile.cc ('k') | cc/resources/resource_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698